ActionScript 3.0 :: Detecting Multiple Keys Pressed Without Bugs?

Nov 1, 2010

I have it like this so far:

ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyReleased);
public function KeyPressed(event:KeyboardEvent):void

[Code]....

and so far it works good, except when I press shift. If I'm holding the left or right arrow key and then I press shift, the object stops moving and doesn't do anything. However, if I release the arrow key and THEN press and hold shift, it works perfectly. How can I make it so that I can press shift while I'm holding the arrow key and still have it work?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Detecting Two Keys Pressed Together?

Aug 7, 2009

How do you detect when to keys are pressed together. For example, if I press W and E together, I want something to happen. How do I do that?

View 5 Replies

ActionScript 3.0 :: Detecting Keys Pressed?

Jun 15, 2011

Im unclear why this code is not working? What am i doing wrong?

ActionScript Code:
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;

[code].....

View 6 Replies

IDE :: Getting Responsive Keyboard Movement - Multiple Keys Pressed

Feb 16, 2010

Im having a problem getting responsive keyboard movement. I have a key_up listener which fails to trigger when 3 keys are down. E.g. Imagine up and right keys are being pressed to move up + right. The user wants to change to moving up + left. The user presses the left key before lifting thg right key. I have a key_up listener to detect when a key is no longer being pressed. However in this scenario it fails to trigger when 3 keys are pressed. Even in this online example, there is the same problem, look how unresponsive it is when chaging from up right to up left really quickly. [URL]

[Code]...

View 2 Replies

ActionScript 1/2 :: Keys Pressed Or Not Pressed?

Dec 6, 2010

I am struggling a bit with keys on the keyboards controlling a movieclip to happen.Ive got a person moving when pressing right and left, and a movieclip with three frames: First frame is a movieclip with the person standing still, looking bored. The second frame is the person moving right, and the third frame is the person moving left.This is the code that Ive inserted into the persons actions on scene1:

if (Key.isDown(Key.RIGHT)) {_x += speed;this.gotoAndStop(2);_xscale = +scale;} 
if (Key.isDown(Key.LEFT)) {_x -= speed;this.gotoAndStop(3);_xscale = -scale;}
 
this code works alright accept that when the keys are not pressed it doesnt stand still, the legs are still moving, so I tried to include this code aswell:

if (!Key.isDown(KEY.RIGHT)) [code]....this makes the person standing still when not pressed but not moving the legs when turning right and left.

View 3 Replies

ActionScript :: Can Track Keys Pressed

Apr 29, 2011

Can I track the keys pressed, using ActionScript?

View 1 Replies

ActionScript 2.0 :: Both Keys Pressed At Same Time?

Jun 14, 2010

if (Key.isDown(Key.RIGHT)and (Key.isDown(Key.LEFT){
trace("both pressed");

i am trying to write the syntax to detect left and right cursor keys .pressed down at same time.

View 1 Replies

ActionScript 3.0 :: How To Detect That No Keys Pressed

Jan 9, 2012

I am doing a Flash game for school with parallax scrolling. Though I am going a much simpler way of the art, I am having one major error. My error is that when I stop pressing the Up Arrow Key, my ship does not move. All that my ship does, is sit there doing nothing, except for the following; exhausting fuel and showing the flame animation. Detecting if the Up Arrow Key (evt.keyCode == 38), I have tried both code below:

ActionScript Code:
!evt.keyCode == 38
and

ActionScript Code:
evt.keyCode != 38

View 3 Replies

ActionScript 3.0 :: Detecting Hardware Keys On Tab Devices

Oct 27, 2011

I want to use the on device keys of the samsung (and other) tab devices {Home, return/back and menu} How do i listen to those/ what events are that? Googling it i have a hard time finding anything. Probably because i am not using the right phrase for it.

View 8 Replies

ActionScript 2.0 :: Cannot Detect All Keys Pressed OnKeyDown

Aug 12, 2009

Cannot Detect All Key pressed onKeyDown

Here is the code I used:

Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("DOWN -> Code: " + Key.getCode() + " ACSII: " + Key.getAscii() + "

[Code]....

It is an usual code to listen the key presed on the keyboard. For some reason, I cannot detect any letter-key exept letters "w", "x", "d" and "J". I tested it on a different computer and results are the same. It is driving me crazy. I am not sure what is the problem.

View 6 Replies

Actionscript 3 :: How Many Pressed Keys Flash Can Detect

Dec 1, 2009

I'm developing a little game. I use the following code to detect the keys pressed by the player:

[Code]...

Basically the shootKey will be hold down by the player almost all the time. And the changeColorKey will be pressed very often but not hold down. While testing I noted that holding the shootKey and the right arrow down, the onKeyUp events for the changeColorKey don't get fired. Holding the up or down arrow key instead of the right arrow has the same effect. If I hold the left arrow key the events get fired. Why does it occour? Is there something wrong with my code?

View 3 Replies

ActionScript 2.0 :: Moving Map When Keyboard Keys Pressed

Jun 21, 2006

I want this code to move my map i.e map_mc when the keyboard keys are pressed. When I add it to the map_mc, I see no effect what do u think I am messing with.

Code:
on (keyPress "<Left>") {
currentX = this._x;
this._x = currentX - 2;
} on (keyPress "<Right>") {
currentX = this._x;
this._x = currentX + 2;
} on (keyPress "<Up>") {
currentY = this._y;
this._y = currentY - 2;
} on (keyPress "<Down>") {
currentY = this._y;
this._y = currentY + 2; }

View 3 Replies

ActionScript 2.0 :: Detect When Keys Are Pressed In Combination?

Aug 15, 2006

I've followed the thread there: [URL]

I understand that this class allow the script to detect when keys are pressed in combination.

But what is exactly the implementation when a key is used both in single and combination states. Let's say that you've the "q" key used alone and "shift-q"...how would one proceed to achieve this detection?

View 2 Replies

ActionScript 3.0 :: Detecting If A Key Is Pressed Without Events?

Jan 8, 2009

In AS2 I did this:

ActionScript Code:
ContactVerDoor.onRelease = function() {
if (Key.isDown(Key.SPACE))  if (Key.isDown(Key.SHIFT)) {
//Do something
}
}

I now need to code it in AS3.Can I still check if a key is down without listening for the keypress events? I understand how to code the Mouseclick in AS3.

View 2 Replies

ActionScript 2.0 :: Detecting Letters When A Certain Key Is Pressed?

Jun 26, 2006

I want to be able to detect when a certain key is pressed. Not the preset ones like spacebar, enter, delete, left, right, etc... I want to make it so that when the letter "a" is pressed, then such and such happens, and if the letter "m" is pressed, another thing happens.

View 3 Replies

ActionScript 3.0 :: Detect Which Keys Are Pressed In Input TextField?

Aug 23, 2009

I want to detect which keys are pressed while user input text into TextField.I tried something like

import flash.text.TextFormat;
import flash.text.TextField;
import flash.events.Event;[code].......

but this doesn't work.

View 3 Replies

ActionScript 3.0 :: Arrow Keys And Space Pressed Simultaneously

Sep 5, 2009

ive tested my game on several different computers. it works well on my desktop, but 2 laptops suffer an issue when left, space and up are all simultaneously pressed... thus the character is unable to move, jump and shoot at the same time

View 2 Replies

ActionScript 2.0 :: Combo Of Keys Pressed To Launch A Command?

Aug 11, 2009

Create a listener that will wait for a combo of keys pressed to launch a command? Something like if they type "admin" it will trigger a function.

View 2 Replies

ActionScript 2.0 :: [MX] Make A Condition Happen If 2 Keys At Once Are Pressed?

Mar 4, 2003

in actionscript, Is there a way i can make a coddition happen if 2 keys at once are pressed?

example:
if (Key.isDown(Key.SHIFT) && (Key.isDown(Key.LEFT) && _currentframe == 1)) {
gotoAndPlay("running_left");
} else if (Key.isDown(Key.RIGHT) && (Key.isDown(Key.RIGHT) && _currentframe == 1)) {
gotoAndPlay("running_right");
}

or can't i do shift and left/right?

View 2 Replies

ActionScript 2.0 :: Detecting Id MiddleMouse Button Is Pressed?

Jan 24, 2009

I need to find a way to detect if the middlemouse button(Mouse 3) is pressed, I have tried to use ASnatives and it worked well..but once you fire up the flash stage in a fullscreen mode the ASnative seams to stop working or any other way of detecting the mousebutton?

View 0 Replies

ActionScript 2.0 :: Detecting A Mouse Click While Key Is Pressed?

Jan 17, 2005

Is it possible to detect when a user is clicking while simultaneously pressing a button on the keyboard? For instance, if a user presses "a" on the keyboard and then clicks on a specific movie clip, I'd like to trigger an animation.

View 3 Replies

ActionScript 2.0 :: Multiple Conditions - An Object Will Go To A New Frame If Multiple Buttons Are Pressed?

Aug 12, 2009

i have an if statement, an object will go to a new frame if multiple buttons are pressed

PHP Code:[code].....

now i want it so that if one condition is met the mc will goto frame 2, if 2 conditions are met, frame 3 and if 3 conditions are met, frame 4.i know i could do this with a lot of if statements but i have a lot of movie clips to use this code on, so is there any way to write an if statement that will trigger different options if multiple conditions are met?

View 4 Replies

ActionScript 3.0 :: One Function For Multiple Keys?

Dec 21, 2009

I'm building a menu for a website that plays a sound each time you mouse over one of the buttons. (each button is a piano key) I've written two functions that change the size of each key on ROLL_OVER and ROLL_OUT events. What I want is someway to play a unique sound in my library for each key, without writing a separate function for each key. Either a new function, or just written into my existing ROLL_OVER function. Currently, it plays the same sound for every key.

Here is a zip of my project

[URL]

What I've got in there is a fla file called menu.fla In that file there is a movieclip on stage called "keyboardmenu" and inside that movieclip are 8 movieclip's (my buttons) each with a unique instance name. In the library there are 8 mp3 files with class name keysound1, keysound2 etc...Here is my code: ( I'm using tweener to handle the scaling. )

Code:
import caurina.transitions.Tweener;
function keyisdown(e:MouseEvent):void{
Tweener.addTween(e.currentTarget,{height:185, width:80, time:.25, transition:"easeOutBounce"});
varsound1.play();

[code]....

View 3 Replies

ActionScript 3.0 :: Cannot Get Multiple Keys To Work

Jun 21, 2010

I want to be able to toggle images on and off on key press.I cannot get multiple keys to work. I used to do this in Flash MX with the code placed on buttons off the stage. I used tell targeting with movie clips on the stage that had blank first frames and images on the second frame. Each button would call the second frame of a movie clip on keypress.Below is the code that is not working in AS3/CS4 - "M1" and "M2" are the two test movies, but only M1 works.[code]

View 1 Replies

ActionScript 3.0 :: Checking If One Or Multiple Keys Continuously Down

May 12, 2011

I have a character that should move using standard WASD control. I've tried to implement that using a listener for the KeyboardEvent.KEY_DOWN. However, it seems that what I get is:

1) Only one key at a time (ie I can't read both W AND A being pressed down at the same time)
2) When holding down first the events come in not every frame and later they come in every frame, ie, regularity of events relates to the system's sticky key.

What I would like is a solution where if I press the key W I continue moving to the left until the key is up. If I press multiple keys then I should move in the combined direction. What would be the best way to implement this? Do I need to listen to both KEY_DOWN and KEY_UP events and then use those as switch for movement? Is there a "good practice" way?

I got smooth movement/etc when I implemented both key_down and key_up. Essentially I made 4 booleans saying "move right/left/up/down" The boolean is set true by key_down event and false to key_up event. Movement itself is performed on enterFrame event based on how the booleans are set. Still wondering if there is a better way..

View 15 Replies

ActionScript 2.0 :: [Flash8] Keylistener On Multiple Keys

May 22, 2007

I got a little problem on a simple code: There are 5 Mcs on stage named Key1 to Key5. I got a listener on keyboard that put the mc alpha to 40 if you press the key of the mc (1 - 5), and turn the alpha to 100 if key isn't pressed

Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(49))key1._alpha=40;

[Code]....

The problem is that it works perfectly if you press a key at time, but it don't work if you press the 5 keys simultaneously , (make strange things :'1' to '4' pressed works, but '3' to '5' make the 5th mc as un-pressed) Is there a fine way to test if the 3 simultaneous keys (char '3' to '5') are pressed ?

View 2 Replies

ActionScript 3.0 :: Detecting Multiple Instances Of A MC

Jan 31, 2010

I want to do a collision detection for a bunch instances of a single movie clip.So I got this movieclip called "map1".Inside "map1" there are a bunch of rectangles called "house1".I also have a character whose name is mainChar1.So I know how to do the collision detection for each house individually, but i need a way to do it with some kind of a LOOP because there are like 50 houses.So instead of going through the code and doing house1, house2, house3..how do i do a loop for it? Here is the code for my collision detection:[code]

View 11 Replies

ActionScript 1/2 :: Detecting Clicks On Multiple Movieclips

Jan 16, 2010

how to detect clicks on various movieclips I am generating. Basically I am allowing the user to attach an arbitrary number of instances of the same movie clip. I would like each instance to A) be clickable and B) pass its reference to the click-handling routine.
 
For example I have something like this:
 
function addMissile() {
this.attachMovie("missile", "missile"+mtop, this.getNextHighestDepth(), {_x:startx, _y:starty});

[Code]....
 
I want to add a callback on-click for each of these movie clip instances.

View 3 Replies

ActionScript 3.0 :: Detecting When Multiple Load Events Done?

Jan 23, 2010

I have an application that at runtime creates a class called map. The constructor for this loads a XML file that specifies a number of images to load and loads them as children. What I want to do is to somehow sense when all images specified in the XML file are loaded and dispatch an event.

What I do is to create a load event for each image to load, that places the image as a child in the map object. This map is then put as a child on the stage.

I need to add a event listener to map that listens when it is fully loaded and triggers a event.

map.addEventListener(...) gives me a compile error of course.

View 3 Replies

ActionScript 3.0 :: Detecting First Visit In Multiple Swf Website?

Feb 5, 2009

i am making a website that has several main swf files that navigate to each other via links (nobody's loading anybody). all of them have external preloaders. i have a nice intro, about a minute long at the start of the homepage.

what i need to do is make the intro play only on the first entry to the site, and not when you reach it from the site's other pages. it's about either detecting first entry, or making the other pages pass a variable to the homepage. but i dont have the slightest idea how to do it...

because they have no physical connection, communication between them, i think it should be something like opening and changing a text file each time you enter a page, that the other pages would read. and this works for one user, but how to make it work for 60+ users at once?

and if you need some ip logging program written in some other language (i dont know any other) that creates unique values for each user, how to tell flash to read a specific file it creates? somehow based on the ip of the system the swf is played at?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved