I’ve been using the following code to load swfs with a simple bar preloader. However, I’ve now got a bunch of AS2 swfs to add loaders to and this code wont work.
Is there either:
a) a way to convert this code to as2?
or
b) a workaround that will allow me to load the as2 files into the container with the existing code?
Any help greatly appreciated!
(Here’s the code)
var myMovie:Sprite;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop, false, 0, true);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done, false, 0, true);
l.load(new URLRequest("movie.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = "Loading " + Math.ceil(perc*100).toString()+"%";
bar_mc.scaleX = perc;
}
function done(e:Event):void
{
removeChild(percent);
percent = null;
myMovie = Sprite(l.content);
addChild(myMovie);
l.contentLoaderInfo.removeEventListener( ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.removeEventListener(Event.COMPLETE, done);
l = null;
}
The reason I cant use a simple AS2 loader is that I need to make sure the whole swf has loaded, including library items.