|
Lavinia Iancu [Extend Studio]
post date:
2008-08-29 10:27:28
|
Hello,
Here is the code which you need to save into an AS file named MCLoader:
class MCLoader extends MovieClip {
private var button : MovieClip;
private var thingsToLoad : Array;
private var main : MovieClip;
public function MCLoader(main_ : MovieClip, button_ : MovieClip, thingsToLoad_ : Array) {
this.button = button_;
this.thingsToLoad = thingsToLoad_;
this.main = main_;
var total = this.thingsToLoad.length;
this.button.ref = this;
this.button.onPress = function() : Void {
this.ref.loadItem(0, total);
}
}
public function loadItem(index : Number, total : Number) {
var item = this.thingsToLoad[index].split("...");
var name_ : String = item[0];
var target_ : MovieClip = this.main.createEmptyMovieClip("container", this.getNextHighestDepth());
var url_ : String = item[1];
var objLoader : Object = new Object();
objLoader.ref = this;
objLoader.onLoadInit = function(mc_ : MovieClip) : Void {
trace("MOVIE " + index + " HAVE BEEN LOADED!");
if(index < total - 1) {
index++;
this.ref.loadItem(index, total);
} else {
trace("LOADING PROCCESS COMPLETED!");
}
}
objLoader.onLoadError = function(mc_ : MovieClip, error_ : String, http_ : Number) : Void {
trace("CANNOT LOAD " + url_ + "!");
if(index < total - 1) {
index++;
this.ref.loadItem(index, total);
} else {
trace("LOADING PROCCESS COMPLETED!");
}
}
var mcLoader : MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(objLoader);
mcLoader.loadClip(url_, target_);
var loadListener:Object = new Object();
}
}
In a fla file, you need to insert this code into the timeline, and create a movieclip:
import MCLoader;
var ddd : Array = new Array();
ddd[0] = "first...1.swf";
ddd[1] = "second...2.swf";
var container : MovieClip = this.createEmptyMovieClip("mcloader", this.getNextHighestDepth());
var aaa : MovieClip = new MCLoader(container, this.button_mc, ddd);
Please feel free to contact us if you have any questions and we will assist you.
Kind regards,
Lavinia Iancu
|
|