Key.IsDown Not Responding To Key Presses?
Feb 14, 2010
I'm following a simple tutorial on making a platformer, but I ran into a problem. This is the code I'm using in a player movie clip:
onClipEvent(enterFrame) {
if(this.character.hitTest(_root.bg.ground)==false) {
this._y+=_root.gravity;
[Code]....
When I press the keys, nothing happens, but if I replace the if statement with a 1 then the code executes fine.
View 1 Replies
Similar Posts:
Aug 5, 2009
I was just wondering what the difference between these two is.
View 1 Replies
Apr 12, 2009
In the actions of a movie clip,I want to use something like:
PHP Code:
if(Key.isDown(W)){
//do stuff
}
But,it does not take anything else than LEFT,RIGHT and some others.I even tried ASCII:
PHP Code:
if(Key.isDown(100))
{}
It doesn't work.Then how do we use keys like W,A,S,D?
View 1 Replies
Apr 1, 2011
I have several input text boxes all of which are activated by the use of the enter key. I only want the one the user is using to run its script when they press enter instead of the keylistener on all of them picking up when enter is pressed. I have tried
ActionScript Code:
listenForEnterObject = new Object();
listenForEnterObject.onKeyDown=function(){
[code]....
View 1 Replies
Jun 5, 2011
I want to have it to that when i press up on my keyboard, my ball will jump up, and if i keep holding it down, it will not jump again until up is released and re-pressed.How my code looks right now
Code:
if (Key.isDown(Key.UP))
{
speedy = -30;
}
my ball's instance name is fivepointstar.
View 1 Replies
Oct 5, 2006
I'm trying to add arrow key control to my image gallery to increment and decrement the image number, but if I go to another section and go back to the gallery, the incrementing is doubled, so that I step through the images by two's. If I repeat this, it always adds 1. Here's the code I have for the Arrow keys:
[Code]...
View 2 Replies
Sep 8, 2011
if (Key.isDown(Key.LEFT) && Math.abs(this["speed"+who])>0.3) {
_root["car"+who]._rotation -= _root.rotationStep2*(this["speed"+who]/_root.maxSpeed);
}
[code].....
View 3 Replies
Jul 28, 2009
so iv been using the Key.IsDown commands to change the yscale (of something), but i am at a loss at getting the yscale (of that something) back to the starting scale when the key is released.
View 3 Replies
Jan 3, 2010
I have a character with multiple animations by way of movieclips, and I'm trying to have it move using the Key.isDown function. Now, my character is moving correctly, but when the key is released, the animation keeps playing. I tried adding a stop command at the end of the walkcycle animation, but that just causes the character to stay frozen on the last frame of the cycle.
Here is the ActionScript Code:
onClipEvent(load) {
var direction = "left";
var speed = 2;
} onClipEvent(enterFrame) {
[Code] .....
View 3 Replies
Oct 19, 2010
I have a logic-sorta question about finding an alternative to an if/else statement that controls key.isDown detection.(NOTE: I am using senocular's KeyObject class, the utility found on his website senocular.com, that returns key.IsDown functionality to AS3)
typically in most game/character movement tutorials I see this:
Code: Select allif (key.isDown(Keyboard.RIGHT))
moveRight();
else if (key.isDown(Keyboard.LEFT))
[code]....
The problem im having with this code is the fact that theres an order it checks the keys due to the if/else statement.For example, if I was holding down the LEFT key and then simultaniously began holding down the RIGHT key, the RIGHT key's function would execute and override whatever the LEFT key's function was doing, since the RIGHT key is the first thing checked in the if/else statment.
The only work-around i can think of is making all the keys a single If statement, and a switch statement that controlls the movement. Which im having a lot of trouble getting to work at the moment...
View 1 Replies
Mar 23, 2010
I'm working on a game where movement is controlled with WASD, and other commands are controlled with YUIOHJKLNM<>. The problem I'm encountering occurs when pressing down certain combinations of three keys. For example, when I'm holding down J and M, the ASD keys won't work; only W will. The same applies to J and N, and K and <; W is the only key of the movement commands that will work.
There is nothing in my programming that I can see or find that is causing this error; I've performed several tests and managed to pretty much isolate the problem being something to do with the keycodes. Does actionscript 2.0 have some inherent issues with certain 3-key combinations being pressed?
View 6 Replies
Jun 16, 2011
How do I make it so that a key down function acts as a hard on/off switch, Instead of the momentary temporary toggle normally associated with "if Key.isdown"
Example: The "CONTROL" key is pressed, gotoAndPlay's an action, until the key is pressed again, which then gotoAndStop'S the action. Would I still use "if Key.isDown" or something else entirely.
View 8 Replies
Oct 9, 2002
How do i get a letter to work inside of a key.isDown action?
View 6 Replies
Feb 5, 2009
I'm working on a pretty neat interactive music remixing site where you remix a song, then interact with a music video to make some cool stuff happen. I saw a few related posts on here, but I've got a bit of a more specific problem. originally I had the controls set so that whenever you click the mouse on the background (which I set as one giant blank button), that it would load a movie clip and unload the previous one:
[Code]....
This has been working fine, although now I'm trying to change the overall controls to assign every key on the keyboard to load a particular movie clip at the mouse x,y when pressed AND to unload the movie clip when it is pressed again. I think I might be applying the code to the wrong portion (in a blank frame in the timeline, not as part of any button or movie clip). I had the code setup so that I wasn't getting any errors, but nothing is happening when pressing the key. I also don't have a start on how to tell if a key has already been pressed, to perform a second action when pressed again (to unload the assigned movie clip). Here's what I've got so far:
[Code]...
View 0 Replies
Aug 21, 2009
Trying to get my button to go to a particular frame in my timeline with this code:
festive_btn.addEventListener(MouseEvent.CLICK, goback);
function goback(event:MouseEvent):void{
gotoAndPlay("return_normal");
[code].....
View 3 Replies
May 10, 2010
A Flash program is connecting to WCF web service hosted on a server without anti-virus and without firewall and windows server 2003 64 bit environment.[code]...
View 2 Replies
Jul 23, 2011
I am noob in Flex/Actionscript so I have the code where compiler doesn't show error but code returns nothing.[code]...
View 4 Replies
Nov 13, 2004
im using this method to load movies and create transitions between them for my site.. I have read the technique thoroughly and im fairly sure the code and structure I have used is correct however the loadMovie function called from an embedded swf is not doing anything and I cant work out why..on the main timeline there is a container movie that the swf files are loaded into, the intro sequence is loaded through an action on frame 1:
_root.currMovie = "introsection";
container.loadMovie(_root.currMovie+".swf");
this works no worries.. but when the container is targeted from inside the introsection.swf movie nothing happens, this is the code used:_root.container.loadMovie(_root.currMovie+".swf")I have tried variations with this and nothing works.. the container movie has the correct instance name and the code works from the main timeline but not from within another swf.
View 12 Replies
Sep 16, 2006
My flv files won't run if I move the folder where I have all the contents. How do I fix this problem so that I can run the flv's no matter where the folder is? I know this isn't exactly an actionscript problem since I imported them directly to the library and from there to the stage,
View 1 Replies
Feb 9, 2009
In my main timeline, I have an image fade in and stop on frame 61. On Frame 61, the code below executes;
[AS]stop();
var placesXML:XML =
<places>
[code]....
View 2 Replies
Nov 15, 2005
I'm building up an image resize gallery, and I want to navigate using the left and right arrow keys on my keyboard. I've been trying to figure this out a while now, but I can't get it working. Here's my code:
[Code]...
View 4 Replies
Dec 23, 2010
Actionscript Code:
// button pressesupKey = 38;downKey = 40;leftKey = 37;rightKey = 39;focusKey = 65;attack1Key = 83;attack2Key = 68;bombKey = 81;autoAttack1Key = 87;autoAttack2Key
[Code].....
Rather than affecting one variable, one key press makes all the others true as well
View 2 Replies
Feb 8, 2009
I have recently been working on creating a game similar to the good ol' Asteroids game. So far, I have managed to create a very simple piece of code that rotates and moves my spacecraft according to the angle it is currently at. There are two problems with it, though:
1. I can't use two buttons at once--for example, to rotate and move forward. I'm sure there must be a better way to detect key presses. What's the best way to do it in AS3?
2. The way the whole thing works looks kind of jerky and stage. Another thing is, the spacecraft is constantly at an odd angle for no apparent reason.
Here it is ("sc" is my spacecraft movieclip):
var SC_speed:Number;
var SC_rotation:Number;
var SC_radians:Number;
SC_speed = SC_rotation = 0;
function keys(event:KeyboardEvent):void{
[Code] .....
View 0 Replies
Dec 7, 2009
im tryin to make this control the player(head) on stage by simply turning rght now but i can't get it to work...
also all the code for keypresses can be found in the player movieclip on the actions of frame 1
View 0 Replies
Dec 9, 2010
I have a really strange problem. I've made a custom class that listens for keyboard events such as key presses (I use it in order to navigate in an interface). When I test my file in Flash (using 'command'+'enter') all key presses work as they should. However, when I publish the file and starts the projector (or the swf for that matter) one key ('g') isn't doing what it should!
View 2 Replies
Sep 19, 2007
I set up some code to record key presses and specific chords. My problem is that I only want the keys to fire once when pressed. This is especially a problem when I require the user to hold CTRL + LEFT for an action.
The user experience is that I want users to hold down CTRL to enter a mode and then press the LEFT key as many times as needed. Currently, the CTRL trace and LEFT trace fire continuously. Is there a way to do a onKeyRelease?
Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.CONTROL)) {
[Code]....
View 1 Replies
Jun 19, 2009
When I say two keyboard presses, I'm thinking about a situation where I would need to detect both. Not a shift this or alt that or control third. I'm talking about Down + A or 5 + T. For instance: Ryu has an overhead attack that is used when both Down + MP are pressed. If I were to create a game, with ActionScript 3.0, is there a way for me to detect that both buttons were pressed at the same time?
View 5 Replies
Aug 15, 2004
I am creating a dancing game:
[URL]
I need to disable the keyboard after each key is pressed, so if the user presses the UP key until the character has finihsed doing the move no other key can be pressed.
View 4 Replies
Jul 19, 2011
In the keyboardEvent, the ENTER key is not responding.. why?.... any other option is there?
[Code]....
View 5 Replies
Dec 13, 2006
I have content in a scrollpane which I would like users to be able to drag (content is larger than the pane). There are also rollover areas in the content that are only accessable when scrolldrag is false (makes sense). So, I've set the scrollpane scrolldrag property to false until the user presses the Ctrl key:
//Listener for Ctrl key to allow drag
createEmptyMovieClip('_keyListener',999);
Key.addListener(_keyListener);
_keyListener.onKeyDown=function(){
if (Key.getCode() == 17) {
[Code]...
View 1 Replies