jeudi 23 juin 2016

Type #1009 Error in actionscript 3, Timer

I'm getting an error in actionscript 3 and it's something to do with my Timer. Here is the Error:

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()

My code involving the Timer is as follows:

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);
    }

}

Aucun commentaire:

Enregistrer un commentaire