AS3 Error: Access of undefined property Event

202 Views Asked by At

I'm making a game in Flash CS4 using AS3 and I've been trying to make a Play button that works. I already know how to make it work but while debugging I always get "Access of undefined property Event" in compiler errors.

Here's my code:

// imports
import flash.events.Event;
import flash.events.MouseEvent;

// code
stop();

pbtn.addEventListener(EVENT.CLICK, startPlay);

function startPlay(event:MouseEvent):void
{
    gotoAndStop(2);
}

I already set the instance name of the button to "pbtn" so it can't be that. I tried both MouseEvent and just Event for the startPlay() function.

I know this must be a really dumb question but I just can't manage to fix this.

1

There are 1 best solutions below

0
Ali Nabeel On

pbtn.addEventListener(EVENT.CLICK, startPlay);
Just change that line to this
pbtn.addEventListener(MouseEvent.CLICK, startPlay);
And its case sensitive so don't change any letter case