Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Pure AS3 self-preloader

Explorer ,
Feb 05, 2013 Feb 05, 2013

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?

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 06, 2013 Feb 06, 2013

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2013 Feb 06, 2013

By self-preloader, I mean 1 file. What you posted requires 2, right? The loader SWF and then the actual SWF.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 06, 2013 Feb 06, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2013 Feb 06, 2013
LATEST

Doesn't work because I have embedded assets.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines