If you seem to have everything set up correctly with a Loader class instance, but there's just nothing happening... You probably made the same mistake I've made a number of times when coding a little too quickly: attaching the event listeners to the Loader object itself, rather than your loader's property: .contentLoaderInfo - where all the information and events on loading status actually occur.
For example...
The Common Wrong Way:
var myLoader:Loader = new Loader();
myLoader.addEventListener(Event.COMPLETE, onLoadComplete);
myLoader.load( new URLRequest("externalExampleImage.jpg") );
...and then you wonder why the event never fires, there is no error, and you know your image is there... doht!
The Right Way:
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
myLoader.load( new URLRequest("externalExampleImage.jpg") );
... works every time!
Adobe Documentation Reference:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html
Posted on
Monday, November 9, 2009
by Sean P
filed under