How to load External SWF Via Flash ActionScript?

To load an external SWF via the Flash ActionScript, you can use the
movieclip loader (Flash MX 2004 & Later :: example code below)

// set up loader, an instance of MovieClipLoader, and use the main
timeline ("this")
// to listen to and respond to its broadcast events
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);

// define what should happen when the swf is completely loaded
// use _mc to refer to the loaded swf
function onLoadInit(_mc:MovieClip) {
// code here
};

// define what should happen while the swf is loading
// use _mc to refer to the swf and loaded & total to refer to the
number of bytes
// currently loaded and to be loaded, respectively
function onLoadProgress(_mc:MovieClip, loaded:Number, total:Number) {
// code here
};

// start loading specified swf into blank movieclip holder_mc on stage
loader.loadClip("somefile.swf", holder_mc);

No comments:

Post a Comment