0

本教程这里有一段代码用as2加载外部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;
};

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

这是源文件

4

1 回答 1

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 以来已经有一段时间了 :)

于 2013-07-23T03:29:01.490 回答