4 Replies Latest reply on May 13, 2012 2:18 PM by ash_vir1

    help: how do i stop sound when i leave the frame?

    ash_vir1

      how do i stop a puppetsound when i  go to another frame .

       

      i have created a button and attached the script below to play the sound

       

      on mousedown

        puppetsound "abc song"

        end

       

      but i want the music to stop when i leave the frame

      at the moment the music is still playing when i leave the frame.

       

       

      any help

       

      thanx

        • 1. Re: help: how do i stop sound when i leave the frame?
          Sean_Wilson Adobe Community Professional

          You should use syntax like:

            sound(channel).play( member("name") )

          instead of the obsolete puppetSound command, and then you can use

            sound(channel).stop()

          when you leave (#endSprite)

          • 2. Re: help: how do i stop sound when i leave the frame?
            ash_vir1 Level 1

            hi sean_wilson

             

            i'm quite new to lingo so please excuse me for not understanding.

             

            i have changed it to

            on mousedown

              sound(5).play( member("abc song") )

            end

             

             

            for the stop command do i need to create another behaviour and attach it to the sprite e.g

             

            on frame exit

            sound(5).stop()

            end

             

             

            thanx.

            • 3. Re: help: how do i stop sound when i leave the frame?
              Sean_Wilson Adobe Community Professional

              You are nearly correct. However, I don't think you want to respond to an #exitFrame message and stop your sound (depending on where you have the code attached). Rather, use the #endSprite message (issued when the playhead leaves a sprite's span in the score):

              on mouseDown me

                sound(5).play( member("abc song") )

              end

               

              on endSprite me

                sound(5).stop()

              end

              • 4. Re: help: how do i stop sound when i leave the frame?
                ash_vir1 Level 1

                i was hoping you could maybe help me further with the sound.

                 

                i have a sound in stage channel 1 which i want to play as soon as the movies starts. and the user is able to control by pressing the pause button

                 

                property pPaused

                 

                on beginSprite me

                pPaused = 0

                end

                 

                on mouseUp me

                if pPaused then sound(1).play()

                else sound(1).pause()

                pPaused = not pPaused

                end

                 

                 

                i have added other sound in songs (2 sounds ) and nursery rhymes (4 sounds ) with the behaviour added to the buttons as below

                 

                 

                on mouseDown me

                  sound(5).play( member("ABCSong") )

                end

                 

                on endSprite me

                  sound(5).stop()

                end

                 

                this stop the sound playing when i leave the frame but doesn't stop the sound in the stage channel 1.

                 

                i only want to play 1 sound at a time perferly when the button is pressed and stop 

                 

                could you please advise of how to solve this problem. only using intermediate/basic lingo as i need to understand it.

                your help is much appreciated

                 

                 

                thank you