Welcome to WebmasterWorld Guest from 54.144.124.152

Forum Moderators: open

Message Too Old, No Replies

gotoAndPlay(5) doesn't refresh clip in frame 5

     

Joey33

4:24 pm on Jul 22, 2007 (gmt 0)

10+ Year Member



Hello,

I assume the problem is trivial but I'm learning so please excuse if level of the question... :)

I have a very simple situation:

two layers and 10 frames in all

Layer1 contains a button that when released triggers the following action:

gotoAndPlay(5);

the button is present in all 10 frames.

Layer2 has a movie clip in frame 5 that continues up to frame 10 (the end of the whole flash movie).

The problem is that when I reach frame 10 and press the button, the mc from frame 5 doesn't play again. I don't get it why. It is in the state it finished playing. Logically thinking it should start playing AGAIN from the start if I move the playhead to the frame on the main timeline where it is nested.

From experiments, I figured out that when the mc lasts up to frame 9 of the main timeline and the button is pressed in frame 10 (when the clip is not present on the stage anymore) the mc DOES play again.

The same is if the button goes not to frame 5 but 4 (where the mc is NOT YET present on the timeline).

Can you give me any clue?

Regards,
Joey33

ps. one more question is bothering me but maybe I'll describe it in a new post.

owika

5:11 pm on Jul 22, 2007 (gmt 0)

5+ Year Member



The mc needs to re-init if it's initiated on stage. You probably need to tell the mc gotoAndPlay(1) from the button-click, or you could just go gotoAndPlay(4) on the main timeline every time.

Joey33

10:32 pm on Jul 22, 2007 (gmt 0)

10+ Year Member



Yeah, I've already tried with telling the mc to play from the beginning and it works. But I'm thinking about a potential situation where I may have 10 clips one day. It would be quite a deal to tell e a c h of them to play from the start.

I just thought if there is another way.

Thanks for the reply and making me more confident that my way of thinking is going right direction:)

Rgs,
Joey33

owika

1:31 am on Jul 23, 2007 (gmt 0)

5+ Year Member



Well, the way we do this in Flash is by using eventListeners. By adding an eventListener to a movieclip, button, or any object, you can call a spesific function every time that event fires.

Look in the help files for samplecode. It's handled a little bit different in AS2 as from AS3, but it's kind of the same concept.

Joey33

1:51 pm on Jul 23, 2007 (gmt 0)

10+ Year Member



many thanks for the clue!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month