I'm writing a "Chicken and Eggs"-style game. I get an error in Main.as, line 160, that says "1119: Access of possibly undefined property ENTER_FRAME through a reference with static type Class." Line 160 is:

basket_mc.removeEventListener(KeyboardEvent.ENTER_FRAME,moveBasket);

basket_mc is a MovieClip of the basket used to collect falling eggs. moveBasket is a function to move the basket.

Any suggestions on how to get the program to recognize ENTER_FRAME as defined would be greatly appreciated.

I'm writing a "Chicken and Eggs"-style game. I get an error in Main.as, line 160, that says "1119: Access of possibly undefined property ENTER_FRAME through a reference with static type Class." Line 160 is:

basket_mc.removeEventListener(KeyboardEvent.ENTER_FRAME,moveBasket);

basket_mc is a MovieClip of the basket used to collect falling eggs. moveBasket is a function to move the basket.

Any suggestions on how to get the program to recognize ENTER_FRAME as defined would be greatly appreciated.

The ENTER_FRAME event is a part of the Event class (flash.events.Event) not the KeyboardEvent class (flash.events.KeyboardEvent).

So to fix the bug you're having, you need to change your line of code to:

basket_mc.removeEventListener(Event.ENTER_FRAME, moveBasket);

Looking at the code in your .zip, I can see that you know what you're doing and are comfortable with adding and removing event listeners, so I won't explain further...It looks like you just made a simple syntax error in your gameOver() function when removing the ENTER_FRAME event listener for your basket_mc!!

Cheers for now,
Jas.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.