Welcome To VertexTemplates.com Flash MX 2004 Tutorials Area - Keyboard Controlled Movement (Part 2) |
![]() |
|||
Flash MX 2004 Keyboard Controlled Movement (Part 2) Tutorial.
Author: Akash Goel Reprinted from www.spoono.com Introduction
// sets our variables movement = 5; movieWidth = 550; movieHeight = 300; ballRadius = this._width / 2; } onClipEvent (enterFrame) { // continually looks for the edges of our ball ballBounds = this.getBounds(_root); // looks for the left arrow key being pressed if (Key.isDown( 37 )) { if (ballBounds.xMin<= 0) { this._x = 0 + ballRadius + movement; } this._x = this._x - movement; } // looks for the right arrow key being pressed if (Key.isDown( 39 )) { if (ballBounds.xMax >= movieWidth) { this._x = movieWidth - ballRadius - movement; } this._x = this._x + movement; } // looks for the up arrow key being pressed if (Key.isDown( 38 )) { if (ballBounds.yMin <= 0) { this._y = 0 + ballRadius + movement; } this._y = this._y - movement; } // looks for the down arrow key being pressed if (Key.isDown( 40 )) { if (ballBounds.yMax >= movieHeight) { this._y = movieHeight - ballRadius - movement; } this._y = this._y + movement; } } Next In part three of our series we will look at screen wrapping. Click here to Go on to the next Part of Keyboard Controlled Movement> |
||||
| Home Web Templates Affiliate Program Template Tour Custom Website Design Tutorials Articles Contact Us FAQ's All Rights Reserved © 2005 VertexTemplates.com Read our Terms Of Use and Privacy Policy Flash Templates by Metamorphosis Design |
||||