0
我正在开发大学项目的步骤顺序器。我为每个按钮创建了一个文档类,每个按钮的所有代码都在按钮类中。当按下按钮时,声音被推入该类中的数组中。我如何可以访问阵列中的主类,所以当按钮被按下它会在当前步骤如何访问数组构成另一个文档类
public var tomsoundArray:Array = new Array();
[Embed(source = "sounds/tom.mp3")]
public var tomSoundClass:Class;
public var tomSound:Sound = new tomSoundClass() as Sound;
public function TomButton()
{
// constructor code
//checkIfBtActive = true;
this.addEventListener(MouseEvent.CLICK, checkButtonState);
}
public function checkButtonState(event:MouseEvent)
{
if (this.alpha == 1)
{
this.alpha = 0.5;
tomsoundArray.push(tomSound);
trace(tomsoundArray);
tomSound.play();
trace("ButtonActive: " + this.alpha);
trace(this.parent.name);
trace(this.name);
}
else if (this.alpha == 0.5)
{
this.alpha = 1;
tomsoundArray.splice(0);
trace(tomsoundArray);
trace("Button Deactivated: " + this.alpha);
}
我在主类我不得不遍历轨道和按键的阵列中的每个跟踪和做再检查如果按钮的alpha值小于1,如果是播放声音形式的数组,但数组是在按钮类中的,并且我有96个按钮实例,所以如果我以每个实例为目标,我最终会得到3000行代码 –