Change theme: 
Search for :    
Previous Blogs
Transformers Blogs
Misc Blogs
Computer/Tech Logs
Movie Reviews
Popular Blogs
ASCII chart
Comment from Tamera on December 24, 2015
Configuring Speedstream 6520 For Modem Only Mode
Comment from Janet on September 13, 2015
Transformers Reviews: MP-19 Smokescreen
Comment from Silagra on August 1, 2015
Transformers Reviews: MP-21 Masterpiece (Bumble) Bee
Comment from google authorship check on June 26, 2015
Aww...It's a Cat...Meow
Comment from vxt on June 4, 2015

RSS Facebook Twitter Instagram
My Tweets
Flash Tips: Sound with AS3
A few months ago I switch over to Flash CS4 using AS3 and it was completely different from what I had been using before (Flash MX using AS2). I've decide to write some mini tutorials just for my own reference and maybe it will help someone else out. First, here's a tutorial for how to use sound.

To play sound from an mp3 file:

// Import the necessary sound classes

var snd:Sound = new Sound();

// create a URL request for your file
var req:URLRequest = new URLRequest("YOUR MP3 FILE");

// Load the file

// create a SoundChannel object.
// This will allow you to control your sound later so it's
// good to use instead of just playing the sound with
// the Sound object.
var channel:SoundChannel = new SoundChannel();
channel =;

To stop your sound:


Optionally, you can create an event listener for when your sound is done playing.

function onPlaybackComplete(e:Event) {
  // Do something


To control the volume:


var vol = 0.5 // define the volume from 0 - 1
var stf:SoundTransform = new SoundTransform(vol);
channel.soundTransform = stf;

To play an embedded sound from your library:

- First, you need to go to the properties window for your sound.
- In the "Linkage" section, check off "Export for Actionscrpt" and "Export in Frame 1".
- Then, where it says, "Class", give it a name, for example, name it "mySoundClass"
- Where it says, "Base class", put in "".

Then, go to the first frame and instead of loading an mp3 file, put the following code:

var snd:mySoundClass = new mySoundClass(); // mySoundClass is the class name you gave your file above.

Everything else is pretty much the same as if using an mp3 file.

Post a Comment

Whathyear is 10hyears from now?Please answer the question shown

Copyright © Viet Tran. All Rights Reserved. Powered by Content ManagerTM | Top