A simple external file loader for ActionScript 3

March 8th, 2010

One of the big mistakes that beginners make when they’re making their first Flash projects is importing all the graphics and making movieclips with tons of frames, resulting in a Flash file that is huge. The bigger the .swf, the longer it will take to load. The simplest way to fix this is to load larger files externally. Loading files is pretty easy in ActionScript 3 so I’m not going to show you how, I’ve just made this ExternalLoader class that does the job and I use it a lot at work. And to use it is the same as loading anything else in AS3. Just download the zip file and put the class wherever you save your custom classes.

Download the .zip file

To use it, you just need three lines of code:

1
2
3
4
5
import com.atomicrobot.ExternalLoader;

var image:ExternalLoader = new ExternalLoader("externalfile.blah");

addChild(image);

And you’re good to go. You can use it as many times as you need in your project and it will help keep down your file size.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>