如何更改movieclip as3

时间:2014-11-12 11:26:34

标签: actionscript-3 flash movieclip

我想在1帧上更改2个动画片段,第一个动画片段用于启动应用程序时的介绍,第二个动画片段是第一个继续。 在这里我的代码:

var sunR1:classSunRays1; //movieclip export
var sunR2:classSunRays2; //movieclip export   

function intro():void{

            sunR1 = new clsSunRays1();
            sunR1.x = mapW/2;
            sunR1.y = mapH/2;
            sunR1.width += 200;
            sunR1.height += 200;
            stage.addChild(sunR1);
            if (sunR1.currentFrame == sunR1.totalFrames){
                stage.removeChild(sunR1);
                sunR2 = new clsSunRays2();
                sunR2.x = mapW/2;
                sunR2.y = mapH/2;
                sunR1.width += 200;
                sunR1.height += 200;
                stage.addChild(sunR2);
            }
        }

1 个答案:

答案 0 :(得分:0)

您可以尝试以下内容:

function intro():void
{
   sunR1 = new classSunRays1();
   sunR1.stop();
   sunR1.x = mapW/2;
   sunR1.y = mapH/2;
   sunR1.width += 200;
   sunR1.height += 200;
   stage.addChild(sunR1);
   // adding a function to be called in the last frame (when you will apply your logic)
   sunR1.addFrameScript(sunR1.totalFrames -1, changeMovieClip);
   sunR1.play();
}

function changeMovieClip():void
{
    sunR1.stop();
    stage.removeChild(sunR1);
    sunR2 = new classSunRays2();
    sunR2.stop();
    sunR2.x = mapW/2;
    sunR2.y = mapH/2;
    sunR2.width += 200;
    sunR2.height += 200;
    stage.addChild(sunR2);
    sunR2.play();
}