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


Similar Posts:


ActionScript :: Can Track Keys Pressed

Apr 29, 2011

Can I track the keys pressed, using ActionScript?

View 1 Replies

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 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 :: 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

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 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 2.0 :: Make A Box That Fades In When Pressed On The Button And Fade Out When Pressed For The Second Time?

Nov 16, 2004

I have a function on root:

_root.fadeBox_mc.onEnterFrame = function (){
if (fade){
this.nextFrame();[code]....

This causes a mc to fade in and out on rollover/rollout. But what I wanna make is a box that fades in when pressed on the button and fade out when pressed for the second time. But if I say

on (press){
_root.fade = true;
}

the mc fades in, but I cant do another on (press) to fade out. Is this too confusing?

View 2 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 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

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

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 3.0 :: Name Of Key Pressed

Jun 29, 2010

Is there anyway to display the name of the key pressed on KEY_DOWN events? For example, if the user pressed the 'w' key I would want the SWF to print out 'w' and NOT the corresponding key code.

View 6 Replies

IDE :: Test To See If The S Key Is Pressed?

Sep 26, 2009

How can i test to see if the S key is pressed? (all i need to do is gotoAndStop)

View 12 Replies

Displaying A Graphic When A Key Is Pressed?

Apr 18, 2010

I am trying to play a sound and display a graphic when a key is pressed , so far i have been able to play my sound when i press the 'a' key but i also want to display a graphic that gets displayed while the key is down , i have created the graphic as a movie clip, not sure if thats right, iam not sure of the code i need to display the graphic.

View 1 Replies

Button On Pressed Stage

Oct 13, 2010

I have 2buttons. Each have 3stages: up, over, down.I want to have 1st button to stay on its 'down state' when pressed and then you should see 2nd button 'up' stage(down stage of 1st button is the same as up stage in 2nd button).If someone hovered again you see 'over' stage of 2nd button,when will click, button move to 'up' stage of 1st button.

View 1 Replies

ActionScript 2.0 :: Do Sth While Mouse Pressed?

Oct 18, 2010

I made a button and want do something when mouse is press, I mean when mouse is pressed that button should do its job. When button release scale of image will increase, now, I want it to do while mouse is pressed.should I use loop or conditional statement?

View 7 Replies

Flex :: Keep Focused After 'alt' Was Pressed?

Jan 18, 2011

I was making an application with AIR+Flex.

One Feature is like: when 'alt' key is down, the mouse cursor changes to B, when 'alt' key is up, the mouse cursor restores to A.

But the problem is that everytime a release 'alt' key, the mouse cursor will change back to system default (Arrow shape), and seems like the focus is on somewhere outside the stage.

That reminds me that, when 'alt' was pressed in a ordinary window, the menuBar will be focused.

How can I stop this default behavior?

p.s. I have tried the following ways and doesn't work:

1) listen to stage's KEY_DOWN/KEY_UP event, and add 'event.stopImmediatePropagation()' in the event handlers

2) listen to stage's KEY_DOWN/KEY_UP event, and add 'event.preventDefault()' in the event handlers

3) listen to stage's KEY_DOWN/KEY_UP event, and add 'this.setFocus()' in the event handlers. And 'callLater(this.setFocus)' doesn't work too.

View 1 Replies

AS3 :: Flash - Print The Name Of A Pressed Key?

Sep 18, 2011

Does AS3 have a way to output the physical name of a key that has been pressed? (ie. "You pressed: Left Arrow")

The obvious solution is to convert the character code to a string, but this only works for things like the alphanumeric keys. Ctrl, Alt, etc have special cases, but this still doesn't help for things like the arrow keys or the F-keys.

Another possibly naive option is to have a Key, Value pair for all the keycodes and their names. It should be almost trivial (if tedious) to code this myself, but since AIR already has things like

KEYNAME_LEFTARROW : String = "Left"

I was wondering if this ability is already built in somewhere without having to keep my own collection of strings.

View 1 Replies

ActionScript 3.0 :: Check Whether Two Key Is Pressed?

Aug 11, 2009

I have a problem in keyboard event as3 is detecting only one key event.How to check whether two key is pressed

View 9 Replies

ActionScript 2.0 :: Something To Happen After Several Mc Are Pressed

Aug 17, 2009

I am trying to make a movie clip fade in after several movie clips are pressed. It does not matter what order they are clicked in-Just as all of them are pressed. Does anyone know what this is called so i can find a solution?

View 3 Replies

ActionScript 2.0 :: Simulate A Key Being Pressed?

Mar 18, 2010

I've search around quite a bit but can't seem to find and answer to this seemingly simple question.

I have a project which listens for keystrokes in an onClipEvent. One of those keys is P. What I want is to simulate the pressing of the P button.

View 2 Replies

ActionScript 2.0 : Check If A Key Is NOT Pressed?

Mar 18, 2006

How do I make it check if a key is NOT pressed? Like after releasing a key.

View 3 Replies

ActionScript 2.0 :: Checking If Key A - Z Pressed?

Apr 15, 2007

I am trying to figure out how to check when the key "A - Z" is pressed...How can I use ASCII characters to check this?, or even if I check something like this
if(Key.isDown(Key("A")))

How to check when keys A-Z are pressed, preferably something like this
onKeyPress("A") = function() {
"run code"
}
Anyway to do this? Basically hotkeys, press "s" to call a line of function that will save the game.. etc...

View 3 Replies

ActionScript 2.0 :: OnRelease Happens When Key Is Pressed?

Apr 2, 2008

I'm writing a program that has a button, and when pressed, and the shift key is pressed, will do an action. I have an onRelease function for that button also, but for some reason when I have the button pressed, and I press shift or any other key, it automatically thinks the button is being released. I was using the onMouseDown, onMouseUp functions before, but they caused me a lot of problems aswell.

Try it for yourself:

Code:
btn.onPress = function() {
trace("pressed"); //now hit a keyboard button
}

[Code]....

View 2 Replies







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