A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: preload actionscript using "getBytes" problems

Threaded View

  1. #16
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Using the AssetManager, you can do it like this.

    frame1 :
    Code:
    // import the required classes
    import km.core.*;
    
    // add a loader object to the stage
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    
    // initiate the load
    AssetManager.loadBinaries('swf1.swf','swf2.swf');
    frame2 : empty frame with label 'loopFrame'

    frame3 :
    Code:
    if (AssetManager.getQueueLength() > 0) gotoAndPlay('loopFrame');
    frame4 :
    Code:
    myLoader.loadBytes(AssetManager.getAsset('swf1.swf', false));
    
    stop();
    frame4 is the start of your normal movie.
    I put a stop action there since this test code contains no further frames. Otherwise you shouldn't put that there of course.
    The other line of code loads the swf from a byte array. It's a bit like loading it externally but a lot faster.
    The loader object can be reused so in another frame you can use a different line of code to load new content into the same loader object.
    Like mentioned in my previous post, you can also choose to add the loader object to mc1 instead of to the stage directly.

    If you wish, you can add a dynamic textfield to frame2 and frame3 and add a line of code to frame2 to set the text to the name of the item that is currently being loaded.
    AssetManager.getQueueCurrent();
    returns a string with the name of that item.
    Last edited by w.brants; 03-21-2012 at 02:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center