Actionscript 3 从函数中获取错误1009?

Actionscript 3 从函数中获取错误1009?,actionscript-3,Actionscript 3,我得到了错误1009,但我不知道为什么。我从第31行和第12行得到错误。代码如下: import flash.events.MouseEvent; var TLBool: Boolean = false; var TBool: Boolean = false; var TRBool: Boolean = false; var CLBool: Boolean = false; var CBool: Boolean = false; var CRBool: Boolean = false; var

我得到了错误1009,但我不知道为什么。我从第31行和第12行得到错误。代码如下:

import flash.events.MouseEvent;

var TLBool: Boolean = false;
var TBool: Boolean = false;
var TRBool: Boolean = false;
var CLBool: Boolean = false;
var CBool: Boolean = false;
var CRBool: Boolean = false;
var BLBool: Boolean = false;
var BBool: Boolean = false;
var BRBool: Boolean = false;
startGenerate();

var randomArray: Array = [];

var buttonPressed: String;

TL.addEventListener(MouseEvent.CLICK, TLClick);
T.addEventListener(MouseEvent.CLICK, TClick);
TR.addEventListener(MouseEvent.CLICK, TRClick);
CL.addEventListener(MouseEvent.CLICK, CLClick);
C.addEventListener(MouseEvent.CLICK, CClick);
CR.addEventListener(MouseEvent.CLICK, CRClick);
BL.addEventListener(MouseEvent.CLICK, BLClick);
B.addEventListener(MouseEvent.CLICK, BClick);
BR.addEventListener(MouseEvent.CLICK, BRClick);

//mix

function startGenerate() {
    randomArray[0] = Math.floor(Math.random() * 2);
    randomArray[1] = Math.floor(Math.random() * 2);
    randomArray[2] = Math.floor(Math.random() * 2);
    randomArray[3] = Math.floor(Math.random() * 2);
    randomArray[4] = Math.floor(Math.random() * 2);
    randomArray[5] = Math.floor(Math.random() * 2);
    randomArray[6] = Math.floor(Math.random() * 2);
    randomArray[7] = Math.floor(Math.random() * 2);
    randomArray[8] = Math.floor(Math.random() * 2);
    trace(randomArray.join());
    if (randomArray[0] == 1) {
        TLBool = true;
        TL.gotoAndStop(2);
    } else {
        TLBool = false;
        TL.gotoAndStop(1);
    }
    if (randomArray[1] == 1) {
        TBool = true;
        T.gotoAndStop(2);
    } else {
        TBool = false;
        T.gotoAndStop(1);
    }
    if (randomArray[2] == 1) {
        TRBool = true;
        TR.gotoAndStop(2);
    } else {
        TRBool = false;
        TR.gotoAndStop(1);
    }
    if (randomArray[3] == 1) {
        CLBool = true;
        CL.gotoAndStop(2);
    } else {
        CLBool = false;
        CL.gotoAndStop(1);
    }
    if (randomArray[4] == 1) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
    if (randomArray[5] == 1) {
        CRBool = true;
        CR.gotoAndStop(2);
    } else {
        CRBool = false;
        CR.gotoAndStop(1);
    }
    if (randomArray[6] == 1) {
        BLBool = true;
        BL.gotoAndStop(2);
    } else {
        BLBool = false;
        BL.gotoAndStop(1);
    }
    if (randomArray[7] == 1) {
        BBool = true;
        B.gotoAndStop(2);
    } else {
        BBool = false;
        B.gotoAndStop(1);
    }
    if (randomArray[8] == 1) {
        BRBool = true;
        BR.gotoAndStop(2);
    } else {
        BRBool = false;
        BR.gotoAndStop(1);
    }
}

//Corners

function TLClick(event: MouseEvent) {
    if (!TLBool) {
        TLBool = true;
        TL.gotoAndStop(2);
    } else {
        TLBool = false;
        TL.gotoAndStop(1);
    }
    if (!CLBool) {
        CLBool = true;
        CL.gotoAndStop(2);
    } else {
        CLBool = false;
        CL.gotoAndStop(1);
    }
    if (!TBool) {
        TBool = true;
        T.gotoAndStop(2);
    } else {
        TBool = false;
        T.gotoAndStop(1);
    }
}


function TRClick(event: MouseEvent) {
    if (!TRBool) {
        TRBool = true;
        TR.gotoAndStop(2);
    } else {
        TRBool = false;
        TR.gotoAndStop(1);
    }
    if (!CRBool) {
        CRBool = true;
        CR.gotoAndStop(2);
    } else {
        CRBool = false;
        CR.gotoAndStop(1);
    }
    if (!TBool) {
        TBool = true;
        T.gotoAndStop(2);
    } else {
        TBool = false;
        T.gotoAndStop(1);
    }
}

function BRClick(event: MouseEvent) {
    if (!BRBool) {
        BRBool = true;
        BR.gotoAndStop(2);
    } else {
        BRBool = false;
        BR.gotoAndStop(1);
    }
    if (!CRBool) {
        CRBool = true;
        CR.gotoAndStop(2);
    } else {
        CRBool = false;
        CR.gotoAndStop(1);
    }
    if (!BBool) {
        BBool = true;
        B.gotoAndStop(2);
    } else {
        BBool = false;
        B.gotoAndStop(1);
    }
}

function BLClick(event: MouseEvent) {
    if (!BLBool) {
        BLBool = true;
        BL.gotoAndStop(2);
    } else {
        BLBool = false;
        BL.gotoAndStop(1);
    }
    if (!CLBool) {
        CLBool = true;
        CL.gotoAndStop(2);
    } else {
        CLBool = false;
        CL.gotoAndStop(1);
    }
    if (!BBool) {
        BBool = true;
        B.gotoAndStop(2);
    } else {
        BBool = false;
        B.gotoAndStop(1);
    }
}

//edges

function TClick(event: MouseEvent) {
    if (!TBool) {
        TBool = true;
        T.gotoAndStop(2);
    } else {
        TBool = false;
        T.gotoAndStop(1);
    }
    if (!TRBool) {
        TRBool = true;
        TR.gotoAndStop(2);
    } else {
        TRBool = false;
        TR.gotoAndStop(1);
    }
    if (!TLBool) {
        TLBool = true;
        TL.gotoAndStop(2);
    } else {
        TLBool = false;
        TL.gotoAndStop(1);
    }
    if (!CBool) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
}

function CLClick(event: MouseEvent) {
    if (!CLBool) {
        CLBool = true;
        CL.gotoAndStop(2);
    } else {
        CLBool = false;
        CL.gotoAndStop(1);
    }
    if (!TLBool) {
        TLBool = true;
        TL.gotoAndStop(2);
    } else {
        TLBool = false;
        TL.gotoAndStop(1);
    }
    if (!BLBool) {
        BLBool = true;
        BL.gotoAndStop(2);
    } else {
        BLBool = false;
        BL.gotoAndStop(1);
    }
    if (!CBool) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
}

function CRClick(event: MouseEvent) {
    if (!CRBool) {
        CRBool = true;
        CR.gotoAndStop(2);
    } else {
        CRBool = false;
        CR.gotoAndStop(1);
    }
    if (!TRBool) {
        TRBool = true;
        TR.gotoAndStop(2);
    } else {
        TRBool = false;
        TR.gotoAndStop(1);
    }
    if (!BRBool) {
        BRBool = true;
        BR.gotoAndStop(2);
    } else {
        BRBool = false;
        BR.gotoAndStop(1);
    }
    if (!CBool) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
}

function BClick(event: MouseEvent) {
    if (!BBool) {
        BBool = true;
        B.gotoAndStop(2);
    } else {
        BBool = false;
        B.gotoAndStop(1);
    }
    if (!BRBool) {
        BRBool = true;
        BR.gotoAndStop(2);
    } else {
        BRBool = false;
        BR.gotoAndStop(1);
    }
    if (!BLBool) {
        BLBool = true;
        BL.gotoAndStop(2);
    } else {
        BLBool = false;
        BL.gotoAndStop(1);
    }
    if (!CBool) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
}

//Center

function CClick(event: MouseEvent) {
    if (!CBool) {
        CBool = true;
        C.gotoAndStop(2);
    } else {
        CBool = false;
        C.gotoAndStop(1);
    }
    if (!TBool) {
        TBool = true;
        T.gotoAndStop(2);
    } else {
        TBool = false;
        T.gotoAndStop(1);
    }
    if (!CLBool) {
        CLBool = true;
        CL.gotoAndStop(2);
    } else {
        CLBool = false;
        CL.gotoAndStop(1);
    }
    if (!CRBool) {
        CRBool = true;
        CR.gotoAndStop(2);
    } else {
        CRBool = false;
        CR.gotoAndStop(1);
    }
    if (!BBool) {
        BBool = true;
        B.gotoAndStop(2);
    } else {
        BBool = false;
        B.gotoAndStop(1);
    }
}
问题来自这里:(第31行)

第12行:

startGenerate();
我想我可能从函数中得到了错误,这是不寻常的。TL、T、TR、CL、C、CR、BL、B和BR都是电影剪辑中的实例名,所以我知道这不是问题所在。我的flash项目只有一帧,我刚才说的电影剪辑是舞台上唯一的对象。我删除了startGenerate()函数,它工作得很好。我正在制作3x3版本的lights out。多谢各位

问题在于:

startGenerate();

var randomArray: Array = [];
在调用需要的函数之前,而不是之后,应该初始化随机数组。

问题在于:

startGenerate();

var randomArray: Array = [];
在调用需要的函数之前,而不是之后,应该初始化随机数组