在动作脚本3,定时器中输入#1009错误

时间:2016-06-24 01:57:15

标签: actionscript-3 timer

我在动作脚本3中收到错误,这与我的计时器有关。这是错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at RECOVER_pacmangame_fla::MainTimeline/doCheck()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

涉及Timer的代码如下:

var pelletcount:int
pelletcount == 0

/*Code that checks pellet collision, if collision is true,
pellets become invisible.*/

my_mc.addEventListener( Event.ENTER_FRAME, handleCollision)
function handleCollision(e:Event):void
{ 
 if (m_pel0.hitTestPoint (my_mc.x, my_mc.y, false)) 
    {m_pel0.visible = false, pelletcount = 1;} 
else 
    {;} 
}

var checkTimer2:Timer = new Timer(20);
checkTimer2.addEventListener(TimerEvent.TIMER, pelletCheck);
checkTimer2.start();

function pelletCheck(e:Event):void {
    if(pelletcount == 1){

        gotoAndStop(42);
    }

}

0 个答案:

没有答案