NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page Movement + Rotation In Flash

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-04-2006, 01:14 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



Movement + Rotation In Flash


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 Code:
onClipEvent (load) {
thrust 1//sets speed
decay 1;//sets strenght not needed at the moment
????: NamePros.com http://www.namepros.com/webmaster-tutorials/173475-movement-rotation-in-flash.html
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
????: NamePros.com http://www.namepros.com/showthread.php?t=173475
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.
asgsoft is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mr.Spot Freelance flash designer(Cool Flash Site) spot For Sale / Advertising Board 0 09-27-2005 09:24 PM
Protect your flash files from hotlinking - specially for arcade sites! Jim_Westergren CODE 15 08-29-2005 01:42 PM
REQUEST - Flash intro, banners and other future projects gRF For Sale / Advertising Board 0 07-29-2005 12:49 AM
Flash Deadly Sins (that can kill your web business) abacomedia Graphic Design / Flash 2 06-26-2004 09:32 PM
Using Music on your Site - WAV, MP3, MIDI, Flash? abacomedia Web Design Discussion 1 05-20-2004 01:04 PM

 
All times are GMT -7. The time now is 12:57 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger