Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何更改movieclip as3_Actionscript 3_Flash_Movieclip - Fatal编程技术网

Actionscript 3 如何更改movieclip as3

Actionscript 3 如何更改movieclip as3,actionscript-3,flash,movieclip,Actionscript 3,Flash,Movieclip,我想更改1帧上的2个movieclip,当应用程序启动时,第一个movieclip用于简介,第二个movieclip是第一个的继续。 这是我的代码: var sunR1:classSunRays1; //movieclip export var sunR2:classSunRays2; //movieclip export function intro():void{ sunR1 = new clsSunRays1(); sunR1.x

我想更改1帧上的2个movieclip,当应用程序启动时,第一个movieclip用于简介,第二个movieclip是第一个的继续。 这是我的代码:

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

您可以尝试以下方法:

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();
}