按下相应按钮时,在加载外部swf as2时传递参数

时间:2013-07-22 20:02:17

标签: flash actionscript load actionscript-2

有一个带有as2的代码here in this tutorial to load external swf: 代码如下:

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;
};

但是如何将参数传递给swfLoader.loadClip("slides.swf",container_mc);中的“slides.swf”?

Here is the source file

1 个答案:

答案 0 :(得分: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以来已经有一段时间了:)