但是当我尝试初始化kogelCheck时,我在spawnKogel的末尾得到了标题中的错误。这是我的代码:
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.media.Sound;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class amateurodius extends MovieClip
{
public var schip:ruimteschip = new ruimteschip();
public var Kogel = new Bullet();
var sound = new lazor();
var BGM = new Muziek();
var backdrop = new background();
var shootAllow:Boolean = true;
public function amateurodius()
{
addEventListener(Event.ADDED_TO_STAGE, initialize);
addEventListener(Event.ENTER_FRAME, vijandmaken);
stage.addEventListener(KeyboardEvent.KEY_DOWN, spawnKogel);
addEventListener(Event.ENTER_FRAME, kogelCheck);
Mouse.hide();
}
function initialize(e:Event)
{
addChild(backdrop);
addChild(schip);
BGM.play();
}
function spawnKogel(e:KeyboardEvent):void
{
if (shootAllow == true)
{
if (e.keyCode == Keyboard.SPACE)
{
addChild(Kogel);
Kogel.x = schip.x;
Kogel.y = schip.y;
sound.play();
shootAllow = false;
kogelCheck (e:Event);
}
}
}
function kogelCheck (e:Event)
{
if (Kogel.x < -30)
{
shootAllow == true;
}
else
{
shootAllow == false;
}
}
答案 0 :(得分:1)
在致电kogelCheck
时删除活动类型:
// Just passing on the event, doesn't need type declaration
kogelCheck (e);