Flash Lite 2 |
|||
| Flash Lite 2.x ActionScript リファレンスガイド > ActionScript クラス > Sound > getVolume (Sound.getVolume メソッド) | |||
public getVolume() : Number
サウンドボリュームレベルを 0 ~ 100 の整数で返します。ここで、0 はボリュームオフ、100 はフルボリュームです。デフォルト設定は 100 です。
使用できるバージョン : ActionScript 1.0、Flash Lite 2.0
Number - 整数。
次の例では、Drawing API および実行時に作成されるムービークリップを使用してスライダを作成します。ダイナミックに作成されたテキストフィールドに、SWF ファイルで再生されているサウンドの現在のボリュームレベルが表示されます。次の ActionScript を ActionScript ファイルまたは FLA ファイルに追加します。
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);
this.isDragging = true;
};
knob_mc.onMouseMove = function() {
if (this.isDragging) {
this.volume_txt.text = this._x;
}
}
knob_mc.onRelease = function() {
this.stopDrag();
this.isDragging = false;
my_sound.setVolume(this._x);
};
setVolume (Sound.setVolume メソッド)