Thursday, 3 January 2013

Load multiple Swfs with LoaderMax

Loading multiple Swf files into one swf file and be accomplish with LoaderMax. I have previously used SwfLoader to load a single swf file, but have not used it for loading multiple files. LoaderMax simplifies the loading process by managing the loading of each file. In my code below LoaderMax loads an array of swf files and handles the loading automatically.

//Import necessary classes
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

//Activate the necessary load
LoaderMax.activate([SWFLoader]);
 
//Create a new instance of LoaderMax and parse the array of swf 
var urls:Array = ['example1.swf','example2.swf', 'example3.swf' ];
var loader:LoaderMax = LoaderMax.parse(urls, {name:"loader", onComplete:completeHandler}) as LoaderMax;
loader.load();
 
function completeHandler(event:LoaderEvent):void {

}

The SwfLoader can also be used to load multiple swf. My code is shown below.
//Import necessary classes
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

//Create a new instance of LoaderMax and append SWFloaders 
var loader:LoaderMax = new LoaderMax({onComplete:completeHandler});
loader.append(new SWFLoader("example1.swf",{name:'loader1'} ) );
loader.append(new SWFLoader("example2.swf",{name:'loader2'} ) );
loader.append(new SWFLoader("example3.swf",{name:'loader3'} ) );
loader.load();

function completeHandler(e:LoaderEvent):void {
 
}

0 comments:

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP