下一塊AS3代碼爲紙牌遊戲寫的,我很好奇,爲什麼我得到錯誤#1010?調試錯誤#1010 ActionScript 3的
var backHands:Array = new Array();
var numberOfPlayingCards = 0;
function initBackHands(){
var i:int;
var j:int;
for(j=1;j<4;j++){
var newBacks:Array = new Array();
for(i=0;i<13;i++){
newBacks[i] = new CBack();
addChild(newBacks[i]);
}
backHands[j-1] = newBacks;
}
}
function removeBack(p:int){
try{
if(position[p]>0){
var index:int = (numberOfPlayingCards/4);
index = 12- index;
if(contains(backHands[position[p] - 1][index])){
removeChild(backHands[position[p] - 1][index]);
}
}
}catch(error:Error){
trace("playCard= NOPC: "+ numberOfPlayingCards +
" index: " + index +
" position: " + (position[p] - 1) +
" err: "+ error);
}
numberOfPlayingCards ++;
}
,這是錯誤日誌:
playCard= NOPC: 0 index: 12 position: 1 err: TypeError: Error #1010
playCard= NOPC: 1 index: 12 position: 0 err: TypeError: Error #1010
playCard= NOPC: 1 index: 12 position: 2 err: TypeError: Error #1010
playCard= NOPC: 2 index: 12 position: 0 err: TypeError: Error #1010
playCard= NOPC: 2 index: 12 position: 1 err: TypeError: Error #1010
playCard= NOPC: 3 index: 12 position: 2 err: TypeError: Error #1010
playCard= NOPC: 4 index: 11 position: 2 err: TypeError: Error #1010
playCard= NOPC: 5 index: 11 position: 1 err: TypeError: Error #1010
playCard= NOPC: 6 index: 11 position: 0 err: TypeError: Error #1010
playCard= NOPC: 8 index: 10 position: 0 err: TypeError: Error #1010
playCard= NOPC: 10 index: 10 position: 2 err: TypeError: Error #1010
playCard= NOPC: 11 index: 10 position: 1 err: TypeError: Error #1010
playCard= NOPC: 12 index: 9 position: 0 err: TypeError: Error #1010
的問題是哪一行,使錯誤,爲什麼當我們調用removeBack功能每圈的NOPC沒有定期增加。
請注意,p是0和3之間的整數,並且位置是包含每一個玩家的位置大小爲4的整數的陣列(0,1,2或3)
很顯然它不能得到backHands [position [p] - 1]的任何數組或對象值,並且不能得到[index] –
@Bolzano,謝謝你的回答,但爲什麼呢?正如你可以在initBackHands()函數中看到的那樣,我初始化bakcHands數組 – csuo