Skip to main content
Known Participant
May 15, 2013
Answered

New to AS3, code snippet not working

  • May 15, 2013
  • 1 reply
  • 1002 views

Hello.  I'm new to AS3.  I'm trying to move onto AS3 from AS2 so that I can make a video gallery app.

I've been using the code snippets in Flash, and the buttons work in a way, but it keeps playing the same movie over and over again, which is the first movie.  Can anyone help me?  I want people to click on a button and have it play a different video associated with that video.  In reality, though, clicking on that button just takes the user to a different frame that has that video on it.  Here's the script:

/* Stop at This Frame
The Flash timeline will stop/pause at the frame where you insert this code.
Can also be used to stop/pause the timeline of movieclips.
*/

stop();

/* Click to Go to Frame and Play
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.
Can be used on the main timeline or on movie clip timelines.

Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
*/

PipeStr_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);

function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
    gotoAndPlay(1);
}

/* Click to Go to Frame and Play
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.
Can be used on the main timeline or on movie clip timelines.

Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
*/

SealInts_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
{
    gotoAndPlay(7);
}

This topic has been closed for replies.
Correct answer Ned Murphy

Have you placed a stop() somewhere at or after frame 7 so that the timeline is not looping back to frame 1?

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
May 15, 2013

Have you placed a stop() somewhere at or after frame 7 so that the timeline is not looping back to frame 1?

CuwenAuthor
Known Participant
May 15, 2013

Thank you so much!!!  I went ahead and just changed the 'gotoandPlay' to 'gotoandStop'.  That fixed it!  I hadn't even noticed that there was no stop in there.  Thanks!

Ned Murphy
Legend
May 15, 2013

You're welcome.