0

这是我的幻灯片:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("main.xml");

myShowXML.onLoad = function() {
    _root.myWidth = myShowXML.firstChild.attributes.width;
    _root.myHeight = myShowXML.firstChild.attributes.height;
    _root.mySpeed = myShowXML.firstChild.attributes.speed;

    _root.myImages = myShowXML.firstChild.childNodes;
    _root.myImagesNo = myImages.length;


    createContainer();
    callImages();

};


function createContainer() {
    _root.createEmptyMovieClip("myContainer_mc",1);
    menu.swapDepths(_root.getNextHighestDepth());

    myContainer_mc.lineStyle(5,0x000000,100);
    myContainer_mc.lineTo(_root.myWidth,0);
    myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
    myContainer_mc.lineTo(0,_root.myHeight);
    myContainer_mc.lineTo(0,0);

    myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
    myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;

}



function callImages() {

    _root.myMCL = new MovieClipLoader();
    _root.myPreloader = new Object();
    _root.myMCL.addListener(_root.myPreloader);

    _root.myClips_array = [];

    _root.myPreloader.onLoadStart = function(target) {

        _root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
        _root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
        _root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
        _root.myText_txt.autoSize = "center";



    };

    _root.myPreloader.onLoadProgress = function(target) {
    _root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";

    };



    _root.myPreloader.onLoadComplete = function(target) {

        _root.myClips_array.push(target);
        target._alpha = 0;

        if (_root.myClips_array.length == _root.myImagesNo) {

            _root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
            _root.target_mc = -1;
            myClips_array.sort();
            moveSlide();
            myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);


        }

    };

    for (i=0; i<_root.myImagesNo; i++) {

        temp_url = _root.myImages[i].attributes.url;
        temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());

        _root.myMCL.loadClip(temp_url,temp_mc);
    }

}


function moveSlide() {

    current_mc = _root.myClips_array[_root.target_mc];
    new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);

    _root.target_mc++;

    if (_root.target_mc>=_root.myImagesNo) {
        _root.target_mc = 0;
    }

    _root.myText_txt.text = _root.myImages[target_mc].attributes.title;
    next_mc = _root.myClips_array[_root.target_mc];
    new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);

}

当我在上面的图层上放置按钮或影片剪辑时,它会切换到正确的场景,但幻灯片正在播放。当我点击一个按钮进入下一个场景时,我需要它卸载。这是我在按钮上尝试过的:

on(release){
clearInterval(myShowInt);
}
on(release){
gotoAndStop("community",1)
}
on(release){myContainer_mc.unloadMovie();}
4

1 回答 1

0

您可以在同一个on(release)函数中包含所有这些语句。确保你gotoAndStop();发生在其他所有事情之后。之后就什么都不会运行了...

on(release){
  clearInterval(myShowInt);
  myContainer_mc.unloadMovie();
  gotoAndStop("community",1)
  //this won't run
  trace("You won't read me...");
}
于 2013-06-25T20:20:40.963 回答