Sounds using AS3
November 12th, 2008
Hi, from now to ever ehehe i ll write my posts in English. Today I will talk about Sound Object, how to use for load music and play other music on sound complete. First step is create object Sound, like used in Actionscript 2:
var s:Sound = new Sound();
After this step need call a music, that will be played:
s.loadSound("music.mp3", true);
The second argument – true – is used to set load progress music, a fake streaming. Now we need set the functions that will be called when sound will be played. We can call a function on music start, other on music loaded and when music will be total played. Bellow the full script that execute function on music played:
var s:Sound = new Sound(new URLRequest("music.mp3"));
s.addEventListener(Event.COMPLETE, doLoadComplete);
var channel:SoundChannel = new SoundChannel();
channel = s.play();
channel.addEventListener(Event.SOUND_COMPLETE, doSoundComplete);
function doLoadComplete($evt:Event):void
{
trace("Song loaded.");
}
function doSoundComplete($evt:Event):void
{
trace("Song done.");
}
I will write a class to load, play, next and prev musics and soon show it here. Thanks for all and comment if you need.





May 3rd, 2009 at 15:43
Hey whats up in da place nice blog man!