Game Development Reference
In-Depth Information
public function play(offset:Number = 0, loops:int = 0, transform:
SoundTransform = null):SoundChannel {
if (_canPlaySound) {
_offset = offset;
if (loops < 0) loops = int.MAX_VALUE;
_loops = loops;
channel = sound.play(_offset, _loops, transform);
if (channel == null) {
_canPlaySound = false;
return null;
}
_transform = channel.transform;
if (isMuted) { //In case this sounds was muted,
paused, and then resumed
mute(true);
}
channel.addEventListener(Event.SOUND_COMPLETE, complete,
false, 0, true);
_playing = true;
return channel;
} else {
return null;
}
}
public function stop():void {
if (_canPlaySound && channel != null) {
channel.stop();
_loops = 0;
_playing = false;
dispatchEvent(new SoundEngineEvent
(SoundEngineEvent.SOUND_STOPPED, name));
}
}
protected function complete(e:Event):void {
if (_canPlaySound && channel != null) {
_playing = false;
dispatchEvent(new SoundEngineEvent(SoundEngineEvent.
SOUND_COMPLETE, name));
}
}
public function get isPlaying():Boolean {
return _playing;
}
Search Nedrilad ::




Custom Search