Monday, December 21, 2009

Play an embedded sound in AS3

Task: You need to play a sound contained within your content and set its volume.
Solution: Use the Sound, SoundChannel, and SoundTransform classes to play and
manipulate sounds.

function onSoundComplete(event:Event):void
{
trace("sound is completed");
}
var my_sound:Sound = new beep_id();
var sTransform:SoundTransform = new SoundTransform();
sTransform.volume = .5;
var channel:SoundChannel = my_sound.play();
channel.soundTransform = sTransform;
channel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
Setting the class name for an embedded
sound for ActionScript 3

No comments:

Post a Comment