Sound in Flash Actionscript

No Reply

Flash

For using a sound in Flash Actionscript we must use Linkage properties and choose Export for Actionscript option. Look at this picture :

Flash Linkage Properties

Choose a suitable name for Identifier, because you will need it in Actionscript.

In next move we should make an object from our sound :

mySound = new Sound();

Then with the name we choose for Identifier before we attach it to our object:

mySound.attachSound("test");

With start method we can make our sound file play, the first parameter will tell Flash to start sound at the specific point (in seconds). Second parameter will specify number of loops :

mySound.start(0,99999);

Some of sound methods

  • stop methol will stop the sound.
  • position method will store the stop point of sound in milliseconds.
  • setVolume method will specify the sound volume.
  • getVolume will get the sound volume. (between 0 and 100)
  • setPan will specify on which channel should sound be played, the value is between 100 and -100
  • getPan will return the current Pan value.
  • setTransform method will use and object with 4 parameters.
  • duration method will return the length of the sound in milliseconds.

Leave a Reply