Loading an external movie clip in AS3

You can’t just use the loadMovie function, oh no! But this works perfectly:

import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

function startLoad()
{
  var mLoader:Loader = new Loader();
  var mRequest:URLRequest = new URLRequest(“MouseActions.swfâ€);
  mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
  mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
  mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event)
{
        addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
  var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
  trace(percent);
}
startLoad()

source:
http://www.iheartactionscript.com/loading-an-external-swf-in-as3/

Tech Reference:

Leave a Reply

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

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑