Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 QuickSkills

Creating A Simple Audio Player (sound class)

 

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.
 

Note: In this example the mp3 file has already been imported into the library. When the audio player is exported as a swf file the mp3 is automatically embedded into the swf file. This can cause larger file sizes and consequently longer download times. To see how to load and play an external mp3 file see [Creating An External MP3 Filer Player].

© 2007 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us