hello friends,
i am trying to make array “carWay” elements to be available in the “function enemy_car” but inspite of declaring it global with “public static var carWay:Array=new Array();” , i m unable to find a way where carWay array elements can be available in “function enemy_car” Where "Race2 "is my class name.Actually i need it to develop a game for Enemy AI.Following are the lines that are causing trouble. “RaceCall” is the function that will be call inside the required .fla file actionPanel.
public function RaceCall()
{
this.addEventListener(Event.ENTER_FRAME, gameloop);
enemy_car();
}
public function gameloop(event:Event)
{
if (lastTime==0)
lastTime=getTimer();
var diff:int=getTimer()-lastTime;
lastTime+=diff;
moveCharacter(diff);
}
public function moveCharacter(timeDiff:int)
{
Race2.carPosition=new Point(gamesprite.car.x,gamesprite.car.y)
Race2.carWay.push(carPosition);
}
public function enemy_car()
{
trace(“carWay.length=”+Race2.carWay.length);
}