0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Daria Shmaria
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.