0

我意识到以前有人问过这个问题,我已经尝试了所有大多数解决方案,但无济于事。在我的 Flash 文件中,我在 goGallery 框架中加载了一个外部 .swf,但现在当我转到另一个框架时,.swf 文件仍在后台。

下面是代码,如果您还可以告诉我在哪里放置新代码,那就太好了,因为我已经多次尝试将解决方案放入其中和周围。

stop();

function listenerFunction (Event):void{
}


function goHome (e:MouseEvent):void{
    gotoAndStop("Home");
}
home_btn.addEventListener(MouseEvent.CLICK, goHome);

function goAbout (e:MouseEvent):void{
    gotoAndStop("About");
}
about_btn.addEventListener(MouseEvent.CLICK, goAbout);

function goHistory (e:MouseEvent):void{
gotoAndStop("History");
}
history_btn.addEventListener(MouseEvent.CLICK, goHistory);

function goEducation (e:MouseEvent):void{
gotoAndStop("Education");
}
education_btn.addEventListener(MouseEvent.CLICK, goEducation);

function goInterests (e:MouseEvent):void{
gotoAndStop("Interests");
}
interests_btn.addEventListener(MouseEvent.CLICK, goInterests);

function goGoals (e:MouseEvent):void{
gotoAndStop("Goals");
}
goals_btn.addEventListener(MouseEvent.CLICK, goGoals);

function goPuzzle (e:MouseEvent):void{
gotoAndStop("Puzzle");
}
puzzle_btn.addEventListener(MouseEvent.CLICK, goPuzzle);

function goSound (e:MouseEvent):void{
gotoAndStop("Sound");
}
sound_btn.addEventListener(MouseEvent.CLICK, goSound);

function goGallery (e:MouseEvent):void{
gotoAndStop("Gallery");
var myLoader:Loader = new Loader();                    
var url:URLRequest = new URLRequest("gallery.swf"); 
myLoader.load(url);                                     
addChild(myLoader);

myLoader.x = 380;                                         
myLoader.y = 270;

myLoader.scaleX = 0.45; 
myLoader.scaleY = 0.45; 

}

gallery_btn.addEventListener(MouseEvent.CLICK, goGallery);
4

1 回答 1

0

myLoader当您不希望它出现在舞台上时,您需要保留对它的引用并删除它。

var galleryLoader:Loader = new Loader();

function goGallery (e:MouseEvent):void{
    gotoAndStop("Gallery");

    var url:URLRequest = new URLRequest("gallery.swf"); 
    galleryLoader.load(url);                                     
    addChild(galleryLoader);
}

在其他函数中删除 galleryLoader :

function goHome (e:MouseEvent):void{
    removeGallery();
    gotoAndStop("Home");
}

function removeGallery():void
{
    if(galleryLoader.parent)
       galleryLoader.parent.removeChild(galleryLoader);
}
于 2013-03-03T01:02:29.817 回答