Skip to main content
jambiscotti
Participating Frequently
June 10, 2017
Answered

how to get a movie clip to replay?

  • June 10, 2017
  • 2 replies
  • 1304 views

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.

    This topic has been closed for replies.
    Correct answer kglad

    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.


    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.

    2 replies

    Community Expert
    June 10, 2017

    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

    kglad
    Community Expert
    Community Expert
    June 10, 2017

    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.

    jambiscotti
    Participating Frequently
    June 10, 2017

    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 ):

    jambiscotti
    Participating Frequently
    June 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.


    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!