Attach the Sound to the Sound Object

 < Day Day Up > 



By using ActionScript you can access the sound from the Library, but sounds in the Library won't export by default with the movie unless they have been placed onto the Stage. You can override this by setting the Linkage properties. The sound then loads with the movie. To set the Linkage and attach the sound, follow these steps:

  1.  Habitat Alert site   Open the  ecard3.fla file from the chapter29_exercise folder.

  2. Import the  heron_audio.mov file to the Library (in the chapter29_ exercise folder).

  3. Select the sound in the Library panel.

  4. Right-click (Control+click) and select Linkage.

  5. In the Linkage Properties dialog box, give it a unique identifier. (We used soundID.)

  6. Leave the Export for ActionScript box checked.

  7. Click Ok and leave the file open.

    Now you are ready to attach the sound to a sound object. An object can only have one sound attached. Use the attachSound method to attach.

  8. Select the top layer and add a new layer. Double-click to rename it and name it sound.

  9. Select the first Keyframe of the Sound layer, and open the Actions panel (F9). In Expert mode, type the following code:

     heron=new Sound(); heron.attachSound("soundID"); heron.start(0) 

This creates a new instance of the sound object named heron and attaches the sound using the identifier you added in the Linkage dialog box. (We used soundID.) Then you tell the sound to start.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net