SomaLoader

SomaLoader is a lightweight loading manager written in AS3. You can load many types such as images, swf, xml, text, xml, css, fonts in a swf, mp3, variables and binary data. Items can be added, removed and changed in position from the queue even while loading.

SomaLoader provides a simple and unique interface for massive loading, to listen to events and access to data.

SomaLoader has some specific features such as targeting before loading, easy loading progress display, caching system and binary loading for “silent loading”.

SomaLoader is a standalone version of the library you will find in the version 2 of the Soma framework.

This work is licenced under a Mozilla Public License 1.1 (MPL 1.1)

Version 1.0.2

demo

docs

source code and tutorials on the SomaLoader google code project

Vote in HexoSearch
34 Responses to “SomaLoader”
  1. nyls says:

    Nice loader,

    is there a way to add the context for swf files ??

    Niels

  2. Romuald says:

    yes, using the loaderContext property of the SomaLoader instance:

    var loader:SomaLoader = new SomaLoader();
    loader.loaderContext = myLoaderContext;

  3. ffx says:

    Hi,

    really awesome work you are doing. Thanks a lot.

    Cool would be a option to set max parallel connections like bulkloader in the constructor:

    http://www.stimuli.com.br:8080/media/projects/bulk-loader/docs/

  4. Romuald says:

    Hi ffx

    Thanks for the comment :)

    I thought a lot about having a single connection or a defined number of connections. The problem is more connections you have, less responsive the Flash Player might be (depending or what you’re loading).

    The thing is I’ve never really needed that, I guess having multiple connections can be useful for mass loading from multiple domains. Otherwise, loading items from a single domain, I’m not even sure multiple connections would be quicker.

    So, I still think about. Just to understand and maybe convince me, why would you need to have multiple connections for?

    Romu

  5. ffx says:

    That’s exactly the reason why I mentioned it. I also experienced lot of slow downs if I load a lot in a parallel way. So if there is no parallel loading at all in one instance, I am happy with it.

  6. ActionScript 3.0????? ??? ?? OpenSource AS3 Library|API | 5ii??????? says:
  7. Flex code Libraries « Vinod_danims Blog says:
  8. Fernando says:

    Hi, if I loaded a SWF with somaloader, how can I access something inside that Moviclip?

    Thanks

  9. Romuald says:

    Like this:


    function completeHandler(e:SomaLoaderEvent):void {
    if (e.item.type == SomaLoader.TYPE_SWF) {
    var movie:MovieClip = e.item.file as MovieClip;
    movie.gotoAndPlay(20);
    }
    }

    Here I cast it to a MovieClip, but try to trace(e.item.file), and you should see the Document Class of the loaded SWF, so you can cast it to another class instead of a MovieClip.


    var movie:MyDocumentClass = e.item.file as MyDocumentClass;
    movie.myMethod();

    This has nothing to do with SomaLoader, it would be the same with a Flash built-in loader (as they are used in SomaLoader).

    Romu

  10. Fernando says:

    Thank you.
    I was casting it as a Sprite, but it has its own class.

  11. Henry Schmieder says:

    Hey Romu, great Loader. Was just about to play a little with it. First thing I struggled was that I couldn’t find a way to access a loaded SWF’s library / Symbol definitions. Ideally there was a additional property applicationDomain in the SomaLoaderItem, that gets copied over from the LoaderInfo Object. Via applicationDomain.getDefinition() I could then gather all linked Symbols from the loaded swf lib.

  12. Henry Schmieder says:

    Also a custom id for each loader item would be cool, i.e. to check against in the complete handler. Now as far I see I can only check against the document class or the url ( type doesnt make sense if I load 10 asset swfs )
    I know the url acts as an id. ( getItem( url ) ), but what if I use different urls upon a runtime check, if the movie runs local, local remote or remote.

    loader.add( “mySWF.swf”, myId )

    private function completeListener( event:SomaLoaderEvent ):void {
    if( event.item.id == myId ) {
    // do someth
    }
    }

  13. Huge list of external libraries | DestroyYourComputer.com | Blog - Interactive Design Agency says:
  14. Martin Klasson says:

    Henry, you got a “data”-parameter you can setup as any custom object, for example {id:”MY_ID”} when adding items to the SomaLoader-instance. Take a look at the parameters when adding an item.

    The one thing I am missing – in which will make me try out other loaders – is that I would love to be able to add event listeners to specific items, and not only to the SomaLoader-instance. I feel that it is necessary when having different classes being able to monitor and follow the specific item needed.

    For now, if I want to listen for a specific item – I must listen to the SomaLoader-events – adding an if:

    private function onSomaLoaderCompleteInstanceEventHandler(event:SomaLoaderEvent):void
    if(event.item.file == “matchesthisfile.jpg”){
    trace(“Now MY FILE was completed”)
    }
    }

    But this seems to be a bad option if you have many places that all the time will be needing of a specific listener.

    having this would be cool:
    somaLoaderInstance.getItem(“myfile.jpg”).addEventListener(SomaLoaderEvent.START, onStartHandler)

    I dont think this would be hard to implement without breaking anything.

  15. Romuald says:

    hi martin,

    I kind of build it to be able to monitor without having to do that:
    somaLoaderInstance.getItem(”myfile.jpg”).addEventListener

    Now you are not the first one asking me this and I can undertand it might be useful.

    I’ll have a look when I get a chance!

    Romu

  16. Martin Klasson says:

    Hello Romuald,

    If you are having time – and if you think my idea is a good addition – please feel free to email me if there are any questions or tests you want me to be apart of.

    I managed my project without the somaLoaderItem.addEvent… so it is not a must-have feature – but it would have made the coding more practical and easier to write.

  17. Narek Gevorgyan says:

    Hello Romuald, please can you help me, I have a problem with soma loader

    //skin.php
    $file = “skin.swf”;
    header(“Date: “.date(DATE_RFC822));
    header(“Server: Apache”);
    header(“Last-Modified: “.date (DATE_RFC822, filemtime($file)));
    $fs = stat($file);
    header(“Etag: “.sprintf(‘”%x-%x-%s”‘, $fs['ino'], $fs['size'],base_convert(str_pad($fs['mtime'],16,”0″),10,16)));
    header(“Accept-Ranges: bytes”);
    header(“Content-Length: “.filesize($file));
    header(“Keep-Alive: timeout=2, max=200″);
    header(“Connection: Keep-Alive”);
    header(“Content-Type: application/x-shockwave-flash”);
    //readfile($file);

    I am using this PHP code to generate skin file for application and this is one of the files, I took this headers from sniffing HTTP requests :D I did everything, if file is not generated by php, Somaloader works perfect, Loader class works well for both variants.And Here is the Error.

    TypeError: Error #2007: Parameter bytes must be non-null.
    at flash.display::Loader/_loadBytes()
    at flash.display::Loader/loadBytes()
    at spb.model::ApplicationDataProxy/somaLoader_completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.soma.loader::SomaLoader/completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    ReferenceError: Error #1069: Property width not found on String and there is no default value.
    at spb.model::ContentProxy/somaLoader_completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.soma.loader::SomaLoader/completeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    Hope you’ll find some spare time for this.And thanks.
    Sincerely
    Narek

  18. Narek Gevorgyan says:

    Hi Romuald, your loader works perfect, I found solution. I changed my URLs from http://localhost/asset/skin/ to http://localhost/asset/skin.swf
    Sincerely
    Narek.

  19. AS3 Code Libraries (APIs) – Joe's private place says:
  20. Librerie AS3 | ricivt.com says:

    [...] SomaLoader – A lightweight loading manager written in AS3http://www.soundstep.com/blog/downloads/somaloader/ [...]

  21. ActionScript 3.0 最新开源项目(转) « fanflash's blog says:
  22. Adrian Sule - My random thoughts on Flash and Flex » Collection of libraries says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  23. AS3 Code Libraries (APIs) « Tournas Dimitrios says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  24. Tibor says:

    hi! I need any fix for caching problem, after i update my site – export and compile, I cant see changes in firefox.
    Anyone any advice to fix this ?

    Thank you!

  25. Romuald says:

    That’s the browser caching issue, not a loader cache issue.

    What’s cached is the SWF file that the browser load.

    Try this in your HTML that load the SWF file:

    Instead of:
    “main.swf”
    do:
    “main.swf?t=” + new Date().getTime()

    This will produce a unique swf file name with the parameter based on the time, Firefox will reload the swf everytime.

    Romu

  26. 多款as3游戏框架 says:

    [...] * QueueLoaderAS3 http://code.google.com/p/queueloader-as3/ * SomaLoader http://www.soundstep.com/blog/downloads/somaloader/ OOP面向对象程序开发框架 * Cairngorm [...]

  27. AS3 各种引擎收集 « Cookfl says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  28. ActionScript. 3.0著名开源库 | 痴豆网 says:
  29. TouchLibs » Blog Archive » AS3 Code Libraries (APIs) says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  30. AS3 CODE Library (API) - Mijimiji Blog says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  31. AS3 Code Libraries (APIs) | bytecoderz blog says:

    [...] SomaLoader – A lightweight loading manager written in AS3 http://www.soundstep.com/blog/downloads/somaloader/ [...]

  32. ActionScript Library says:
  33. Salina Feilds says:

    Keep up the good article, added to my ie rss.

  34. ActionScript Фреймворк | НОВОЕ ИЗМЕРЕНИЕ says:

    [...] SomaLoader — «легковесный» AS3 менеджер для управления загрузкой. [...]

Leave a Reply