Flash development

Moderators: None (Apply to moderate this forum)
Number of threads: 221
Number of posts: 377

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Keyboard Help Posted by ian_boden on 12 Aug 2006 at 4:12 PM
I have a script which uses the keyboard to move through a maze which is stored in a mysql database accessed through php pages. It works out if a move is possible based on the map.
It works fine most of the time however if you hold down a direction button and move towards a wall that is not adjacent (ie you have a run up) then it will let you run through walls, how many wall squares it lets you run through is random.

This is achieved through the following code:

var watching:Boolean = true;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if(watching==true)
{
watching = false;
if (Key.getCode() == Key.LEFT) {
moveLeft();
}
else if (Key.getCode() == Key.RIGHT) {
moveRight();
}
else if (Key.getCode() == Key.UP) {
moveUp();
}
else if (Key.getCode() == Key.DOWN) {
moveDown();
}
watching = true;
}
};
Key.addListener(keyListener);

The moveUp,moveDown etc functions check to see if a square is accesable and moves if it is. Using the watching variable as a guard seems to make no difference so I'm rather confused. If anyone has any ideas where the problem might be then please let me know.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.