Choose File > Import > Import to Library to import a sound. http://www.53dream.com
Select a sound in the library, right-click (Windows) or control-click (Macintosh), and then select Link.
Select "Export for ActionScript" and "Export in first frame", and then specify the sound identifier a_thousand_ways.
Add a button on the stage and name it play_btn.
Add a button on the stage and name it stop_btn.
Select Frame 1th on the main timeline and choose Window > action.
Add the following code to the Actions panel:
The code is as follows |
Copy Code |
var song_sound:sound = new sound (); Song_sound.attachsound ("A_thousand_ways"); Play_btn.onrelease = function () { Song_sound.start (); }; Stop_btn.onrelease = function () { Song_sound.stop (); }; |
The code first stops the speaker movie clip. It then creates a new Sound object (Song_sound) and attaches the link identifier to the object as the A_thousand_ways sound. The Onrelease event handlers associated with the PLAY_BTN and Stop_btn objects start and stop the sound by using the Sound.start () and Sound.stop () methods, and also play and stop the attached sound.
Select "Control" > "Test movie" to try listening to the sound.