Game Development Reference
In-Depth Information
} else { //NO INTERNAL REFERENCE FOUND - WILL
ATTEMPT TO LOAD
sound = new Sound(new URLRequest(name));
sound.addEventListener(IOErrorEvent.
IO_ERROR, onIOError, false, 0, true);
}
_soundList[name] = new SoundEngineObject(name, sound);
_soundList[name].addEventListener(SoundEngineEvent.
SOUND_COMPLETE, onSoundEvent, false, 0, true);
_soundList[name].addEventListener(SoundEngineEvent.
SOUND_STOPPED, onSoundEvent, false, 0, true);
}
var channel:SoundChannel = _soundList[name].play(offset,
loops, transform);
if (channel == null) {
return null;
}
if (_allMuted) _soundList[name].mute(true);
return channel;
}
protected function onIOError(e:IOErrorEvent):void {
if (_debug)
trace( " SoundEngine Error Message: Failed to load
sound: " + e.text);
delete _soundList[e.target.url];
dispatchEvent(new SoundEngineEvent(SoundEngineEvent.
SOUND_ERROR, e.target.url));
}
protected function onSoundEvent(e:SoundEngineEvent):void {
dispatchEvent(e);
}
public function stopSound(name:String = null):void {
if (name) {
if (_soundList[name]) {
_soundList[name].stop();
} else if (_debug) {
trace(
was not found,
ignoring stop command.
"
Sound
"
+ name +
"
"
);
}
} else {
for (var i:String in _soundList) {
_soundList[i].stop();
}
}
Search Nedrilad ::




Custom Search