Clock Crew

Community => Flash & Flash Accessories => Topic farted by: Bong Clock on November 30, 2009, 08:40:59 PM

Title: ActionScipt Help
Post by: Bong Clock on November 30, 2009, 08:40:59 PM
I have a movie clip that rotates with the left and right buttons and I'd like it to move it's relative forward and backward when up and down are pressed. I remember being able to do it but I just can't remember how.
Title: ActionScipt Help
Post by: TapedeckClock on November 30, 2009, 08:48:43 PM
hey its you!
Title: ActionScipt Help
Post by: AmberArachnidClock on November 30, 2009, 09:08:32 PM
its trigonometry. I can't remember exactly.
Title: ActionScipt Help
Post by: BootClock on November 30, 2009, 10:21:52 PM
Assuming AS2:

if(Key.isDown(Key.UP)) {
_x += Math.cos(_rotation/180*Math.PI)*spd;
_y += Math.sin(_rotation/180*Math.PI)*spd;
}
if(Key.isDown(Key.DOWN)) {
_x -= Math.cos(_rotation/180*Math.PI)*Rspd;
_y -= Math.sin(_rotation/180*Math.PI)*Rspd;
}

I didn't check it but it should work, spd is a variable for speed and Rspd is a variable for reverse speed.