topical media & game development
student-game-wakuwaku-com-waku-classes-WakuSound.ax
student-game-wakuwaku-com-waku-classes-WakuSound.ax
(swf
)
[ flash
]
flex
package // com.waku.classes
{
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
public class @ax-student-game-wakuwaku-com-waku-classes-WakuSound
{
private var _soundChannel : SoundChannel;
private var _soundTransform:SoundTransform;
public function @ax-student-game-wakuwaku-com-waku-classes-WakuSound()
{
_soundChannel = new SoundChannel();
_soundTransform = new SoundTransform();
_soundChannel.soundTransform=_soundTransform;
_soundTransform.volume = 1.0;
}
public function Play(soundUrl : String) : void {
var sound : Sound = new Sound();
var req: URLRequest = new URLRequest(soundUrl);
//var audio:SoundChannel = new SoundChannel();
sound.addEventListener(Event.OPEN,soundLoadCompleteHandler);
sound.load(req);
//"com/waku/animals/0"+ animalId.toString() + "/sound1.mp3")
}
private function soundLoadCompleteHandler(event:Event):void {
var localSound:Sound = event.target as Sound;
_soundChannel = localSound.play(0,1,_soundTransform);
}
public function unmute():void {
_soundTransform.volume =1.0;
}
public function mute() : void {
//var _sound:Sound = new Sound(new URLRequest("song.mp3"));
_soundTransform.volume = 0.0;
}
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.