Skip to main content
Known Participant
September 8, 2010
Question

Need help with a Stupid Question

  • September 8, 2010
  • 1 reply
  • 537 views

Hi, this is probably an easy question for someone who is in the know, but anyway I'm trying to communicate between 2 different classes using a getter in a class, but when I call the getter to get a value I get an error. Heres the code-

//THE PLAYER CLASS

public function get _playerX():Number

{

return this.x;

}

public function get _playerY():Number

{

return this.y;

}



//ENEMY CLASS

private function EnemyAi(){

thePlayerX = Player._playerX;

thePlayerY = Player._playerY;

}



I get this error:

1119: Access of possibly undefined property _playerX through a reference with static type Class.

This topic has been closed for replies.

1 reply

Known Participant
September 8, 2010

Looks to me like flash thinks you're trying to access a static Player class property rather than the property of the Player instance you've instantiated...

I presume you have a Main class that creates instance of these child classes?

You need to pass a reference to the Player class into the Enemy constructor and use that reference to get the property you are after. Does that make sense?

Known Participant
September 8, 2010

sort of, how do I do that exactly, thanks

Known Participant
September 8, 2010

thanks I figured out how to do it.