这是一个非常基本的问题(我对 AS3 有点陌生)但是你在 AS3 中导入什么来允许“addEventListener”?我犯了学习如何在时间轴上编程的错误,现在这个跳转有点棘手。
编辑:这是我的代码(有无数错误,但我只想修复 addEventListener ):
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class TheGameItself extends MovieClip
{
public static function startit(stage)
{
addEventListener(Event.ENTER_FRAME, movecat);
addEventListener(Event.ENTER_FRAME, spawnanimal);
var myDelay:Timer = new Timer(100);
myDelay.addEventListener(TimerEvent.TIMER, showMessage);
myDelay.start();
var myMouse = 0;
var speed = 1;
var wave = 1;
var score = 0;
var rnum = 0;
var moveornot = false;
}
function showMessage(event:TimerEvent):void
{
moveornot = true;
}
function movecat(event)
{
if ((mouseY > 40) && (mouseY < 330))
{
cat.y = mouseY;
}
}
function spawnanimal(event)
{
var rnum = Math.floor(Math.random() * ((100 / wave) - 1 + 1)) + 1;
if (rnum == 5)
{
myMouse = new mouse();
myMouse.x = 0;
myMouse.y = Math.floor(Math.random() * (350 - 45 + 1)) + 45;
addChild(myMouse);
for (var i:int = 0; i < 10000; i++)
{
if (moveornot == true)
{
myMouse[i].y += speed * 100;
moveornot == false;
if ((myMouse.x == 500) || (myMouse.hitTestObject(cat)))
{
myMouse.visible = false;
}
}
}
}
}
}
}