4 Replies Latest reply on Jan 27, 2011 6:08 PM by Super_Noodles

    Sound problem

    Super_Noodles Level 1

      On my first page I have got two checkboxes. One for sounds and one for music. This allows the user to choose whether they want the sound played before it suddenly starts and shocks them.


      This is the code i have for the Sounds checkbox:


      on beginSprite me

        if (sprite("checkbox_Sounds").hilite = TRUE) then 

          sound(1).volume = 255

        else if (sprite("checkbox_Sounds").hilite = FALSE) then

          sound(1).volume = 0

        end if


      and i have some audio on the page with this code (it is played when hovering over an item)
      The code seems fine and with no errors but it does not work. I guess I'm doing something stupid but have spent too long trying to figure it out. Please help.

        • 1. Re: Sound problem
          Mike Blaustein Level 4

          For one thing, your code is on beginSprite which only happens once, when the sprite first appears.  So, clicking on the checkbox will never change the volume unless you leave the frame and go to a frame tht this checkbox is not in, then come back.  You probably want to also add some code to on mouseUp so that it adjusts the volume when it gets clicked.

          • 2. Re: Sound problem
            Super_Noodles Level 1

            Oh right, I have now changed it back to MouseUp but still nothing is happening.


            I have also tried this if statement but it also has no effect


            if (sprite("checkbox_Sounds").selected=1) then

            • 3. Re: Sound problem
              Mike Blaustein Level 4

              put a few "put" statements into your code to see what is happening (or not happening)... for example:


              on mouseUp me

              put sprite(me.spriteNum).selected

              ... your other code here...



              That will test to see if the button actually is getting pressed, and if the selected property is being correctly toggled... some Flash Component buttons don't work until you set the EventPassThrough to Always in the property inspector.

              • 4. Re: Sound problem
                Super_Noodles Level 1

                Thanks for the help Mike!


                I'm finally getting to grips with Lingo now. I did make the silly mistake of having the component as Never not Always though :S