how can i fix this, "ArgumentError: Error #1063: Argument count mismatch"

how can i fix this, "ArgumentError: Error #1063: Argument count mismatch"

我一直在研究这段代码,但我不知道该怎么做。 这是我要修复的代码:

stage.addEventListener(KeyboardEvent.KEY_DOWN, detectKey);

 function detectKey(e:KeyboardEvent):void {
 // space: shoot
 if (e.keyCode == 32) {
    shootBullet();
 }
}



stage.addEventListener(KeyboardEvent.KEY_DOWN, shootBullet);

function shootBullet():void{
 var bulletSpeed:Number = 80;
 var bullet:Rapid = new Rapid();
 stage.addChild(bullet);
 bullet.x = mini.x
 bullet.y = mini.y - 20
 var gameplay:Timer = new Timer(200);
 gameplay.start();
 gameplay.addEventListener(TimerEvent.TIMER, moveBullet);
 function moveBullet(e:TimerEvent):void{
     bullet.y -= bulletSpeed;
    if(bullet.y > stage.stageHeight + bullet.height){
         stage.removeChild(bullet);
 }
 }
}

stage.addEventListener(KeyboardEvent.KEY_UP, stoptimer);

function stoptimer():void{

var end:Timer = new Timer(500);
end.stop();
end.removeEventListener(TimerEvent.TIMER, remove);
function remove(e:TimerEvent):void {
    shootBullet();
}
}

它应该做的是当我按住空格键时,它会一直射击直到我松开。但我不断收到:

"ArgumentError: Error #1063: Argument count mismatch on hell_fla::MainTimeline/shootBullet(). Expected 0, got 1.

ArgumentError: Error #1063: Argument count mismatch on hell_fla::MainTimeline/stoptimer(). Expected 0, got 1."

有人可以帮助我吗?谢谢

"What it's suppose to do is when I hold down spacebar, it will keep shooting until I let go..."

最好使用 Enter_frame 事件而不是 Timer 事件来实现这种移动。

尝试这样的事情:

//#1 Add Vars

var bulletSpeed:Number = 80;
var bullet:Rapid;
var gameplay:Timer;


//#2 Add Listeners

//stage.addEventListener(KeyboardEvent.KEY_DOWN, shootBullet); //causes error
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectKey); //better way


//#3 Add Functions

function detectKey(e:KeyboardEvent):void 
{
    // space: shoot
    if (e.keyCode == 32) { shootBullet(); }
}

function shootBullet():void
{
    bullet = new Rapid();
    stage.addChild(bullet);
    bullet.x = mini.x;
    bullet.y = mini.y - 20;

    // instead of gameplay timer setting up, just use :
    // each unique NEW bullet will follow instruction in "moveBullet"
    bullet.addEventListener(Event.ENTER_FRAME, moveBullet);

}

function moveBullet(evt:Event):void
{
    evt.currentTarget.y -= bulletSpeed;
    if(evt.currentTarget.y > stage.stageHeight + evt.currentTarget.height)
    {
         stage.removeChild(evt.currentTarget as DisplayObject);
    }
}