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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running in a flash game

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to develop a flash game where the user presses 2 keys (such as left and right arrows) to make a character run. The quicker you press the keys the faster the character runs. Does anyone know how I would go about doing this with Action Script?

Many thanks in advance
 
You could do this with a clip event attached to your character.

I tried this out with a clip which had three frames in its animation cycle with the following frame labels - left foot forward ("leftFoot"), right foot forward ("rightFoot") and neither ("standing"). Put a stop(); action in the first frame.

ClipEvent (keyDown) {
if (Key.getCode() == Key.RIGHT) {
this.gotoAndStop("rightFoot");
} else if (Key.getCode() == Key.LEFT) {
this.gotoAndStop("leftFoot");
} else {
this.gotoAndStop("standing");
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top