EnhancedSound is a sub class of built-in Sound class, which extends
Sound with some extra properties and methods.
The properties and the methods of Sound are available as they are, with
this EnhancedSound as well.
Properties added (All optional)
Used for the methods 'fadeOut' and 'fadeIn'
A boolean value which specifies whether the sound can be played
overlapping itself when it's already playing. If true, it stops
the previous play before it starts.
An x coordinate number value which sets its panning position.
i.e. Assigning 0 to xPosPan sets the pan to leftmost and Stage.Width
Can be useful when you want the sound's pan to follow the mc's
mySound.setXPosPan(0) is equivalent to mySound.setPan(-100).
mySound.setXPosPan(Stage.Width) is equivalent to mySound.setPan(100).
Equivalent to 'start' of Sound, except it supports 'dontOverlap'
and switching 'file'.
Fades-out the sound during the time specified with the passed milliseconds
Fades-in the sound during the time specified with the passed milliseconds
Optionally, you can specify the file to play at this time as well.
Usage example 1
// "bell.wav" and "buzzer.wav"
in the library of _level10
// The parameters, except the first one which specifies the timeline,
are all optional.
_global.SE_bell = new EnhancedSound(_level10.SE_bell_mc, "bell.wav");
_global.SE_buzzer = new EnhancedSound(_level10.SE_buzzer_mc, "buzzer.wav",
70, true, 0.008, 0, Stage.Width*0.7);
Usage example 2
// "song1.wav" and "song2.wav"
in the library of _level1
_global.BGM1 = new EnhancedSound(_level1, null, 50, true, 0, 9999);
// You may switch 'file' to another at a later time
// Also you may do something like this to cross-fade two BGMs.
// "song3.wav" in the library of _level2
_global.BGM2 = new EnhancedSound(_level2, "song3.wav", 50,
true, 0, 9999);