# Stolen Data!

**URL:** <https://forum.kirupa.com/t/stolen-data/316026>\
**Category:** flash\
**Created:** [November 10, 2010, 4:04pm UTC](https://forum.kirupa.com/t/stolen-data/316026 "2010-11-10T16:04:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scoots1m](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@scoots1m](https://forum.kirupa.com/u/scoots1m)\
**Post date:** [November 10, 2010, 4:04pm UTC](https://forum.kirupa.com/t/stolen-data/316026/1 "2010-11-10T16:04:02Z")

</div>

Hello!

I’m in the process of creating a simple AI for a car within a game writen in AS3, I’m not entierly new to AS3, but i’m not that experienced with it either.

I’ve written a function that spawns cars randomly from the stage, here it is:

```auto
function SpawnCar(XPos : Number, YPos : Number, arrayIndex : Number) : void
{
 //create a car, and pass it the current and next path
trace("Creating a Car @: "+XPos+" : " +YPos);
 
 var car : Car = new Car();
 addChild(car);
 car.SetCurrentPath(centralPathArray[0]);//set the current path 
 car.SetNextPath(centralPathArray[1]);//set the next path 
 car.x = XPos;
 car.y = YPos;
 
 currentCars++;
 
}

```

That all works fine, its within the car object that has just been created, and had its path’s set that the issue arises.

These are the functions that are called from the code above:

```auto
function SetCurrentPath(path : Path) : void
{
 currentPath = path;
 trace(currentPath.x);
}
function SetNextPath(path : Path) : void
{
 nextPath = path;
 trace(nextPath.x);
}

```

The output so far is fine:

**Creating a Car @: 140 : 250**  
**405.95**  
**140**

However when the enterFrameHandler is called, the output shows the values of both as 0, and they should be the same as the output above.  
This is a royal pain as there are no other lines of code anywhere that seem to be removing or changing the values of the nextPath and currentPath variables.

Have i missed something here with AS3?

_Thanks._

Here is the eventlistener Code if it helps:

```auto
this.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
function enterFrameHandler(e:Event):void 
{
 //need to rotate the car to face the nextPath
 trace(nextPoint.x);
 trace(currentPoint,x);
 
 //move the car forwards
 carAngle = this.rotation*Math.PI/180;
 this.xSpeed = Math.cos(carAngle)*carSpeed;
 this.ySpeed = Math.sin(carAngle)*carSpeed;
 this.x += this.xSpeed;
 this.y += this.ySpeed;
}

```
