Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple scripting: On frame (45) go back to first frame..??

Contributor ,
Aug 03, 2011 Aug 03, 2011

I am trying to do a simple script and I am having a huge brain fart.

when I get to frame 45 I want the play head to go back to frame 1.  I have the below code but I am getting errors.  Can someone point my head in the right direction?

<><><>

onFrame (45) {
    this.gotoAndPlay(1);
}

<><><>

One error says that "is expecting semi-colon before or after first brace.....

second possible error is "call to possible undefined method onFrame....

Need help.

TOPICS
ActionScript
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 03, 2011 Aug 03, 2011

If that is the first scene, the in the last frame (45) simply putting...

    gotoAndPlay(1);

should work.

If it is not the first scene, then you should label the first frame and use the label instead of the frame number...

    gotoAndPlay("firstFrameLabel");

Translate
Guest
Aug 03, 2011 Aug 03, 2011

i have three suggestions that may work, im a noob myself but i think i know the answer to this one,

1st try going to frame one and adding a stop(); on it

if not try making it a gotoAndStop(1) instead of play

if all else fails try something a little harder:

instancenameofyourbutton.addEventListener(MouseEvent.CLICK, BackToStart)

function BackToStart(event:MouseEvent):void

{

MovieClip(this.root).gotoAndPlay(1,"Scene 1");

}

Hope this helps

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 03, 2011 Aug 03, 2011

I have a pulse action happening on some items on the stage.  I am letting the play head go for 45 frames then on the 45th frame I just want the play head to go back to frame 1 thus giving the repeating action of pulse.

The event would be the appearance of frame (45)  I guess.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2011 Aug 03, 2011

If you want the timeline to continuously loop, then you don't need any code - that is a natural behavior.  Just be sure not to have a stop() command anywhere in the timeline.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 03, 2011 Aug 03, 2011

I just tested your comment.  I have not stop(); actions.  This issue with this is that I am using scenes for different portions of the program.  I need to have something that directs the play head back to frame 1 so it does not continue into the next scene.

I did this back in the day with Swish Max but now in flash it seems to be difficult to do.

Any ideas of a work around?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2011 Aug 03, 2011

If that is the first scene, the in the last frame (45) simply putting...

    gotoAndPlay(1);

should work.

If it is not the first scene, then you should label the first frame and use the label instead of the frame number...

    gotoAndPlay("firstFrameLabel");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 04, 2011 Aug 04, 2011
LATEST

Great! This works.  I will also keep in mind to use frame labels for my other scenes.  That would have been my next post in the next couple of hours.

Thank you much!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines