0
我對動作相對比較陌生,我試圖選擇一個隨機選擇的障礙物來飛向我的玩家角色。我不斷收到錯誤1151:在命名空間內部與定義obstInstance存在衝突。我得到了同樣的錯誤三次。我認爲這是因爲我反覆分配相同的障礙實例新值(即使它在條件格式內)。任何幫助將不勝感激!ActionScript錯誤1151:隨機選擇障礙
this.addEventListener(Event.ENTER_FRAME, obstacleGenerator);
function obstacleGenerator(e:Event):void
{
trace("Obstacle Generator Initiated");
var obstacleSelector:uint=Math.ceil(Math.random()*4);
trace("Obstacle Number ", obstacleSelector);
if (obstacleSelector==1){
var obstInstance:Obj1 = new Obj1();
}
else if (obstacleSelector==2){
var obstInstance:Obj2 = new Obj2(); //error 1151
}
else if (obstacleSelector==3){
var obstInstance:Obj3 = new Obj3(); //error 1151
}
else if (obstacleSelector==4){
var obstInstance:Obj4 = new Obj4(); //error 1151
}
}