2013-03-02 72 views
0

我意识到这个问题之前已经被询问过了,并且我已经尝试了所有的大部分解决方案并且无济于事。在我的flash文件中,我在goGallery框架中加载了一个外部.swf文件,但现在当我转到另一个框架时,.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); 

回答

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); 
} 
+0

谢谢!这工作完美! – Mike 2013-03-03 15:07:06