How to create a simple audio player using the sound class:
- In the library panel:
- Drag the "play_btn" and the "stop_btn" on stage.
- Then right click on the sound file "matts_blues" and select "linkage" from the drop down menu.
- In the "linkage properties" window:
- Check the "Export for Actionscript" check box.
- Press the "OK" button.
- On stage:
- Select the play button then in the properties panel set the instance name to "play_btn".
- Then select the stop button and in the properties panel set the instance name to "stop_btn".
- In the timeline:
- Select the first frame in the "actions" layer.
- Then open the actionscript panel and add the following script:
var my_sound:Sound = new Sound();
my_sound.attachSound("matts_blues");
play_btn.onRelease = function(){
my_sound.start();
}
stop_btn.onRelease = function(){
my_sound.stop();
}
- In the main menu go to Control > Test Movie.
discuss this topic to forum
