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

Replay button inside movieclip to replay entire animation

Community Beginner ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

Hi, my main stage consists of a single frame with different movieclips, each with different frame starting and ending positions, and of course a stop. The last one contains a replay button; on click I want it to replay every movie clip again, starting with the 1st one. I know that I have to set it up so each movie clip is restarted, but I'm at a loss on how to make it replay from the 1st movieclip since the button is inside the last one. I know an easy solution is to move the buttons to the main stage, but I'd like to learn how to set it inside a movieclip. Thank you in advance for the help.

TOPICS
ActionScript

Views

298

Translate

Translate

Report

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
Community Expert ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

parent.movieclip1.gotoAndPlay(1);

parent.movieclip2.gotoAndPlay(1);

etc

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

I tried setting the button Actionscript like this

replay.addEventListener(MouseEvent.CLICK, fl_ClickToRestart);

function fl_ClickToRestart(event:MouseEvent):void

{

parent.congrats_clip.gotoAndPlay(1);

parent.you_clip.gotoAndPlay(1);

parent.absol_clip.gotoAndPlay(1);

parent.nothing_clip.gotoAndPlay(1);

parent.viruswin_clip.gotoAndPlay(1);

}

and I got this error 5 times: "1119: Access of possibly undefined property ____ through a reference with static type flash.display:DisplayObjectContainer."

I googled some more, and I got it to work like this:

replay.addEventListener(MouseEvent.CLICK, fl_ClickToReplay);

function fl_ClickToReplay(event:MouseEvent):void

{

MovieClip(parent).congrats_clip.gotoAndPlay(1);

MovieClip(parent).you_clip.gotoAndPlay(1);

MovieClip(parent).absol_clip.gotoAndPlay(1);

MovieClip(parent).nothing_clip.gotoAndPlay(1);

MovieClip(parent).viruswin_clip.gotoAndPlay(1);

}

Thank you both nonetheless, it was learning about the parent function what helped me!

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

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 ,
Oct 26, 2017 Oct 26, 2017

Copy link to clipboard

Copied

Another easy solution is to move all of the code to the main stage and target the movieclips from there, including the code that is used for the buttons in the last one.

lastmovieclip.addEventListener(MouseEvent.CLICK, restartAll);

function restartAll(evt:MouiseEvent):void {

        movieclip1.gotoAndPlay(1);

        movieclip2.gotoAndPlay(1);

        etc...

}

Votes

Translate

Translate

Report

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