Category Archives: ActionScript

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:

// 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, onLoadComplete);
// add the image to the display

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

ActionScript Tutorial

I’ve been published!

Well, kind of.

Last weekend I wrote a tutorial on an AS2 sliding tile puzzle game I wrote a little while ago. It was my first attempt at writing coherent instructions for others to follow, so I was very pleased when it was accepted by the wonderful folks at</>. Thanks to Chris et al!

For anyone who isn’t familiar, DIC is a large community of programmers and web developers who are very helpful and knowledgeable on a huge range of technologies.

Here’s the direct link to the tutorial: