Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

interactivity using keys

Status
Not open for further replies.

ron997

Vendor
Dec 16, 2007
2
0
0
GB
Hi

I am trying to get a object to move using the keys in flash 8. I am trying to get the objects code in the time line.
This is the code im using

plane.onEnterFrame=function(){
if (Key.isDown(Key.RIGHT)){
plane._rotation +=2
}
}
if (Key.isDown(Key.LEFT)){
plane._rotation -=2

}
if (Key.isDown(Key.UP)){
plane._rotation +=2
}

if (Key.isDown(Key.DOWN)){
plane._rotation -=2
}



plane._y+= Math.cos(plane._rotation*Math.PI/180)*-2

plane._x+= Math.sin(plane._rotation*Math.PI/180)*2


I really appericate all the help

thank you

ron997
 
Code:
plane.onEnterFrame = function() {
	if (Key.isDown(Key.RIGHT)) {
		this._rotation += 2;
	} else if (Key.isDown(Key.LEFT)) {
		this._rotation -= 2;
	} else if (Key.isDown(Key.UP)) {
		this._rotation += 2;
	} else if (Key.isDown(Key.DOWN)) {
		this._rotation -= 2;
	}
	this._y += Math.cos(this._rotation*Math.PI/180)*-2;
	this._x += Math.sin(this._rotation*Math.PI/180)*2;
};

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top