Game Development Reference
In-Depth Information
play(_pauseTime, _loops, _transform);
_offset = normalOffset;
} else {
_pauseTime = channel.position;
channel.stop();
}
}
}
public function get isPaused():Boolean {
return _paused;
}
The final methods in the class control the pausing and muting of
the sound, as well as information about each. In the pause method,
we store where the sound is when it is paused and stop it, using this
information as the offset when we resume. In the mute method, we
simply toggle between a zeroed-out SoundTransform object and the
one stored in our _transform property. Note that, in the original ver-
sion, these methods took no parameters and simply toggled the
value of the internal property. This led to inconsistencies where
some objects could get set to muted and some not and then toggling
would just invert both sets; there was no way to force all of them to
mute. By making the passing of a value explicit this solves the issue.
Now that we have an understanding of how each object will
work in the engine, we can return to the main class and see how
each is accessed. Back in the SoundEngine class:
public function playSound(name:String, offset:Number = 0, loops:
int = 0, transform:SoundTransform = null, applicationDomain:
ApplicationDomain = null):SoundChannel {
if (!_soundList[name]) { //SOUND DOES NOT EXIST
var sound:Sound;
var soundClass:Class;
try {
soundClass = (applicationDomain != null) ?
applicationDomain.getDefinition(name) as
Class : getDefinitionByName(name) as Class;
} catch (err:ReferenceError) {
if (_debug)
trace("SoundEngine Message: Could
not find sound object with name
" + name + " . Attempting to load
external file.");
}
if (soundClass) { //INTERNAL REFERENCE FOUND -
CREATING SOUND OBJECT
Search Nedrilad ::




Custom Search