2012-12-20 65 views
2

我使用一個數組的戰士和子彈錯誤#1063錯誤失配誤差是

package { 
    import flash.display.MovieClip; 
    import flash.events.Event; 

public class level extends MovieClip { 

    var fighters:Array; 
    var bullets:Array; 

    public function level() { 
     trace("level"); 
     addEventListener(Event.ENTER_FRAME, loop); 
     bullets=new Array(); 
     fighters=new Array(); 
    } 

    function loop(e:Event) { 
     if(numChildren<3) { 
      var f=new fighter(); 
      addChild(f); 
      // fighter spaWNS RANDOMLY 
      f.x=Math.random()*stage.stageWidth; 
      f.y=Math.random()*stage.stageHeight; 
      f.rotation=Math.random()*360; 
      fighters.push(f); 
     } 

     for(var bcount=bullets.length-1; bcount>=0; bcount--) { 
      bullets[bcount].update(); 
      if(bullets[bcount].parent==null) { 
       bullets.splice(bcount,1); 
       bcount--; 
      } 
     } 

     for(var count=fighters.length-1; count>=0; count--) { 

//**** error is here 
//**** there is a mismatch in the arguments with the fighter 

      fighters[count].update(); 

      for(bcount=bullets.length-1; bcount>=0; bcount--) { 
       if(fighters[count].hitTestObject(bullets[bcount])) { 
        fighters[count].health--; 
        removeChild(bullets[bcount]); 
        bullets.splice(bcount,1); 
       } 
      } 

      if(fighters[count].health<=0) { 
       removeChild(fighters[count]); 
       fighters.splice(count,1); 
      } 
     } 
    } 
} 

}

回答

0

錯誤#1063意味着你沒有通過必需的參數或通過超過預期。可能有關於錯誤的其他信息,您沒有發佈可能會有所幫助的錯誤,它很可能看起來像這樣:

ArgumentError:錯誤#1063:參數計數與類和函數不匹配。預計1,得到0

檢查update()函數的戰鬥機()對象,看看它是否需要設置了一個param。