LoaderMax – Smart AS3 Loading
- Version: 1.921, Updated 2012-08-09
- Compatibility: AS3 (Flash Player 9 or later)
LoaderMax is a new AS3 loading system that does for loading what TweenLite and TweenMax did for tweening, simplifying and enhancing the entire process. LoaderMax does much more than just get swf, mp3, css, video, image, text, binary, and xml files into your Flash application. It eats files for dinner, burps, and then asks for 2nds. And 3rds. Yet it’s surprisingly thin. In fact, it can be half the size of most other loading systems even though it delivers a surprising number of unique capabilities, some of which you probably never knew you needed but won’t want to live without. Here are a few of the noteworthy features:
- Integrated subloaders – LoaderMax can recognize other LoaderMax-related loaders inside an asset being loaded and integrate them into the overall loading progress and the event model of the main loader. For example, if LoaderA subloads LoaderB which subloads LoaderC, LoaderA can report the entire group’s progress and not dispatch its COMPLETE event until LoaderB and LoaderC have finished loading (see the ASDocs about the “requireWithRoot” special property to enable this feature).
- Flexible setup – build loaders in a variety of ways, including single-item loaders from nothing more than a URL (LoaderMax can automatically determine which type of loader to use based on the file extension) and loader queues automatically assembled from XML documents or an array of URLs.
- Prioritize on the fly – build a queue that intelligently loads assets in the order specified but that can easily reprioritize any asset anytime. For example, if the user clicks something that requires loading immediately, just prioritize() its loader.
- Tight file size – Many other systems are 16-24k+ even if you’re just loading text, but LoaderMax can be as little as 7k (depending on which loader types you use).
- Detailed progress reporting – show progress of individual loaders or groups of loaders.
- Robust event system – easily add event listeners, including multiple listeners in a single line of code. Events bubble up through LoaderMax hierarchies and carry a consistent target for easy identification.
- Define an alternateURL for any loader – If the original url fails to load, it will automatically switch to the alternateURL and try again.
- Avoid common Flash bugs/hassles – LoaderMax solves many problems like the recently discovered issues with subloading swfs that use TLF as well as garbage collection headaches with subloaded swfs, images, and NetStreams.
- Pause and resume loads in progress
- Conveniences galore – prevent asset caching, optionally manipulate many display characteristics like image smoothing, centering registration points, positioning, and many more. Set a width/height for an ImageLoader, SWFLoader, or VideoLoader and when it loads, the image/swf/video will automatically scale to fit using any of the following scaleModes: “stretch”, “proportionalInside”, “proportionalOutside”, “widthOnly”, or “heightOnly”. Even crop the asset inside that area with crop:true
- Common set of properties and methods – all loaders types (XMLLoader, SWFLoader, ImageLoader, MP3Loader, CSSLoader, VideoLoader, LoaderMax, etc.) have name, status, loadTime, paused, bytesLoaded, bytesTotal, and progress properties as well as methods like load(), pause(), resume(), prioritize(), unload(), cancel(), auditSize() and dispose() delivering a touch of polymorphism sweetness.
- Media playback controls in VideoLoader and MP3Loader – operationally control video and MP3 assets including methods that play, pause, and go to a specific time; properties that get or set volume, time, and duration; and events that monitor playback progress and more.
- Automatic parsing of LoaderMax-related nodes inside XML – XMLLoader can look for LoaderMax-related nodes like <LoaderMax>, <ImageLoader>, <SWFLoader>, <XMLLoader>, <VideoLoader>, <DataLoader>, <CSSLoader>, <MP3Loader>, etc. inside XML files that it loads, and if any are found it can create the necessary instances and then begin loading any that had a load=”true” attribute, integrating them into the XMLLoader’s overall progress. See XMLLoader’s ASDocs for details.
- Nest LoaderMax instances inside other LoaderMax instances as deeply as you want. – A LoaderMax instance is basically a queue of loaders which makes it simple to control or report their progress as a whole. You can put one queue into a slot inside another – group and nest them however you want. This makes complex queues simple.
- Find loaders and content by name or url – Every loader has a name property which you can use to uniquely identify it. Feed a name or URL to the static LoaderMax.getLoader() or LoaderMax.getContent() methods to quickly get the associated loader or content from anywhere.
- maxConnections – Set the maximum number of simultaneous connections for each LoaderMax instance (default is 2). This can speed up overall loading times.
- Helper classes for code hinting and strict data typing – Check out the com.greensock.loading.data package for classes like LoaderMaxVars, ImageLoaderVars, XMLLoaderVars, etc.
- Flex friendly – Simply change the LoaderMax.contentDisplayClass to FlexContentDisplay and then ImageLoaders, SWFLoaders, and VideoLoaders will return content wrapped in a UIComponent.
Interactive demo 1
Getting Started
Check out Rich Shupe’s “Meet LoaderMax” video series.
Documentation
Please view full ASDoc documentation here.
Tips & Tricks
Please see the dedicated tips & tricks page.
Sample AS3 code
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
//append several loaders
queue.append( new XMLLoader("xml/data.xml", {name:"xmlDoc"}) );
queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) );
queue.append( new SWFLoader("swf/child.swf", {name:"childClip", estimatedBytes:3000, container:this, x:250, autoPlay:false}) );
queue.append( new MP3Loader("mp3/audio.mp3", {name:"audio", repeat:2, autoPlay:true}) );
//prioritize the loader named "photo1"
LoaderMax.prioritize("photo1"); //same as LoaderMax.getLoader("photo1").prioritize();
//start loading
queue.load();
function progressHandler(event:LoaderEvent):void {
trace("progress: " + event.target.progress);
}
function completeHandler(event:LoaderEvent):void {
var image:ContentDisplay = LoaderMax.getContent("photo1");
TweenLite.to(image, 1, {alpha:1, y:100});
trace(event.target + " is complete!");
}
function errorHandler(event:LoaderEvent):void {
trace("error occured with " + event.target + ": " + event.text);
}
Interactive demo 2
Avoid bugs, inconsistencies, and hassles
Reliability is a huge concern when it comes to loading external assets. Did you know there are a bunch of bugs, inconsistencies, and hassles in Adobe’s loading classes (Loader, URLLoader, NetStream, and Sound) that could cause trouble in your project? This is another reason why so many developers are shifting to LoaderMax – it works around these issues and provides a more stable, reliable, and robust foundation for loading. Use LoaderMax to avoid these issues:
- Adobe’s Loader doesn’t properly subload swf files that use Adobe’s TLF. The preloading animation stays on the screen and the Loader’s “content” doesn’t refer to the real swf root, so reference errors are generated. See Adobe’s note here. See example here..
- When MouseEvent listeners are added to swf content loaded by Adobe’s Loader, they are not dispatched properly (at least when the swf was published by CS5). See example here..
- If close() is called on a Loader before its INIT event is dispatched, the content may not be properly unloaded or garbage collected.
- If BitmapData.draw() is called on a partially-loaded child swf that contains a NetStream that hasn’t started yet, SECURITY_ERRORs are thrown.
- If close() is called on an in-progress Loader, its bytesLoaded reports incorrectly on all subsequent loads even for completely different files. It cannot be reused effectively.
- In certain browsers, a Loader or URLLoader’s bytesLoaded is occasionally reported as being greater than bytesTotal (impossible) when gzip is enabled on the server. This can lead to the progress never reaching 1.
- Subloaded swf files may not be properly unloaded or garbage collected if all nested MovieClips aren’t stopped first and even if they are, the swf may not unload properly. It can be particularly problematic if the child swf has audio that’s attached to the timeline as a “stream”.
- If pause() is called on a NetStream before the metaData is received (client.onMetaData() is called), it will never be received even after the NetStream resumes.
- If Video.attachNetStream() is called when the NetStream’s buffer is full, the NetStream doesn’t attach properly (it doesn’t display). (See example FLA)
- Video.attachNetStream() doesn’t work properly when called as the video is added to the display list with addChild() unless you seek() at the same time. That seek() cannot be to a time after the last encoded keyframe either or it won’t work. (See example FLA)
- If NetStream.pause() is called when the NetStream isn’t attached to a Video object and the buffer isn’t full, it acts as though it continues playing (ignoring the pause() call).
- If you publish your swf using Flash CS3 or CS4 and target Flash Player 9, NetStreams don’t reliably dispatch a “NetStream.Buffer.Full” NetStatusEvent for progressive downloads.
- The Video object’s scrollRect won’t work properly unless the Video’s size is initially set to 320×160
- If you seek() a NetStream to a position between the last keyframe and the end of the video, a NetStreamEvent with the info code “NetStream.Play.Stop” will be dispatched even if the NetStream is paused.
- If you seek() a NetStream before it dispatches its first RENDER event, it will completely lose its audio.
- NetStream only dispatches RENDER events when you publish to Flash Player 10 or later. For Flash Player 9, the only reliable way to know that it has rendered is to wait about 50ms.
- If you call the Video object’s attachNetStream(null) method from within the RENDER event handler on the NetStream that was attached to it, Flash occasionally crashes (you can call it from pretty much anywhere else without a problem).
- Sometimes a NetStream will dispatch a NetStatusEvent with a code of “NetStream.Play.Start” before the buffer has filled
- As of Flash Player 11, if you call a NetStream’s seek() method on the same frame as when it finishes playback, it causes a flicker. This makes seamless looping…well…not seamless. You must wait a frame before doing the seek().
- Unlike Loader, URLLoader, and Sound, there are no PROGRESS events dispatched by NetStream. To track its loading progress, you’d need to set up a Timer or ENTER_FRAME handler to keep checking the bytesLoaded and bytesTotal.
- Even if you listen for the appropriate NetStatusEvent indicating that a NetStream is starting and pause() it immediately, you can often see the video briefly animate before it pauses and you can hear the audio briefly as well.
- If you seek() to a certain time in a NetStream and then immediately check its “time” property, it is often incorrect (reflects the previous time, not the new one)
- Sometimes a NetStream will report a “time” that is greater than its duration (which would be impossible of course). When it has finished playing, sometimes it reports a “time” that doesn’t match the duration either.
- Occassionally Flash garbage collects a NetStream that’s attached to a Video and playing if two LocalConnections are connected with the same name.
- There is a bug/inconsistency in Adobe’s NetStream class that causes relative URLs to use the swf’s location as the base path instead of the HTML page’s location like all other loaders. Therefore, it would be wise to use the “base” attribute of the <OBJECT> and <EMBED> tags in the HTML to make sure all relative paths are consistent. See http://kb2.adobe.com/cps/041/tn_04157.html for details.
- A Sound object’s length doesn’t reflect its duration until it is completely loaded.
- If close() is called on a Sound object, it no longer reports its bytesLoaded properly so it cannot be reused effectively.
- Sometimes a SoundChannel’s position reports as being greater than the duration (should be impossible)
- By default, images and swfs from other domains are loaded with heightened security restrictions that prevent bitmap smoothing, BitmapData captures, and script access in swfs.
- If you add URLVariables to a URLRequest and set the URLRequest’s url to a String that has been modified using any of the String’s methods like split(), substr(), etc., in certain versions of the Flash Player (like 10.0.12.36) Flash will omit the “?” that separates the URL from the GET variables, causing invalid addresses.
FAQ
- Where do I get the code?
LoaderMax is included in the main AS3 GreenSock download zip – just click the “Download AS3″ button at the top right corner of this page. - What if I need to send variables to the server along with my request in a loader?
The first parameter of the various loaders (ImageLoader, XMLLoader, SWFLoader, MP3Loader, etc.) accepts either a simple String URL or a URLRequest. So if you want to pass data to the server, simply construct a URLRequest accordingly, like:var request:URLRequest = new URLRequest("http://www.yourDomain.com/whatever.php"); var data:URLVariables = new URLVariables(); data.exampleSessionId = new Date().getTime(); data.exampleUserLabel = "label1"; request.data = data; request.method = URLRequestMethod.POST; var loader:ImageLoader = new ImageLoader(request, {name:"image1"}); - Do I need to define estimatedBytes for all my loaders?
Nope. If you don’t define one, the default value of 20000 will be used. The only benefit of defining an estimatedBytes is to make the loader’s progress more accurate before it has downloaded enough information to determine the bytesTotal. Once it can accurately determine the bytesTotal, it will stop using the estimatedBytes. By default, when a LoaderMax loads, it will loop through its children first and find any that don’t explicitly define an “estimatedBytes” and quickly open a URLStream to determine the bytesTotal if possible. There’s a slight speed penalty when the LoaderMax first starts loading, but it makes it very accurate. You can turn that feature off with auditSize:false in your LoaderMax’s vars parameter. - If a child loader inside a LoaderMax has already completed and I call load() again on the LoaderMax, will it waste time reloading that already-completed loader?
No. If a loader has completed, LoaderMax will skip it in the queue for maximum efficiency and performance. If you want to force a full reload, though, set the “flush” parameter to true in your load() call, like myLoader.load(true) - Why do I have to use different loader types (ImageLoader, XMLLoader, SWFLoader) instead of LoaderMax automatically figuring out the appropriate type based on the file extension in the URL?
Actually, LoaderMax has a parse() method that can do exactly that (automatically figure out the appropriate loader type based on the file extension) – you just need to make sure you use LoaderMax.activate() first to activate the loader types that you want LoaderMax to be able to recognize like LoaderMax.activate([ImageLoader, SWFLoader]). This extra step may seem annoying, but there are a few reasons LoaderMax doesn’t activate all loader types by default:- Doing so would force ALL types of loaders to be compiled in your swf so that they’re available just in case you need them. Your project may never need an SWFLoader or MP3Loader, etc. but they would still be compiled into your SWF to accommodate “lazy” loading. In my opinion, this bloats the whole system which isn’t good because a loading system should be relatively lightweight in order to get things moving quickly.
- It’s virtually impossible to accurately determine the file type if the extension is something like “.php” because you could have a server-side script that spits back any type – an image, an XML file, etc. In those cases, the “lazy” system would break down. You’d have to explicitly define the type anyway.
Ultimately I believe it is much cleaner to have the developer choose the appropriate loader for the asset whenever possible and it definitely allows the system to be more lightweight and efficient. It could literally reduce the file size requirement by more than 60%.
- Is the LoaderMax API finalized? Might it change?
This is a 1.0 release and while there are no plans to make any changes to the API, my experience has been that feedback from the community is invaluable and can help shape the API. I try to keep improving things to serve end users better, so don’t be surprised if there are some changes in upcoming months. I would recommend checking back frequently for updates or sign up for Club GreenSock so that you can be notified. - Can I make suggestions for improving LoaderMax?
Please do! Either in the comments section below or in the forums. - Why did you use the loosely typed vars parameter to define all the special properties (like {name:”myLoader”, width:100, height:200}) instead of regular strong-typed parameters or properties? Your way doesn’t give me code hinting either.
Don’t worry – you can get code hinting and strong data typing by using the data classes in the com.greensock.loading.data package, but two of the primary objectives were to keep file size to a minimum and encourage readable code, neither of which could be accomplished very well without using a generic vars object by default. There are quite a few optional special properties for various loaders (SWFLoader recognizes 41!) and regular constructor parameters just wouldn’t be feasible. Which one is more readable?:new SWFLoader("main.swf", "myFile", 100, 100, 200, 200, this, completeHandler, null, null, progressHandler); -OR- new SWFLoader("main.swf", {name:"myFile", x:100, y:100, width:200, height:200, container:this, onComplete:completeHandler, onProgress:progressHandler});But again, if you want strong typing and code hinting, use data classes in the com.greensock.loading.data package (like LoaderMaxVars, ImageLoaderVars, XMLLoaderVars, etc.) which allow you to define all your vars with a special object.
- Can I get the source code for the demos above?
Sure, download it here. - Is LoaderMax available in AS2? Will it be?
The tweening platform and TransformManager, GreenSock’s 2 most popular products, ARE available in AS2 as well as AS3 but LoaderMax is only AS3 because…well…AS2 has been on the decline for a long time and LoaderMax relies heavily on the event system in AS3 so it would be a much bigger challenge to port it to AS2. Then there’s maintenance. Right now, every time I make an update to the AS3 version of TweenLite/Max/TimelineLite/Max/TransformManager, I must also make the update to the AS2 versions, copy all the files, create zips, post to the SVN, update the bonus zips for members, etc., Then there are language-specific differences I’d need to accommodate. So it just doesn’t seem worthwhile to do for a product like LoaderMax especially since AS2 is headed towards extinction. - Will you be posting more examples?
Yes. - Do I have to purchase a license to use this code? Can I use it in commercial projects?
You may use the code at no charge in commercial or non-commercial web sites, games, components, applications, and other software as long as end users are not charged a fee of any kind to use your product or gain access to it. If your client pays you a one-time fee to create the site/product, that’s perfectly fine and qualifies under the “no charge” license. If multiple end users are charged a usage/access/license fee of any kind, please simply sign up for a corporate Club GreenSock membership which comes with a special commercial license granting you permission to do so. Click here for details. Club GreenSock members get several useful bonus plugins, classes, update notifications, SVN access, and more. Please see the licensing page for details on licensing.
Need help?
Please post your question in the forums. You’ll increase your chances of getting a prompt answer if you provide a brief explanation and include a simplified FLA file (and any class files) that clearly demonstrates the problem.
Comments (117)

I’m very excited to try the new library out Jack, loving the features you’ve included! Thank you for sharing!
GreenSock have done it again. My life just got a whole lot easier. Thank you!
Amazing work. Again. Thank you so much!
Ah, if only you released this 5 days ago!
Very nice work, I can’t wait to use it in my next project.
Watching Rich demo it now. Thanks, Jack.
I was one of the beta testers on this system, and have had some time to play aound with it on various projects. I truly recommend anyone dealing with web design/development to give it a go. It wil save you a huge load of time and trouble! (Sorry, couldn’t help the pun).
Congratulations! I’m already using it for production while it was beta
, working like charm!
You deserve a medal, Jack!
Wow that was close… I started down the road of creating my own, but I think I will use yours instead!
This is such a great utility and was built smartly. I’ve already started playing with it on multiple levels. Thank you so much!!
Insane feature, it is a kind of bulkLoader, but very better. INSANE
Great stuff (again). They should give out extremely shiny gold stars for this sort of thing. As ever, thanks for sharing all your hard work…
Again ? Jacks seal of quality: Small size and nestable. First TweenLite and now this ? Im a good Coder, but now i have inferiority complexes.
I hate you!
Amazing. Many thanks.
Awesome! Great work as usual guys!
Jack you are the man. This is so well done and sorely needed.
Amazing job! Thanks for all of your hard work!
Fantastic work as always Mr. Green
)
Wow. Make that Wow!
Great, man.
Frikkin awesome!! No more loading pains!!
Awesome!, I’m gonna play with it right now! ;
Very nice, I’ll take a look at it. Maybe this will be a good competitor for the also amazing Arthur Debert’s Bulk Loader (http://code.google.com/p/bulk-loader/).
Saving dev lives left right and centre Jack Doyle – whoever you are! Thanks again!
Been using QueueLoader for most of my previous projects, really looking forward to playing with this though – centering the registration point and setting required w & h before its loaded, hell yeah!
There probably isn’t, but I’ll still ask – Is there any performance penalties in XMLLoader while it checks for LoaderMax specific tag names? And if so, can we disable this?
Silly me – integrateProgress = false to disable XMLLoader looking for LoaderMax related nodes
Haven’t had a chance to work with LoaderMax yet, but just cos it’s from GreenSock I know I’m gonna love it!
Well, after a little look at the LoaderMax i can say that it IS better than the BulkLoader in a lot of ways. It’s like a future version of it for me, plus lots of extras like you always do.
This is going to be a huge hit! You’re doing so much good to the community, Jack. You the man! Adobe should thank you personally and offer a partnership or something!
I love that it can eat seconds, then thirds, and still stay slim! Loving it. Thanks for the lib – looking forward to using it as much as possible.
rocking again, jack!
This is awesome! I will definitly integrate it in the next release of the Fleb Framework (www.flebframework.com)!
Best work, as usual!
Thanks Jack! I already used it while it was beta.
Keep up the great work and make our life easier!
Fantastic Library!
Great job Jack!
Many projects especially those like micro/publicity web apps require all time loads so loads are in some cases my first concern. That’s why I have been working with bulkLoader for a while and I use a class that manage all the load’s that my app requires thru bulkloader and XML.
Now you create this…wow.. it’s like “listening” my methods!? ![]()
Great job Jack!
Nice class ! Very usefull. I will use it in my next projects, for sure. Thanks for sharing
Great tools.I like it.
How can I cast a loaded SWF to a custom datatype (like a baseclass or Interface)
Get rumtime errors when I try…
Got it! This is how:
var myLoadedSWF : MyCustomDataType;
myLoadedSWF = SWFLoader.rawContent as MyCustomDataType;
addChild(_module as DisplayObject);
I wrote my own class a couple weeks ago – MultiLoader… what a waste of time because this kicks my loader’s @$$. I’m proud to be a shockingly green member. Thanks for making my life so much easier.
Once again you guys have rocked it. This is exciting, and I am going to start a new project just as a study in LoaderMax.
Thanks
About Freakn’ time dude!!! I remember a time about a year ago when I asked if you were going to create this. And now you have!
Super awesome job! Best script ever
Brilliant. Magic.
I’ve been wishing and hoping GreenSock would do this for years! I’m so absolutely excited and happy, it raises suspicion.
Awesome! Thank you!
-B
thanks for sharing~~
Awesome! This looks like an awesome preloading class… I can wait to try it out. Thanks for sharing!
Fantastic work…as always
Well… If I needed a kick up the backside to finally switch to as3, then this is it.
Ok jack you’ve finally convinced me.
Fine work.
Thanks for this amazing utility! I’ve been able to overhaul my entire workflow.
This is so awesome, thanks for your efforts!
Feature request: DownloaderMax – Ability to queue up files like this for physical download to local machine with directory structure. Would be absolutely perfect for offline AIR apps that depend on externally loaded content.
Very nice loader solution
Thanks a lot for sharing this !
This is great! I’ve built several loaders overtime, usually in response to a project’s need, and each time have improved on reusability, and features, but haven’t taken it this far. Thanks!!!
Is it possible to pass a parameter to the onComplete handler. Kinda like:
_swfLoader = new SWFLoader(“child.swf”, {parameters:["josé", "joão"], onComplete:_completeHandler});
function _completeHandler(event:LoaderEvent):void {
trace(event.target.parameters);
}
This is brilliant. Kudos, Jack.
Sure, you can use the vars object to store your data, like this:
_swfLoader = new SWFLoader(“child.swf”, {parameters:["josé", "joão"], onComplete:_completeHandler});
function _completeHandler(event:LoaderEvent):void {
trace(event.target.vars.parameters);
}
Hi,
Could you access events in loaderMax?
I would like to know when an element has loaded but not with an onComplete function.
I would like to add an event listener to do that.
Listen to events and take actions based on that.
Thanks
Absolutely, Farnando – LoaderMax is fully compatible with the standard addEventListener() way of working in AS3. The various special properties like onComplete, onProgress, onFail, etc. are simply shortcuts that allow you do set up all those listeners in one fell swoop. It shortens the amount of code you need to write, but feel free to do stuff like this if you prefer:
loader.addEventListener(LoaderEvent.COMPLETE, completeHandler);
Jack, you never cease to amaze!
How are files loaded?
If I add 3 images to the queue, do they start to load all at the same time?
I ask because I would like to be able to load sequentially. One file at a time. Is that possible?
Or do I have to load one file, wait until it’s finished loading and then add the next one to the loader?
LoaderMax gives you complete control over how your queue loads. There’s a maxConnections property that controls how many files it will try to load simultaneously (the default value is 2 which provides a nice mix of prioritization and speed). If you set maxConnections to 1, it will load one file at a time, but loading things sequentially like that is slightly slower because it doesn’t allow Flash to leverage multiple streams at the same time. In other words, if maxConnections is 2 instead of 1, it will finish the overall load of the entire queue a bit faster because it can make better use of your connection.
If you want things to load sequentially one-after-the-other, just set maxConnections to 1, dump all your loaders into the LoaderMax, and let ‘er rip. LoaderMax will handle everything for you.
Jack, thank you so much! You get the high score for karma points, helping out so many embattled coders with such *total* quality software!! What on earth will you do next?
There is some changelog for this module? New version came out, so it would be nice to see what’s new or whats changed in this release without using diff on the source code..
mlemonro, yep, there’s a changelog.txt file in the com/greensock/loading directory.
Loving loaderMax, works soo well and no hiccups. Would love to see an appendURLs method added. That way our array of files could be just the filename without the extension repeating (eg. .jpg). Guess it would only be useful for gallery’s but every bit of text saving counts
var aImages:Array = new Array(“image1″,”image2″); //etc
instead of
var aImages:Array = new Array(“image1.jpg”,”image2.jpg”); //etc
very good framework.
I must spend much time to learn it.
Thank you .
You are the man! Thanks a lot again!!!
well green this is!
Thank you so much for all of your classes. They are extremely well written and easy to use.
I can’t find one project where I won’t use your classes all over the place.
Excellent,good job ……I am enjoying your loader~~
Ridiculously good. Jack takes everything up a level with his tools, and yet somehow makes it simpler as well.
The control and depth of event management for loading is great, the documentation is excellent, the file size trumps all others, and now I get to have my loader, and my tweener living happily under one roof.
Leave your other bloat-loaders behind!
hi Jack.
If I pause the LoaderMAX(only one SelfLoader).
Whether the “main.swf” stop loading? or do nothing?
ason0, the only purpose of a SelfLoader is to report the loading progress of the main swf, so if you pause() a SelfLoader, it doesn’t actually stop the loading of the swf because…well…that would be impossible.
Well, this is definatly a ‘load’ off my mine…
Hi Jack,
Quick question (hope I’m not missing the answer or it’s obvious).
What if I want to reuse already-loaded bytes of an image? I could access the loader.content property, right? But… what if I want another loader object? If I try to load an image that was already loaded earlier, is LoaderMax smart enough to “recycle” the already-loaded bytes, or will it make another server call (even if it does use the cache)?
Thanks for your time.
Natán, sure, if you want to make a copy of an image that you loaded, you could do:
var image:Bitmap = new Bitmap(loader.rawContent.bitmapData);
As far as LoaderMax being “smart” enough to recycle, that’s a tricky question. It assumes that the “smart” thing to do would be to always recycle but I don’t think that’s the case. Imagine loading a swf, allowing it to play, and then wanting to create a duplicate swf that plays next to it and starts all over again. In that case, it wouldn’t be smart at all to just hand over that already loaded swf. It would be partially played and you can’t really duplicate a swf anyway (assets, state, variables, etc.). It would need to get loaded again as a separate instance. For images it might sound “smart” to reuse data, but again that may not be the case – what if your ImageLoader hits a php script that spits back a new image each time you make the request and noCache is set to true?
In general, I try to make things as “smart” as possible, but I don’t like making too many assumptions about what the developer wants to do because it can limit flexibility. I prefer to give them the tools to get what they need out of a clean API. If a loader is already loaded and you call load(), it will not waste resources forcing a reload (although you can do that with the flush parameter). It will automatically skip over failed, paused, and loaded loaders as it rips through its queue. That’s the “smart” part, but if you create a separate loader instance that has the same URL as a previous one, it doesn’t force it to use the previously loaded data. It respects the developer’s request to have a separate, distinct instance with fresh data.
is loadermax free or a part of club membership?
Yes, Girish, LoaderMax is completely free to use in almost all types of commercial and non-commercial sites/products although there is a very rare, particular type of usage that requires the special license that comes with corporate Club GreenSock memberships. See http://www.greensock.com/licensing/ for details. All of the LoaderMax files are in the free download on http://www.LoaderMax.com, so you don’t need to pay anything to get the files.
Good morning, Jack.
Is it possible to add dynamic cuePoints to the videoLoader? Like the “addASCuePoint()” method from the FLVPlayback Component. Thank you for the great work.
I’ve used and loved BulkLoader for many years now. Its extremely powerful. But one of things I wasn’t crazy about(in additon to the bloated file size) was the need to always daisy chain my loaders, first loading my config XML, grabing asset path information, and THEN actually preloading my assets.
With the new intelligent autoload feature of the XMLLoader class this is no longer necessary.
Fantastic work Jack!
Your wish is my command, Stefan. I just posted an update to VideoLoader (1.6) and it now has addASCuePoint() and removeASCuePoint() methods. Enjoy!
Jack! You are the best! Thank you so much!
Just amazing, i test it for 5 minutes.. i will never use anything else!
Do I need to buy this class for commercial project or is it free to use in any type of project?
Nitin, LoaderMax is completely free for MOST commercial projects. There is a very particular type of commercial usage that requires the special license that comes with corporate Club GreenSock memberships. See http://www.greensock.com/licensing/ for details.
Great Engine! Great job!
Just debugged my App because the SelfLoader didnt fire when used after the swf was already loaded. So thanks for your update on Oct 13 for that! Had this problem already in 2 projects, so it’s not a so unlikely phenomenon.
Thanks very very much for your great work, i’ll go ahead to be a really green socked club member!
Making my life easier, thanks!
How could I Know the LoaderMax is Loading now?
isnow, every loader (and LoaderMax queue) has a “progress” property that reaches 1 when it is finished loading. Each loader also has a “status” property that you can check.
Yo Jack, what if I want to download my SWF assets and after get this asset in my library? I can’t find the “e.target.content.loaderInfo.applicationDomain.getDefinition(“preloader_mushroom”) as Class”
If you have any idea, please tell me.
Marcelo, SWFLoader makes that very simple actually:
myLoader.getClass(“preloader_mushroom”);
See the getClass() method in the ASDocs for a full description.
Promising! Well done greensock!
Great engine, only one thing is still bugging me. The ContentDisplay Class. Basically, what if I’m loading a SWF or an Image and I dont want it to be placed in a ContentDisplay sprite?
I’ve already tried to modify the DisplayObjectLoader but I would like not to do that. Is is possible not to create the ContentDIsplay object?
Jakub, I originally built LoaderMax so without any ContentDisplay class, but it quickly became apparent that one would be necessary (well, extremely convenient at least). A lot of people requested it. ContentDisplay solves all sorts of problems, as described in the docs. But if you don’t want to use it, you are certainly welcome to reparent the rawContent (your subloaded swf in this case) to wherever you want and then dispose() the SWFLoader when you’re done.
Is there some reason you’d need to avoid a ContentDisplay ever even being created in the first place? It uses very little memory and I cannot imagine you’d EVER see even the slightest performance degradation.
Jack you are absolutely AMAZING. Thanks for great stuff and best luck
How to use .parse() with binary file/files?
For example, LoaderMax.parse( “test.zip” ) throws an error “LoaderMax could not parse (…)”
Sure, drunkcat, I just uploaded a new version that adds a BinaryDataLoader class. Just activate() that and then LoaderMax.parse() will associate zip files with BinaryDataLoader. In the new version of LoaderMax, you can also LoaderMax.registerFileType() to add other types, like .pdf or whatever.
This is amazing! I’ve used it on my two last projects. It works perfectly. I like the class activator and Vars chain the most
brilliant idea! I love my code being clean, so strongly typed props are exactly what I desired.
my images loaded with loadermax are blurry. can you tell me why this is happening?
LoaderMax will not affect the image itself at all, but if you defined a width and/or height, it will scale the image to that size. Whenever you scale an image in Flash, you risk having blurry pixels (like in any program) because if the resolution isn’t adequate, things get fuzzy. For example, if you load a 100×100 image and scale it to fit into a 500×500 area, the pixels get 5 times bigger and get blurred a bit (since smoothing is turned on by default). You can set smoothing:false if you want. And make sure your image has adequate resolution. Oh, and if you apply any 3D properties (like rotationX, rotationY, rotationZ, or z), Flash applies a matrix3D which tends to make things a bit blurry, but that has nothing to do with LoaderMax.
Hey Jack,
I came here to post a question and noticed your response above regarding the 3D properties. I’ve found this over at Flash and Math – http://www.flashandmath.com/flashcs4/blursol/index.html. If you just drop on image on the stage their solution works when trying a 3D rotation.
I’ve been playing around with different parameters of LoaderMax to try and achieve the same result, but I can’t seem to manage it. Would you know of any combination of parameter settings that might allow for this?
Matt, you’re welcome to listen for the INIT or COMPLETE event on the ImageLoader and then apply the custom scaleX/scaleY as that article recommended to help eliminate the 3D blur at z of 0, but I don’t think it would be appropriate to do that automatically inside ImageLoader because it could be confusing for developers. And most of the time when 3D properties are set, they’re not left at the default values of 0 anyway.
Perfect. I’m going to give that a whirl. I actually just came back to have a look at your ASDocs and saw that you had replied. I appreciate the response.
BTW – if I ever end up winning the lottery or somehow acquiring loads of cash I’m giving you a $1 million right off the top. Your work is invaluable. Can’t thank you enough.
This is a great website and a great help for designers and non-programmers like me. I hope this website won’t go offline the next 10 years…
Adobe should really built your classes into the CS packages. As3 is so damn convoluted sometimes.
Thanks for making the world easier!
Hi thanks for all these neat libs, lot of saved time !
thanks so much for your perfect work.
Thanks for these valuable stuff , you are FlashMasters .. love you
Hello, I just want to say thanks. You saved me from those bugs I`ve encountered all over again. I will start my next project and use all of your products, and thank you for having a great and “free” versions…thank you.
Hello,
LoaderMax is perfect, too!
But is there a maximum of images, LoaderMax can handle?
Between 1350 and 1373 the Loading stops…
Thanks for help,
Gite.
Gite, LoaderMax itself has no limit, no, but the Flash Player does. It depends on the system, memory, etc. I definitely wouldn’t recommend loading over
1000 images and having them all in memory at the same time, no. That’s pushing the Flash Player too far. Again, that’s not a limitation of LoaderMax – it’s just the Flash Player. You can preload all the images and unload() the ones you don’t need immediately so that they’re at least in the browser cache and can be loaded very quickly when you need them.
Hey guys,
I’ve used LoaderMax on a number of projects it’s amazing so first off thanks so much! Hopefully without sounding too greedy I’m wondering if you guys have any plans for a JS loading platform?
Again thanks so much!
John
Thanks for asking, John. We don’t have any immediate plans to create a JavaScript loading platform yet, but it may eventually happen. Right now what’s needed most in the industry is a solid animation platform and we’re very focused on filling that need. You’re not the first to ask about the JS loading platform, by the way, and we’re taking notice of what the community is asking for. It matters to us and helps shape what we pursue.
kudos on all these AS3 libraries, you have made my life as a developer soooooooo much easier.
Hello!
Thanks for all the libs! I use Tween[Max|Lite] and LoaderMax.
I use LoaderMax to load MP3 in my application. The server returning MP3 sets huge expiration time in HTTP headers to ensure that MP3 is cached by browser. But when I run the app and view its requests I see that there are still actual requests to server. And more than that, LoaderMax explicitly adds gsCacheBusterID query parameter (=timestamp) preventing browser cache to hit.
Do these requests download entire file? This might burn me few TB a day
Thanks.
Anton, the request with the gsCacheBusterID at the end is just a very quick URLStream load that only loads enough to figure out the total size of the file (typically as soon as a single small chunk is sent by the server, it tells LoaderMax what it needs and LoaderMax kills the connection immediately). This is necessary for LoaderMax to accurately report the progress of entire queues of files, but you can easily turn off the file size auditing feature if you prefer. See tips 8 through 10 here: http://www.greensock.com/loadermax-tips/#8
My question concerns loaderMax object with maxconnections set to 5. When running via Adobe Air 3.5 in iOS the loading of images is super fast. However today I ported my app to an Android tablet and it’s VERY slow (seems like maxconnections never gets above 1). Just curious if anyone had the same problem. Thanks
Marcum, each ecosystem imposes its own limitations on connections which LoaderMax cannot override. For example, some browsers may only allow a maximum of 3 simultaneous connections. Some may allow 5. Android may allow only 1. When you set a maxConnections value in LoaderMax, it’s just an upper limit – that doesn’t mean it will be able to hit that maximum.




















Download zip