我正在尝试在我的游戏中制作一些我的声音。单击文本字段时,音量会根据数字的值减小或增大。我试过这样做,但发生了错误。我的代码有什么问题?
import flash.events.MouseEvent;
import flash.media.SoundChannel;
var onoff:Number;
onoff = 2
var mysoundArray:Array = new Array(tchannel,Mchannel);
var volControl:SoundTransform = mysoundArray.soundTransform;
options_mc.onoff_txt.text = String(onoff);
options_mc.onoff_txt.addEventListener(MouseEvent.CLICK, tick);
function tick(event:MouseEvent)
{
if(onoff == 1)
{
onoff = 2
options_mc.onoff_txt.text = String(onoff);
volControl.volume = .5;
mysoundArray.soundTransform = volControl;
}
else if(onoff == 2)
{
onoff = 1
options_mc.onoff_txt.text = String(onoff);
volControl.volume = 1;
mysoundArray.soundTransform = volControl;
}
}