2013-07-22 29 views
0

有一個代碼here in this tutorial to load external swf與AS2時: 的代碼如下:傳遞參數加載外部SWF AS2當按下對應按鈕

var swfLoader:MovieClipLoader = new MovieClipLoader(); 
var loadingListener:Object = new Object(); 

swfLoader.addListener(loadingListener); 

loadingBtn_mc.onRelease = function() 
{ 
    swfLoader.loadClip("slides.swf",container_mc); 
    this._visible = false; 
}; 

loadingListener.onLoadStart = function(container:MovieClip):Void 
{ 
    trace("The MovieClip " + container + " started loading"); 
    loadingProgress_mc._x = 126; 
    loadingProgress_mc._y = 135; 
}; 

loadingListener.onLoadProgress = function(container:MovieClip, bytLoaded:Number, bytTotal:Number):Void 
{ 
    var percentageLoaded:Number = (bytLoaded/bytTotal) * 100; 

    loadingProgress_mc.percentage_txt.text = String(Math.floor(percentageLoaded)); 

    trace("Loading progress = " + String(Math.floor(percentageLoaded))); 
}; 

loadingListener.onLoadComplete = function(container:MovieClip):Void 
{ 
    trace("The MovieClip " + container + " has completed loading"); 
    loadingProgress_mc._x = -200; 
}; 

loadingListener.onLoadInit = function(container:MovieClip):Void 
{ 
    trace("The MovieClip " + container + " has been initialized"); 
}; 

loadingListener.onLoadError = function(container:MovieClip, errorCode:String):Void 
{ 
    trace("Error loading the file. Error code = " + errorCode); 
}; 

要卸載SWF(一次加載)我加入:

unloadingBtn_mc.onRelease = function() 
{ 
    swfLoader.unloadClip(container_mc); 
    //this._visible = false; 
}; 

但如何將參數傳遞給「slides.swf」swfLoader.loadClip("slides.swf",container_mc);

Here is the source file

回答

1

我認爲你可以做這樣的事情......

swfLoader.loadClip("slides.swf?data1=12345&data2=67890",container_mc); 

,然後你應該能夠訪問它,像這樣(在slides.swf)...

var my_data1:String = _level0.data1; 
var my_data2:String = _level0.data2; 

雖然,自從我做了任何AS2以來,它已經有一段時間了:)

+0

我用過'_root.the_variable ='東西';'感謝喲ü – cMinor