• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need help with a Stupid Question

New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

471

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

sort of, how do I do that exactly, thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

LATEST

thanks I figured out how to do it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines