10 Replies Latest reply on Aug 31, 2007 5:02 AM by JohnGree

    sound class pause

    JohnGree Level 1
      Hi i have a flash presentation, which has a pause and play button.

      the pause button pauses my movie fine, except i have voice sound as a sound class, the sound starts to play, but i can not get it to pause or stop

      any ideas what i need to do?
      i have the following code
        • 1. sound class pause
          place this code, along with your pause and play buttons, on the root scene. the code will fade your sounds in and out for you. hope you like it.
          • 2. Re: sound class pause
            JohnGree Level 1
            ok thanks, i have tried this but cant get it to work?

            all i need is to have some action script for my pause btn so the movie and the sound "newWelcome" pauses and then

            on my play btn i need some action script to resume from the pause.

            dont know what i am doing wrong with your last code?
            • 3. sound class pause
              _name Level 1
              yeah, i'm not sure where you might be going wrong. i wrote the code above in flash and tested it many times. i'm certain it works. did you place the code on the _root of your movie along with the buttons that control your presentation? if not, do so. if you have already done this, make sure that the code is on the same frame as your buttons. also, check your naming conventions. additionally, i noticed in your code up top that you were defining and attaching your sound twice instead of just once - take that out. the code i wrote you will kill your sound when the pause button is pressed and resume it once the play button is pressed, but you will have to place the code to pause or start your presentation within the onRelease events yourself. if you still can't get it to work just let me know. i will help you until it works.
              • 4. Re: sound class pause
                JohnGree Level 1
                ok this is what i have

                is this correct?
                • 5. sound class pause
                  _name Level 1
                  no, your code above is not correct: your onRelease functions are written as such to be placed directly on your button objects and not on the root time line; additionally, the function volAdjust(), which is the function responsible for controlling your sound, is not present in your code at all.

                  to fully understand what is going on, take five minutes to do this:

                  1.) open a brand new flash document.

                  2.) import a sound to your library ( file > import > import to library ), open your
                  library ( f11), right-click on the sound inside your library and select linkage,
                  check export for actionscript, make sure export in first frame is checked, and
                  then enter, newWelcome , into the identifier text field.

                  3.) draw a rectangle on stage and convert it to a movieclip (f8) - name it whatever you wish.

                  4.) with the newly created movieclip selected, go to your properties inspector
                  and enter the string, btnPlay , into the instance name text field.

                  5.) open your library ( f11) and drag another instance of the movieclip you just
                  created onto the stage.

                  6.) with the newly dragged out instance of your movieclip selected, go to your
                  properties inspector and enter the string, btnPause , into the instance name text field.

                  7.) make a new layer above the one you have working in and name it actions.

                  8.) lastly ,copy and paste the code i sent you into the first frame of the layer
                  actions. (note: your movieclips, btnPlay and btnPause, should be on the first
                  frame of your second layer ( the layer beneath your layer labeled actions ).

                  • 6. Re: sound class pause
                    JohnGree Level 1
                    Hi many thanks for your help, i have that working but it is not pausing my sound just lowering the volume to zero

                    the sound i have is a naration voice so i need this to actually pause with the movie

                    if i click pause at the min the sound acually keeps playing but with no volume

                    how would i alter the code to do what i need?
                    • 7. sound class pause
                      FlashTastic Level 1

                      Try this instead, I think it's what you were after.


                      • 8. Re: sound class pause
                        JohnGree Level 1
                        ok yes that works, th only thing is i wanted to have a play btn resume rather than have to click the pause btn again.

                        so what i acually need is

                        1. sound to play when the movie starts
                        2. pause btn pauses the movie and the sound
                        3. play btn only resumes the movie and the sound

                        how would i change the code to do this?
                        • 9. Re: sound class pause
                          FlashTastic Level 1
                          This should work then - code heavily commented for your benefit.

                          note: the 'movie pause' portion of the code will only work if all of your animation is on the _root timeline and not in separate movieclips.

                          • 10. Re: sound class pause
                            JohnGree Level 1
                            ok thanks that works well

                            just one more thing, the newWelcome sound, is quite short, i want to loop it but not sure how when its a linked file?