LoaderMax – Smart AS3 Loading
LoaderMax is a new AS3 loading system that 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 bunch 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:
- Integration of loaders inside subloaded swfs – with most other systems, if you subload a swf, the loader will only concern itself with the swf file’s bytes but what if that swf must subload other content like XML, images, and/or other swf files before it should be considered fully loaded? LoaderMax can elegantly handle the sub-subloads as deep as they go. You can link any loader and/or LoaderMax with a swf’s root (using the requireWithRoot vars property) so that when you subload it into another Flash application, the parent SWFLoader automatically factors the nested loaders into its overall loading progress! It won’t dispatch its COMPLETE event until they have finished as well.
- Automatic parsing of LoaderMax-related nodes inside XML – The XMLLoader class automatically looks for LoaderMax-related nodes like <LoaderMax>, <ImageLoader>, <SWFLoader>, <XMLLoader>, <VideoLoader>, <DataLoader>, <CSSLoader>, <MP3Loader>, etc. in XML files that it loads, and if any are found it will create the necessary instances and then begin loading the ones that had a load=”true” attribute, automatically integrating their progress into the XMLLoader’s overall progress and it won’t dispatch a COMPLETE event until the XML-driven loaders have finished as well. See XMLLoader’s ASDocs for details.
- 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).
- Define an alternateURL for any loader – If the original url fails to load, it will automatically switch to the alternateURL and try again.
- A common set of properties and methods among all loaders – All loader types (XMLLoader, SWFLoader, ImageLoader, MP3Loader, CSSLoader, VideoLoader, LoaderMax, etc.) share common properties like: content, name, status, loadTime, paused, bytesLoaded, bytesTotal, and progress as well as methods like: load(), pause(), resume(), prioritize(), unload(), cancel(), auditSize() and dispose() delivering a touch of polymorphism sweetness.
- 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 them as a whole and get the overall progress, bytesLoaded, and/or bytesTotal. You can put a queue into another – group and nest them however you want. This makes complex queues simple. Need to know when the first 3 loaders have finished loading inside a 10-loader queue? Just put those 3 into their own LoaderMax that has an onComplete and nest that LoaderMax inside your main LoaderMax queue.
- 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”.
- Conveniences like auto smoothing of images, centering their registration point, noCache, setting initial x, y, scaleX, scaleY, rotation, alpha, and blendMode properties, optional autoPlay for mp3s, swfs, and videos, and more.
- Works around common Flash hassles/bugs – LoaderMax implements workarounds for things like garbage collection headaches with subloaded swfs, images, and NetStreams as well as other problems like the recently discovered issues with subloading swfs that use TLF.
- 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.
- A single loader can belong to multiple LoaderMax instances
- Accurate progress reporting – For maximum performance, set an estimatedBytes for each loader or allow LoaderMax’s auditSize feature to automatically preload just enough of each child loader’s content to determine its bytesTotal, making progress reporting on large queues very accurate.
- prioritize() a loader anytime – Kick an object to the top of all LoaderMax queues to which it belongs, immediately supplanting the top spot in each one.
- A robust event system – events bubble up through LoaderMax hierarchies and carry a consistent target for easy identification
- Set up multiple event listeners in one line – Add listeners like onComplete, onProgress, onError, etc. via the constructor like new LoaderMax({name:”mainQueue”, onComplete:completeHandler, onProgress:progressHandler, onError:errorHandler});
- maxConnections – Set the maximum number of simultaneous connections for each LoaderMax instance (default is 2). This can speed up overall loading times.
- pause()/resume() – no queue loading solution would be complete without the ability to pause()/resume() anytime.
- Flex friendly – Simply change the LoaderMax.contentDisplayClass to FlexContentDisplay and then ImageLoaders, SWFLoaders, and VideoLoaders will return content wrapped in a UIComponent.
AS3 Scale9 Bitmap
AS3 Scale9 Bitmap is class that lets you create scale9 sprites with bitmap data fill – originally this was not possible in Flash 9. The class creates a “fake” scale 9 sprite containing 9 shapes that scale according to user-defined scaling matrix. Extremely useful for quick user interface work (creating buttons, scalable UI elements etc.)
http://www.uza.lt/codex/as3-scale9-bitmap/
Scale9Grid Helper
I have been working on a project with lots of round cornered cubes. They all have to scale so i apply scale9Grids. Making a new Scale9Grid everytime and not seeing the grid frustrated me enough to come up with a solution to all my problems.
Thus the birth of the Scale9Helper class.
This class can make a Scale9Grid for you and it can also visualize you grid. SO you can actually see how the Scale9Grid is layed out.
http://blog.rackdoll.nl/?p=272
Cookie Util
From the site:
I have written a small utility class which I think some of you really would like to use. It is a small class that makes it possible to set Cookies via Actionscript without adding anything to the HTML Wrapper, all the code will be injected at runtime.
http://myflex.wordpress.com/2008/11/12/actionscript-cookie-util/”.
ExtendedTimer
From the site:
so let’s say you start a Timer with 1000 milliseconds delay and stop it after 600 milliseconds. if you call Timer.start() again, it starts with a new delay of 1000 milliseconds again. there is no built-in possibility to resume the timer for the remaining 400 milliseconds. i thought “nothing easier than that, just call Timer.pause()”. but there was no such method, so i decided to write my own ExtendedTimer class and add the pause functionality. now i like to share it with you…
http://blog.fjakobs.com/archives/101.
Object Pool
From the site:
Two of the slow operations in the flash player are object creation and garbage collection. If we pool objects – save objects when they’re no longer needed and reuse them later when another object of the same type is required – then object creation is kept to a minimum and garbage collection is reduced to zero.
ttp://www.bigroom.co.uk/blog/object-pool-class.
Bitmap Mosaic
From the site:
This class will allow you to create a pixellated copy of any display object.
It allows for varying pixel sizes and caching of rendered pixels so you don’t have to redraw them every time.
http://juliankussman.com/blog/2008/10/01/as3-bitmap-mosaic-class/.
ObjectSerializer
From the site:
If anyone ever has the need to pass complex objects through a url, LocalConnection, or whatever.. I wrote an ObjectSerializer that you might want to use.
http://techish.jeremymooer.com/2008/09/random-utility-class-objectserializer.html
Survey Lite Library
From the site:
Last month a client of mine who has very strick business model for marketing research called us to create a entire library for them to build survery quick as possible. It’s took me dozens days to develop the library and after I finish up I realize that I could create a new one more light and tiny version of that I did…SurLL, intend to get more easy to create UI survery in Flex with no extra work.
http://www.igorcosta.org/?p=154
MarchingAntsSelect
From the site:
This is a simple ActionScript 3 implementation of the class marching ants selection marquee you find in applications such as Photoshop.
The class is based off this ActionScript 2 example here; http://www.nocircleno.com/experiments/selection_ants_proof/index.html, but adds in many more methods and is entirely self contained. Drawing the bitmaps for the marquee internally in the class.
Features
Either Fixed or user drawn marquee
Draggable or static fixed marque
Programatically changeable marquee colours
Programatically changeable marquee line thickness
Does not rely on library assets for marquee