0
我收到錯誤#1009,但我不知道爲什麼。我從線31得到的錯誤,而12以下是代碼:從函數中獲取錯誤1009?
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行)
function startGenerate() {
randomArray[0] = Math.floor(Math.random() * 2); //This is line 31
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);
}
}
和線路12:
startGenerate();
我想我可能會從函數中獲取錯誤,這是不尋常的。 TL,T,TR,CL,C,CR,BL,B和BR都是來自影片剪輯的實例名稱,所以我知道這不是問題。我的Flash項目只有一個框架,而我剛剛提到的電影剪輯是舞臺上唯一的對象。我刪除了startGenerate()函數,它工作得很好。我正在製作一個3x3版本的燈。謝謝。