I need to get access to a variable from another class and I keep getting error '1119: Access of possibly undefined property enemyList through a reference with static type Class.' I can't see what I do wrong since my variable is made 'public' and 'static'.
class where the variable is made.
package classes.enemy
{
imports ...
public class Enemy extends MovieClip
{
public static var enemyList:Array = new Array(); **
var speed:Number;
public function initialize()
{
var stageReff:Stage = this.stage as Stage;
addEventListener("enterFrame", enterFrame);
}
public function Enemy()
{
enemyList.push(this); **
this.x = 700;
this.y = Math.random()*200 + 50;
speed = Math.random()*5 + 5;
}
//code
}
}
class that needs access to the variable
package classes.ship
{
imports ...
public class Bullet extends MovieClip
{
var speed:Number;
public function initialize()
{
var stageReff:Stage = this.stage as Stage;
stage.addEventListener("enterFrame", enterFrame);
}
//code
function enterFrame(e:Event):void
{
this.x += speed;
trace(enemy.enemyList); **
}
}
}
Putted '**' behind the lines where the problem occurs and where the variable is made, just to make it clear.
Classes are in different folders (classes > enemy & classes > ship), don't know if that has anything to do with it.
Thanks in advance.