Sound.getVolume()
Availability
Flash Player 5.
Usage
my_sound.getVolume() : Number
Parameters
None.
Returns
An integer.
Description
Method; returns the sound volume level as an integer from 0 to 100, where 0 is off and 100 is full
volume. The default setting is 100.
Example
The following example creates a slider using the Drawing API and a movie clip that is created at
runtime. A dynamically created text field displays the current volume level of the sound playing in
the SWF file. Add the following ActionScript to your AS or FLA file:
var my_sound:Sound = new Sound();
my_sound.loadSound("song3.mp3", true);
this.createEmptyMovieClip("knob_mc", this.getNextHighestDepth());
knob_mc.left = knob_mc._x;
knob_mc.right = knob_mc.left+100;
knob_mc.top = knob_mc._y;
knob_mc.bottom = knob_mc._y;
knob_mc._x = my_sound.getVolume();
with (knob_mc) {
lineStyle(0, 0x000000);
beginFill(0xCCCCCC);
moveTo(0, 0);
lineTo(4, 0);
lineTo(4, 18);
lineTo(0, 18);
lineTo(0, 0);
endFill();
}
knob_mc.createTextField("volume_txt", knob_mc.getNextHighestDepth(),
knob_mc._width+4, 0, 30, 22);
knob_mc.volume_txt.text = my_sound.getVolume();
knob_mc.onPress = function() {
this.startDrag(false, this.left, this.top, this.right, this.bottom);
760
Chapter 2: ActionScript Language Reference
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?