3 Replies Latest reply on Nov 6, 2007 4:49 PM by clbeech

    Playing Sound File Using an Invisible Button

    coolburn
      I'm just starting to learn actionscript. I'm wanting to make an mp3 file play when I drag my mouse over an invisible button and then stop playing when I move the mouse away. I make a movie clip and then add the button. I add the following actionscript to the button :
      on (rollOver) {
      xmastime.play();
      }
      on (rollOut) {
      xmastime.stop();
      }
      My movie clip is on one layer and my button is on another layer. I have my xmastime mp3 file imported to the library but when I test the movie, the mp3 file won't play. What am I doing wrong? Thanks for any help you can give me.

      Mike
        • 1. Playing Sound File Using an Invisible Button
          clbeech Level 3
          have you declared the rest of the SoundObject structure and attached the Library sound file?

          You may want to write this more like below, place this code in frame one on a new layer in the same (root probably) timeline that you have the MC and the button in, call the layer 'actions', and remove the handlers that you have attached to the button. You will also need to give your button an 'instance name' (I used 'xmas_btn' in the code), and you will need to give the Sound file in the Library a 'Linkage identifier'. To do so, right-click the file in the Library, select ... you guessed it, Linkage ... , and enter a name for the id (I used the id of 'xmas_id' int he code) that should do it.

          • 2. Re: Playing Sound File Using an Invisible Button
            coolburn Level 1
            Thanks, your code example works perfect. The book I'm reading, "Show Me Macromedia Flash MX 2004" didn't say anything about declaring the rest of the SoundObject structure and attaching the Library sound file. I wish I could find a better book for learning actionscript. I'm very new to actionscript and programming. Thanks again for your time and help.

            Mike
            • 3. Re: Playing Sound File Using an Invisible Button
              clbeech Level 3
              you're welcome Mike, one of the best resources (although sometime difficult to follow) is the Flash Help Guide/Manual (F1) there is a huge amount of information on everything that Flash can do, as well as several starter tutorials, it is one of the most heavily documented Manuals anywhere. the topics you ran into here are covered in 'Learning ActionScript>Working with Images, Sound and Video' and 'ActionScript Langauge Reference>Sound' class