加载新的swf时无法卸载以前的swf

时间:2013-05-04 23:08:54

标签: flash actionscript

我在adobe flash中创建了一个主导航页面,其中有3个按钮。我已经使用这段代码按照按下的按钮调用一些外部swf。问题是,当我按下按钮加载一个swf我想要卸载前一个。我怎么能这样做我已经尝试了一切

var myLoader:Loader = new Loader();        
var myLoaderMain:URLRequest = new URLRequest("main1.swf");
var myLoaderQuiz:URLRequest = new URLRequest("quiz.swf");
var myLoaderAnimation:URLRequest = new URLRequest("athens_animation.swf");
var myLoaderVideo:URLRequest = new URLRequest("videogallery.swf");


videogallerybtn.addEventListener(MouseEvent.CLICK, videoFunc);

function videoFunc(curEvt:MouseEvent) {
myLoader.load(myLoaderVideo);
addChild(myLoader); 
 }

 Quizbtn.addEventListener(MouseEvent.CLICK, quizFunc);
 function quizFunc(curEvt:MouseEvent) {
myLoader.load(myLoaderQuiz);
addChild(myLoader);

 }

 Animationbtn.addEventListener(MouseEvent.CLICK, AnimationFunc);

 function AnimationFunc(curEvt:MouseEvent) {
myLoader.load(myLoaderAnimation);
addChild(myLoader);
 }

1 个答案:

答案 0 :(得分:0)

每个按钮都有两个事件监听器,第一个用于卸载加载器的Mouse_Down和用于加载加载器的MOUSE_UP。

    videogallerybtn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
    videogallerybtn.addEventListener(MouseEvent.MOUSE_UP, MouseUP);

     function MouseDown(curEvt:MouseEvent) {
     trace("mouseDown so unload, remove");
     }

     function MouseUP(curEvt:MouseEvent) {
     trace("mouseUP so load something and add it");
     }

希望你明白这个原则。