0

我正在尝试制作一个使用频道的音量滑块。

我不知道该怎么做。

这是我的代码:

import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.media.Sound;

// Enter Frame Event
var sliderValue:uint = mySlider.sliderKnob.x;
addEventListener(Event.ENTER_FRAME, frame);
function frame(event):void {
    sliderValue = mySlider.sliderKnob.x ;
    status_txt.text = "Volume: "+sliderValue;
    var snd:Sound = new Sound();
    var channel:SoundChannel = new SoundChannel();
    var volumeLevel = channel.soundTransform;
    var req:URLRequest = new URLRequest("Background.mp3")
    snd.load(req);
    channel = snd.play();
    var newLevel:Number = mySlider.sliderKnob.x / 100;
    volumeLevel.volume = newLevel;
    channel.soundTransform = volumeLevel;
}
4

1 回答 1

0

您正在实例化并在每一帧上加载声音。你需要创建一个新的 SoundTransform 实例!
我认为滑块本身正在工作!

var snd:Sound = new Sound();
var channel:SoundChannel = new SoundChannel();
var volumeLevel:SoundTransform = new SoundTransform();

snd.load(new URLRequest("Background.mp3"));
channel = snd.play();

addEventListener(Event.ENTER_FRAME, frame);

function frame(event):void {
    sliderValue = mySlider.sliderKnob.x ;
    status_txt.text = "Volume: "+sliderValue;
    var newLevel:Number = sliderValue / 100;
    volumeLevel.volume = newLevel;
    channel.soundTransform = volumeLevel;
}
于 2013-03-10T12:09:21.547 回答