我是 as3 新手,我通过单击不同的按钮加载外部 swf 文件,但只使用一个可以正常工作的功能。
//main
mainCloseBtn.visible = false;
movieloaderbg.visible = false;
M1L1Btn1.visible = false;
//Load activities
var Xpos:Number = 0;
var Ypos:Number = 0;
var swf:MovieClip;
var loader:Loader = new Loader();
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
// Btns Universal function
function btnClick(event:MouseEvent):void {
removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("activities/" + event.target.name + ".swf");
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChildAt(loader,3);
mainCloseBtn.visible = true;
}
// Btn listeners
wrong.addEventListener(MouseEvent.CLICK, btnClick);
// Back btn
backBtn.addEventListener(MouseEvent.CLICK, backBtnClick);
function backBtnClick(evt:MouseEvent):void {
gotoAndStop("M1Lessons");
}
// Video Button
videoBtn.addEventListener(MouseEvent.CLICK, videoBtnClick);
function videoBtnClick(evt:MouseEvent):void {
mainCloseBtn.visible = true;
M1L1Btn1.visible = true;
M1L1Btn1.gotoAndPlay(2);
}
//Main Close Button
mainCloseBtn.addEventListener(MouseEvent.CLICK, mainCloseBtnClick);
function mainCloseBtnClick(evt:MouseEvent):void {
mainCloseBtn.visible = false;
loader.unload();
M1L1Btn1.visible = false;
M1L1Btn1.stop();
}
我正在尝试通过单击关闭按钮来卸载 swf,但问题是当加载 swf 时我无法再看到关闭 btn,我尝试使用交换深度但无法正常工作。
如果有人可以帮助我,我将不胜感激!
谢谢