我Loader::load()
成功地使用将 swfs 加载到我的主 swf 中,然后我将它们添加为 Sprite 的子项。当发生其他事件时,我想根据需要删除 swf。我看过unload()
并removeChildAt()
没有成功。
我只添加了addChild()
调用来尝试固定加载的实例,以便我可以删除它。加载工作正常,没有addChild();
我也尝试过发布到播放器 v.10 并使用myLoader.unloadAndStop()
; 但这也没有效果;
以下演示代码显示了我的问题。我看到添加了一个孩子并删除了一个孩子,但 intro.swf 仍在播放。
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
var myLoader:Loader = new Loader();
var holderMC:Sprite = new Sprite();
var myRequest:URLRequest = new URLRequest('intro.swf');
myLoader.load(myRequest);
holderMC.addChild(myLoader);
trace("initial:"+holderMC.numChildren); // traces initial:1
while(holderMC.numChildren > 0) {
holderMC.removeChildAt(0);
trace("now there are:"+holderMC.numChildren); // traces now there are :0
}
myLoader.unload();
//编辑- 也尝试过:
myLoader.unloadAndStop();
myLoader = null;
有什么想法吗?