actionscript 3外部swf加载在关闭按钮上方

时间:2013-06-24 09:43:00

标签: actionscript-3 flash swfloader

我是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();
}

我正在尝试通过单击关闭按钮卸载swfs,但问题是当swf加载时我再也看不到关闭btn了,我试图使用交换深度但是没有工作。

如果有人可以帮助我,我真的很感激!

由于

1 个答案:

答案 0 :(得分:0)

试试这个:

替换

addChild(loader);

addChildAt(loader,0);