Could anyone give me some tips to do the port/conversion?

this is a simple as2 file which moves a car (rotates wheels, gas, etc.)

the 2 movieclips being used are car and wheel

```
//www.swfspot.com
//movement speed of the car
var speed=2;
//Compute pi/180. The value is used twice for each frame, so storing it as a variable saves CPU
var piOver180=Math.PI/180;
onEnterFrame=function(){
//If the left or right keys are down, rotate the wheels
if(Key.isDown(Key.LEFT)){
car.leftwheel._rotation=Math.min(24,Math.max(-24,car.leftwheel._rotation-5));
car.rightwheel._rotation=Math.min(24,Math.max(-24,car.rightwheel._rotation-5));
}
if(Key.isDown(Key.RIGHT)){
car.leftwheel._rotation=Math.min(24,Math.max(-24,car.leftwheel._rotation+4));
car.rightwheel._rotation=Math.min(24,Math.max(-24,car.rightwheel._rotation+4));
}
//check if the up or down keys are pressed
if(Key.isDown(Key.UP)||Key.isDown(Key.DOWN)){
//if the up key is down, the car moves forward
if(Key.isDown(Key.UP)){
carDirection=1;
//otherwise move the car backwards
}else{carDirection=-1;}
//default turning to false
turning=0;
//if the left or right keys are pressed, set turning to true and rotate the car
if(Key.isDown(Key.LEFT)){
turning=1;
car._rotation-=5*carDirection;
}
else if(Key.isDown(Key.RIGHT)){
turning=1;
car._rotation+=5*carDirection;
}
//if the car isn't turning, reset the rotation of the tires
if(!turning){
car.leftwheel._rotation=0;
car.rightwheel._rotation=0;
}
//move the car. The y coordinate plane is flipped in flash, so we use - instead of +
car._x+=Math.sin(car._rotation*piOver180)*speed*carDirection;
car._y-=Math.cos(car._rotation*piOver180)*(speed)*carDirection;
}
}
```

how does rotation work in as3?

can math.pi still be used?

thank you

-joey

so far i hav this: but its not working at all:

```
package {
//www.swfspot.com
import flash.events.KeyboardEvent;
import flash.display.MovieClip; //
var key_left:Boolean = false;
var key_up:Boolean = false;
var key_right:Boolean = false;
var key_down:Boolean = false;
//movement speed of the car
private var speed:Number =2;
//Compute pi/180. The value is used twice for each frame, so storing it as a variable saves CPU
var myangle:Number = a * Math.PI / 180;
addEventListener(Event.ENTER_FRAME, main);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);
//If the left or right keys are down, rotate the wheels
function KeyDown(event:KeyboardEvent){
if(event.keyCode == 37){ //checks if left arrowkey is pressed.
key_left = true;
car.leftwheel.rotation=Math.min(24,Math.max(-24,car.leftwheel.rotation-5));
car.rightwheel.rotation=Math.min(24,Math.max(-24,car.rightwheel.rotation-5));
}
if(Keyboard.isDown(Keyboard.RIGHT)){
car.leftwheel.rotation=Math.min(24,Math.max(-24,car.leftwheel.rotation+4));
car.rightwheel.rotation=Math.min(24,Math.max(-24,car.rightwheel.rotation+4));
}
//check if the up or down keys are pressed
if(Keyboard.isDown(Keyboard.UP)||Keyboard.isDown(Keyboard.DOWN)){
//if the up key is down, the car moves forward
if(Keyboard.isDown(Keyboard.UP)){
carDirection=1;
//otherwise move the car backwards
}else{carDirection=-1;}
//default turning to false
turning=0;
//if the left or right keys are pressed, set turning to true and rotate the car
if(Keyboard.isDown(Keyboard.LEFT)){
turning=1;
car.rotation-=5*carDirection;
}
else if(Keyboard.isDown(Keyboard.RIGHT)){
turning=1;
car.rotation+=5*carDirection;
}
//if the car isn't turning, reset the rotation of the tires
if(!turning){
car.leftwheel.rotation=0;
car.rightwheel.rotation=0;
}
//move the car. The y coordinate plane is flipped in flash, so we use - instead of +
car.x+=Math.sin(car.rotation*piOver180)*speed*carDirection;
car.y-=Math.cos(car.rotation*piOver180)*(speed)*carDirection;
}
}
}
```

are you trying to make it a class?

idk… this is my first as3

the only thing this flash is is the car movement

so thats all the code

did i do it wrong?

Heres what i did do:

movieclips in library and on stage in the .fla

set doc class: control(.as) and then put that code in control.as

I would use the movieclip-class instead of the doc class (you might need this one later)

If you look at the linkage properties of your movieclip you can see the name of the class, just create a .as file with the same name and try to build up your code from there.

In my opinion it would be easier to build it up from scratch instead of converting the whole as2 script. I think the learning effect would be bigger that way (maybe just for me!).

I would start with simple movement (forward/backward) of the car and then add more and more stuff to your movieclip class.

hope that helps

Carlo