开发者

Need help with flash if current frame

开发者 https://www.devze.com 2023-03-31 09:18 出处:网络
Hi I am not familiar with flash action script that much much. The part I need help with is I have three movie clips and one button the movie clips are called ex_1 ex_2 ex_3.

Hi I am not familiar with flash action script that much much. The part I need help with is I have three movie clips and one button the movie clips are called ex_1 ex_2 ex_3.

I want to firstly check if the movie clips are on frame 15 if they are I want to perform gotoAndPlay frame number 16 if any of the 3 are not on a spe开发者_如何学Ccific frame I want to perform gotoAndPlay for the movie clips that are on frame 15.

I hope I made some sense and any help is appreciated thanks in advance!


I don't understand the whole question, but can help you part by part.

Checking the frame number and moving can be done like this:

ex_1.addEventListener(Event.ENTER_FRAME, onEnterFrame);

private function onEnterFrame(e:Event):void
{
   if (ex_1.currentFrame == 15)
   {
      ex_1.gotoAndPlay(16);
   }
}

The other part is not clear, but you could iterate trough the movie clips and check if any is not on the specific frame and then setting the desired frame with gotoAndPlay.


Similar to Mentoliptus's post, but you should only use one ENTER_Frame listener, and that should be attached to the parent of the three MovieClips:

this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(event:Event):void
{
    if(ex_1.currentFrame == 15) { 
        ex_1.gotoAndPlay(16);
    } else {
        ex_1.play();
    }
    if(ex_2.currentFrame == 15) { 
        ex_2.gotoAndPlay(16);
    } else {
        ex_2.play();
    }
    if(ex_3.currentFrame == 15) { 
        ex_3.gotoAndPlay(16);
    } else {
        ex_3.play();
    }
}


this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(event:Event):void
{
    if(ex_1.currentFrame == 15 && ex_2.currentFrame == 15 && ex_3.currentFrame == 15) { 
        ex_1.gotoAndPlay(16);
    } else {
        ex_1.play();
    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消