ActionScript 3.0 :: Detect When A Key Was Pressed?

Sep 13, 2010

Im getting kinda frustrated as I try to come up with a simple way of telling when a key was just pressed... I've used both senoculars KeyObj class and the KEY_DOWN event, but i dont quite work as a would want the to work (if i press enter I get a zillions events - i just want ONE).

View 1 Replies


Similar Posts:


ActionScript 1/2 :: Detect The Name Of Any Object Pressed?

Aug 12, 2010

I need to detect the name of any object pressed that is on the stage. This needs to be done by simply pressing the mouse on that particular object on screen.I tried looking down the Mouse.addEventListener and myObject.target route but did not get very far. Baring in mind that this needs to be done in AS2. I have found a way to do it in AS3 but could not work out how to reverese this as so it works within AS2

View 3 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 Key Pressed OnKeyDown

Aug 12, 2009

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.

View 2 Replies

ActionScript 2.0 :: Detect When Other Buttons Pressed?

Mar 31, 2005

my fla file will be attached below. (its not the greatest looking thing but i just need to understand how to do what i want it to). i've got a navigation menu at the bottom of my stage with 2 movieclips. each movieclip has an instance of a button inside, a motion tween of a _alpha graphic flying in, and text to distinguish each button.

my problem #1: on the stage when you hit 'home', it'll fly in, but when you hit 'schedules' next, that will fly in too, right over anything i would have placed on 'home'. i'd like to prevent that by maybe having an outro animation (like a reverse of the intro animation) that can check whether another button was pressed before playing & when its completely off the stage, to play the next content corresponding to the button pressed.

my problem #2: i dont like how everytime when on the stage, i press the 'home' button or 'schedules' button multiple times, that they keep replaying the animation. i'd like it to know that its already been pressed & doesnt need to play again. i have a feeling this problem might be an easier one to figure out but i'm drawing a blank with it.

View 5 Replies

ActionScript 2.0 :: Detect Which Button Has Been Pressed?

Nov 29, 2002

I've played with this thing forever, here's my script:

if (_root.navigation.whois.onPress) {
loadMovie("content.swf", _root.contentarea);
_root.targetx = 140;

[code].....

View 6 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.0 :: Wont Detect UP ARROW KEY Being Pressed

Dec 11, 2009

[code]This code will trace "up is pressed." into the output panel whenever the UP ARROW KEY is pressed.Try pressing up a couples times to make sure it works.Now hold down the SPACE BAR and the LEFT ARROW KEY at the same time.Try pressing up while you hold BOTH those keys down, and it wont detect the UP ARROW KEY being pressed.It also wont detect the UP ARROW KEY being pressed if you hold down the combination CTRL+LEFT ARROW KEY.

View 3 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 3.0 :: Keyboard Event To Detect When A Key Is Pressed

Jan 6, 2011

I'm using a keyboard event to detect when a key is pressed. This is what it looks like:

Code:
private function keyPressed(event:KeyboardEvent)
{
switch(event.keyCode)
{
case Keyboard.CONTROL:
ctrlHandle=true;

[Code]...

It's worked up until now. I know that all the keys except the last one work because they carry out their function and the trace on DOWN works. However, for the last one, I've tried W and ALTERNATE (and got errors) and ESCAPE and TAB (both not doing anything, not even returning the trace).

View 2 Replies

ActionScript 2.0 :: Detect The Enter Key Being Pressed On A Button?

Oct 14, 2004

How do you detect the enter key being pressed on a button..

I want 2 text boxes 1 for user name 1 for the password

and a button

the user enters username presses tab - enters password - presses tab - button gets focus - presses enter on the keyboard form gets submited

I can detect the enter key press but not when the button has the focus..

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 :: Detect Enter Key Being Pressed On A Button

Oct 14, 2004

How do you detect the enter key being pressed on a button.. I want 2 text boxes 1 for user name 1 for the password and a button the user enters username presses tab - enters password - presses tab - button gets focus - presses enter on the keyboard form gets submited I can detect the enter key press but not when the button has the focus..

View 3 Replies

ActionScript 2.0 :: Detect Number Of Times A Button Has Been Pressed?

Feb 7, 2009

I have 1 button that when pressed 1 time should play "movieclip 1" and when hit for the second time should play "mc 2" on so on untill "mc9"(each movieclip plays continously when once activated)

so I need the button to register how many times it has been activated to play the right movie at the right time

I know I saw a script once that would work sometime, just cant find at anymore

View 6 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 2.0 :: Detect The Enter Key Being Pressed While In A Input Textbox?

Feb 19, 2009

I got this code:

Code:
if(Key.isDown(Key.ENTER)&&_root.answer==_root.youranswer)
{
//game over code here
}

However the "youranswer" variable is represented by the value in an input textbox and when I push enter, it just blanks it out and it never matches.

If I change it from Key.ENTER to Key.SHIFT, it works.

But this game: [URL]

has it where it can detect Enter and do a check with an input text box. How does that work?

View 2 Replies

ActionScript 3.0 :: Detect Number Of Times A Button Has Been Pressed - Attach New Mc Each Time?

Feb 7, 2009

with the following problem:I have 1 button that when hit 1 time shouldplay "movieclip 1"when hit for the second timeplays "mc 2"on so on untill mc9(each movieclip plays continously when once activated)

View 0 Replies

ActionScript 2.0 :: Snap - Press Button To Detect The Last Button Pressed And If The Shapes Match

Jan 12, 2009

I want the press button to detect the last button pressed and if the shapes match, make them do something...obviously. I think I'm going at it the wrong way. I need to stick a "triange" id into the button/mc then if compares that and then if there is a match works then... right?

[Code]...

View 1 Replies

ActionScript 2.0 :: Detect The Pressed Movieclip Outof 4 Movieclip?

Jun 13, 2011

i am new to flash AS,i have 4 movieclips, those have the 4 option of a question, when i select the answer,if it correct means my score will increase otherwise it will show alert,for that first i have to press the any one movieclip out of 4 options, in AS3.0 addEventHandler will work for AS2.0 what will i use to achive this

[Code]...

in this answer1, answer2,answer3,answer4 are the movieclip for 4 options

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







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