11 Replies Latest reply on Jul 7, 2009 6:52 AM by eapre

    play/pause button dilemma

    eapre

      Hello!  I have a play/pause button that mostly works...when I press pause the sound and the movieclip both stop...then I press play and they both play...then I press pause again and they both pause...then I press play again and the sound continues but the movieclip goes to the beginning!  What kind of changes do I need to make to this code??  It seems like it's having issues with the toggling between the two. Thanks for any assistance!

       

       

      playpause_btn.onRelease = function() {
          if (audioplay == true) {
              p = Math.round(_root.Sound3.position / 1000);
              _root.Sound3.stop();
              audioplay = false;
              play_mc._visible = true;
              pause_mc._visible = false;
              indifferencecurves_mc.stop();
         
          } else {
              _root.Sound3.start(p, 0);
              audioplay = true;
              pause_mc._visible = true;
              play_mc._visible = false;
              indifferencecurves_mc.play();
          }
      };

        • 1. Re: play/pause button dilemma
          kglad Adobe Community Professional & MVP

          there's nothing in that code that would make  indifferencecurves_mc return to frame 1.  if it's at the end of its timeline it will return to frame 1.

          • 2. Re: play/pause button dilemma
            eapre Level 1

            Well, it's doing it so it must just be a stupid Flash fluke!  Weird!

            • 3. Re: play/pause button dilemma
              kglad Adobe Community Professional & MVP

              almost certainly it's something you're doing to cause the problem.

              • 4. Re: play/pause button dilemma
                eapre Level 1

                I know now what is causing this problem.  My explanation_mc animation here is only two seconds long, but my audio is much longer.  When it gets to the end of the animation but I pause the sound, since the animation is done, it goes and plays the beginning of the animation if play is pressed.  I want the code to say that if the animation is already done playing, don't play it again.  Can anyone help?  Maybe someone not so smart allickey?

                 

                 

                playpause_btn.onRelease = function() {
                    if (audioplay == true) {
                        p = Math.round(_root.Sound2.position / 1000);
                        _root.Sound2.stop();
                        audioplay = false;
                        play_mc._visible = true;
                        pause_mc._visible = false;
                        explanation_mc.stop();
                   
                    } else {
                        _root.Sound2.start(p, 0);
                        audioplay = true;
                        pause_mc._visible = true;
                        play_mc._visible = false;
                        explanation_mc.play();
                    }
                };

                • 5. Re: play/pause button dilemma
                  kglad Adobe Community Professional & MVP

                  i'm not sure why you are critical of my comment, but good luck.

                  • 6. Re: play/pause button dilemma
                    eapre Level 1

                    LOL..

                    • 7. Re: play/pause button dilemma
                      eapre Level 1

                      Ok, so really, does someone have a solution to this?  Because plenty of people have viewed this and I'm sure they would like to see how this was resolved.

                      • 8. Re: play/pause button dilemma
                        Ned Murphy Adobe Community Professional & MVP

                        You can probably test the _currentframe of the animation to determine if it should be allowed to play or not.  Or you could have the end of the animation set a variable that indicates it is done so that it will inhibit any attempt to allow it to play if that variable has been set.

                        • 9. Re: play/pause button dilemma
                          eapre Level 1

                          Thanks, much appreciated :-)

                          • 10. Re: play/pause button dilemma
                            Ned Murphy Adobe Community Professional & MVP

                            You're welcome

                            • 11. Re: play/pause button dilemma
                              eapre Level 1

                              Ok, I think I put the if statement for the _totalframes in the wrong part, because now when I press the playpause_btn, the audio stops but the movieclip is still playing.

                               

                              I used this code (I changed the names of my movieclips from last time):

                               

                              playpause_btn.onRelease = function() {
                                  var content4anim_mc:MovieClip = content4.content4panel.content4anim_mc;
                                  if (content4anim_mc._currentframe = _totalframes) {
                                      content4anim_mc.stop();
                                  };
                                  if (audioplay == true) {
                                      p = Math.round(_root.Sound4.position / 1000);
                                      _root.Sound4.stop();
                                      audioplay = false;
                                      play_mc._visible = true;
                                      pause_mc._visible = false;
                                      content4anim_mc.stop();
                                 
                                  } else {
                                      stopAllSounds();
                                      _root.Sound4.start(p, 0);
                                      audioplay = true;
                                      pause_mc._visible = true;
                                      play_mc._visible = false;
                                      content4anim_mc.play();
                                  }
                              };

                               

                              Could someone assist?  Thanks!