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

how to get a movie clip to replay?

New Here ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

hi! i've got a movie clip containing a menu that shows up/hides when buttons are pressed. the first time the menu shows up, it plays an animation. every subsequent time that a button is pressed to open the menu, there is no animation. how can i get the animation to replay every time the button is pressed? i've tried writing menu.play();, menu.prevFrame();, MovieClip(menu.root).play(); etc. but none of those commands do anything. does anyone have any ideas? thank you in advance!

edit: also, an unrelated question but in case anyone knows, when the menu is closed, the music from the menu still continues playing despite the button being told to stop all sounds (SoundMixer.stopAll();). does this have something to do with the fact that the button and sound are inside of the movie clip? because buttons on the main stage are able to stop the sound without a problem.

Views

648

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

correct answers 1 Correct answer

Community Expert , Jun 11, 2017 Jun 11, 2017

it means you have not assigned an instance name for the timeline that you want to control.  assign it an instance name (eg, anim) and, if your code is on the main timeline, use:

pausemenu.anim.gotoAndPlay(1);

which makes me wonder what 'menu' is and if there's a playmenu someone that's going to complicate things.

Votes

Translate

Translate
Community Expert ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

SoundMixer.stopAll() stops all sounds playing at the time the code executes.  it doesn't stop sounds that start after that code executes.

so if you hear sound after that executes, you're either wring (it doesn't execute) or you're hearing a sound that started after that code executes.

as for restarting your menu, do you have code on your menu's timeline?  if so, that's a potential problem and needs to be explained. eg, if you have a stop() on the last frame of your menu, you should use menu.gotoAndPlay(1) to restart it.

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
New Here ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

thank you for your response! i realized i overlooked the fact that the animations are inside separate movie clips that are within the menu movie clip, so i tried to replay them as you'd suggested by writing something like menu.text.gotoAndPlay(1); (for the menu text movieclip) but it still doesn't work! i do have a stop() code at the end of each separate animation.

as for the music, the song starts when the menu button does the following command:

var song:menusong = new menusong();

var channel:SoundChannel = song.play();

and fails to stop when it's closed. it's still continuing despite the code being there to stop all sounds (it doesn't repeat or anything, it just keeps going). there's no other music on the timeline or anything.. i have the exact same code playing something different when the menu is gone, and the menu button manages to stop that with the stopAll command when the menu opens.

edit: i've just taken the close menu button outside the movie clip and that seems to have fixed things! i think the fact that the button was inside the menu movie clip was causing problems. the animation still isn't replaying though 😞

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 ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

use trace(this.name) on the timeline of the animation you want to stop.

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
New Here ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

thank you again for your response. just "trace(this.name);"? that doesn't seem to stop the animation.. it keeps looping if i write that!

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 ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

the trace statement is used to help debug your code.  you use that to determine the correct reference. eg,

trace(this.name,this.parent.name,this.parent.parent.name)

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
New Here ,
Jun 11, 2017 Jun 11, 2017

Copy link to clipboard

Copied

kglad, when i write in what you wrote, i get an output of "instance12 pausemenu root1", what does that mean? sorry, i've never done this before! thank you for being patient with me.

thank you nick, i've gotten the sound to work now but i'll be sure to check that video out for future reference.

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 ,
Jun 11, 2017 Jun 11, 2017

Copy link to clipboard

Copied

it means you have not assigned an instance name for the timeline that you want to control.  assign it an instance name (eg, anim) and, if your code is on the main timeline, use:

pausemenu.anim.gotoAndPlay(1);

which makes me wonder what 'menu' is and if there's a playmenu someone that's going to complicate things.

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
New Here ,
Jun 11, 2017 Jun 11, 2017

Copy link to clipboard

Copied

this might seem like a dumb question, but how do you assign an instance to a timeline? i thought the instance of a timeline was the instance of the object with the timeline in it, ie. a "text" movieclip with an animation inside of it.

there's no menu object per se -- i just wrote that in the opening post to make it simpler. there is only a pausemenu. sorry for the confusion!

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 ,
Jun 11, 2017 Jun 11, 2017

Copy link to clipboard

Copied

the movieclip that contains your trace statement is added to the pausemenu timeline.  click on that movieclip and, in the properties panel, enter an instance name.

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
New Here ,
Jun 11, 2017 Jun 11, 2017

Copy link to clipboard

Copied

it works now!! thank you so much! i couldn't have figured it out without your help!

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 ,
Jun 11, 2017 Jun 11, 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
Community Expert ,
Jun 10, 2017 Jun 10, 2017

Copy link to clipboard

Copied

If nothing else watch this tutorial and see if they way this mp3 player is built works for you. Flash MP3 Player Tutorial How to Make an MP3 Player - YouTube

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