Skip to main content
Participant
May 7, 2016
Question

gotoAndPlay won't repeat

  • May 7, 2016
  • 1 reply
  • 350 views

Hi,

Actionscript3 in Flash CC

I am trying to make a timeline play to specific points using buttons and then go back to the start at the end of the timeline.

The timeline will play OK once, but on the last frame returns to frame 3 and won't go any further.

The code I have is this:

Frame 3:

stop();

Next.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_8);

function fl_ClickToGoToAndPlayFromFrame_8(event:MouseEvent):void

{

  gotoAndPlay(4);

}

This is repeated on frames 20, 22 and 24. Each gotoAndPlay is set to the stop frame+1 (21,23,25)

On frame 36 - gotoAndPlay(1); . When I hit the button on frame 36 the timeline returns to frame 3.

Each time I hit the button the timeline flashes to frame 1, then back to 3 and will go no further.

I am not getting any compiler errors.

And help will be greatly appreciated. Thank you.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 7, 2016

you're probably losing your Next reference when you go to frame 1.  this can occur if Next fails to exist at some point and especially if Next is timeline-tweened.

Participant
May 7, 2016

Hi kglad

thanks for your post. I am new to this (you may have guessed).

Next is the instance name of my button. I have used this same instance on all by action keyframes. should I use a different instance name for each keyframe?

Thanks.

kglad
Community Expert
Community Expert
May 7, 2016

as long as your Next button is only on one keyframe, you'll have no problem.

if it's on more than one, you may have a problem.  it can be hard to track the problem after it occurs, but if you put an object (like Next) on a keyframe and assign its instance name (in the properties panel) and then add other keyframes later in the timeline, you'll have no problem.

if you do anything else, you may have a problem.

at this stage, the easiest fix is to add Next to frame 1 (always a keyframe) and no where else in your timeline.  test your code.  everything should work though Next may appear when you don't want it to appear and it may not appear where you want it.  don't worry about that right now.  it's easy to fix that once you get it working.