Category Archives: Flash

ActionScript Flash

Loader vs URLLoader

Today I tried to load an image, and I failed.  I failed because I was trying to use the URLLoader class.  As I discovered this won’t work, because although it will perform a load and happily dispatch a complete event, it doesn’t have the facility to display anything.

What you need for displaying is the Loader class, or more specifically it’s content property, which is a DisplayObject.  Like so:

[as3]
// create new Loader object
var myLoader = new Loader();
// set up a listener
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
// trigger the load
myLoader.load(new URLRequest("my_image.gif"));
// load complete handler
function onLoadComplete(evt:Event):void
{
// clean up the listener
evt.target.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
// add the image to the display
addChild(evt.target.content);
}
[/as3]

So basically the difference is this: Loader for display objects, URLLoader for data connections.

Flash

Auto-Save for Flash

My CS4 just crashed.  Again.  Although I try to be good about saving, sometimes I get focused on what I’m doing, and it’s always at these times when Flash decides that clicking that last frame was in some way offensive.  Much swearing ensues and a short break is taken, then I begin that complex string of animations again.

This time though I thought to employ google, and turned up a neat little extension on flashguru: Flash Auto-Save.

Pay no attention to the comment about it not working on CS4, I’ve installed it and it works fine.  The only thing to be aware of is that it needs to be visible at all times, and hiding it in a panel group will stop it working.

I hope this saves more people a bit of fury.