flash video animation tutorials

Steve's Book of the month: "Macromedia Flash MX 2004 Bible" by Robert Reinhardt;




Flash MX - Sound Object

Import Sound File

  1. Select File - Import To Library . Choose your sound file. I usually use .wav files. Try .mp3's if you like.
  2. Select Window - Library ( or press F11) to open the library. Right click on the sound file in the library.
  3. Select "Linkage" from the drop down menu
  4. Tick the "Export for Actionscript" box and the "export in first frame " box.
  5. In the "Identifier" Textfield , type the actionscript name that you will use in your script. I used "bang". Click "OK" button to close linkages window.

Create a button

  1. Draw a button, I used a round circle. Select the circle and hit key F8 (or Select Menu Item "Insert" - "Convert to Symbol")
  2. In the "Convert to Symbol" dialog box, select the "Button" box, and write a name in the "Name" TextField. I used "soundButton".
  3. Click on the sound button on the stage. Open the Properties window and in the "Instance Name" textfield write your button's actionscript variable name. I used "sound_btn"

Flash Tutorials in Video Format - Watch them now at LearnFlash.com  

Write code to play Sound

  1. Create a new layer in the timeline. ("Insert" - "Layer") . Double click on the layer name and rename it "Control". This is where we will write our Code.
  2. With the first frame of the control layer selected, open the Actions Window (F9 or Menu "window" - "actions").
  3. Type this code into the Actions window:
    mySound = new Sound();
    mySound.attachSound("bang");
    
    sound_btn.onRelease = function() {
    	mySound.start();
    }
    
  4. Test it - Hit (Control + Enter) Keys.

flash video animation tutorials