Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Movement + Rotation In Flash

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch
Have you seen these flash space games where you can move and rotate a spaceship. well here is how to do it.

1- Load up flash mx and set the document size to 550 by 400. to do this go to modify>document.

2- create a spaceship what ever you want it to be.

3- select it and press on F8 select movieclip and the press ok.
Press on the spaceship now and load up the actions panel by going to windows>actions. make sure it says Actions-Movie clip not Actions-frame.
add the following in the actions box:
PHP:
onClipEvent (load) {
thrust = 1; //sets speed
decay = 1;//sets strenght not needed at the moment
maxSpeed = 15;//maximum speed
}
onClipEvent (enterFrame) {

if (Key.isDown(Key.RIGHT)) { //if right button is down
_rotation += 10; //rotate 10 degreese clockwise
}
if (Key.isDown(Key.LEFT)) { //if left button is down
_rotation -= 10; //rotate 10 degreese anti-clockwise
}
if (Key.isDown(Key.UP)) {//if up button is down
xSpeed += thrust*Math.sin(_rotation*(Math.PI/180));
ySpeed += thrust*Math.cos(_rotation*(Math.PI/180));

} else {
xSpeed *= decay;
ySpeed *= decay; //slow down

}
speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed));
if (speed>maxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
_y -= ySpeed;
_x += xSpeed;

//make the ship come back on screen if it goes out of view
if (_y<0) {
_y = 400; // document height
}
if (_y>400) {
_y = 0;
}
if (_x<0) {
_x = 550; //document width
}
if (_x>550) {
_x = 0;
}
}
test the movie by clicking control+ enter
That should do the job neatly. If you have any problems or errors comming up please do not hesitate to contact me.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back