0
获取错误1061:调用可能未定义的方法通过静态类型flash.events:TimerEvent的引用停止。我的as3课上有 。我刚刚开始学习as3,并不知道导致错误的原因。代码:带定时器的as3错误1063
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class game extends MovieClip
{
//assign types to var names
//allows values and variables to be acessed in methods
public var as1:astroid;//astroids
public var ship1:ship;//ship
public var timer:Timer;
public function game()
{
//astroid
as1=new astroid();
addChild(as1);
//ship
ship1=new ship();
addChild(ship1);
//timer
timer=new Timer(25);//every n frames
timer.addEventListener(TimerEvent.TIMER, onTick);//attach function to timer
timer.start();//start timer
}
public function onTick(timer:TimerEvent):void
{
//animate astroid
as1.moveDown();
//move ship
ship1.x = mouseX;
ship1.y = mouseY;
if(ship1.hitTestObject(as1))
{
timer.stop();//error on this line!
}
}
}
}