0

我正在尝试在我的游戏中制作一些我的声音。单击文本字段时,音量会根据数字的值减小或增大。我试过这样做,但发生了错误。我的代码有什么问题?

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;

}
}
4

1 回答 1

0

您的代码有多个错误。

错误一:tchannel从哪里来Mchannel

var mysoundArray:Array = new Array(tchannel,Mchannel);

错误 2:数组mysoundArray没有名为 的子对象soundTransform

var volControl:SoundTransform = mysoundArray.soundTransform;

因此,对象volControl为空。修复上述错误,您的问题将得到解决。

于 2013-11-11T03:18:26.827 回答