Copy link to clipboard
Copied
My project originally had everything on the timeline, but I have since moved all the code to the document class, but some of my assets are still in the library and some of them are embedded. I'm trying to make a self-preloader that doesn't use any external files, but I can't seem to find a good tutorial that doesn't involve using the timeline. Can anyone point me to a pure AS3 self-preloader tutorial or tell me where I'm supposed to put everything?
Copy link to clipboard
Copied
If you mean by "self-preloader" a pure Standalone as3 preloader:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
//this line has to be adapted to the name of your document class
l.load(new URLRequest("main.swf"));
function loop(e:ProgressEvent):void
{
var kBytesLoaded:int = Math.round(e.bytesLoaded/1024);
var kBytesTotal:int = Math.round(e.bytesTotal/1024);
var perc:Number = kBytesLoaded / kBytesTotal;
trace("PERCENT:"+perc);
}
function done(e:Event):void
{
//this line for the stuff you might need to visually communicate the loading process and want to remove when loading is done
removeChildAt(0);
addChild(l);
}
Copy link to clipboard
Copied
By self-preloader, I mean 1 file. What you posted requires 2, right? The loader SWF and then the actual SWF.
Copy link to clipboard
Copied
Here is a method described how to do it in AS3 the AS2 way.
I find it a little absurd, to be honest, to go to such lengths, only to avoid a second file, but to each his own
Copy link to clipboard
Copied
Doesn't work because I have embedded assets.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now