I have 2 separate containers on my main stage, each of these contains numerous child MovieClips. One contains my enemies and the other contains a smaller representation of those enemies. The smaller enemies need to get a reference to the corresponding larger enemy position to set their own position to half of that value. This works by adding the following code to the small enemies class file for x, y and rotation:
this.x=MovieClip(this.parent.parent.getChildByName("enemyHolder")).getChildAt(myRef).x/2;
However I also need to access the larger enemies health variable but if I use the same approach in this manner:
this.health = MovieClip(this.parent.parent.getChildByName("enemyHolder")).getChildAt(myRef).myHealth;
I get the following error?
1119: Access of possibly undefined property myHealth through a reference with static type flash.display:DisplayObject.
I am declaring myHealth in the constructor function of the enemy class file and have tried setting it’s access modifier to public but still can’t access that variable.
Any help would be most appreciated!