Professional :: Keyboard Event Isn't Working
Nov 28, 2010
I am creating a game where you have to use the up and down buttons on the keyboard to avoid movie clips. For some reason it won't register when i press the keys down. Here is my code:
[Code]...
View 2 Replies
Similar Posts:
Nov 26, 2009
I have a class called OfficeGame, which is working fine, except in that class I instantiate a class called OfficeSchmuck which is the character of my game. The problem being that the character is not responding to my event listeners which tell him to move. Here are the two classes:OfficeGame.as
ActionScript Code:
package {
// imports
[code]........
View 3 Replies
May 27, 2009
I use an event listener to detect keyboard activity and it is working fine, but when I add a MovieClip to the stage, the event is no more triggered, I need to click on the stage to get it active.The MovieClip fills all the stage, and I tried to add the same event listener to it, but still I need to click on it to get the event listener active.
View 11 Replies
Jun 1, 2010
I created a button that has a movieclip in the rollover state. When you rollover the mouse, the movieclip will animate to appear as if the button will scale from a small to a large button even though it is the movieclip that is playing and not the button itself. But I also want to add a keyboard code to play the rollover instead of the mouse. I learned to write actionscript to play different scenes with the code below, but I'm not sure if I can play a button rollover with the same code.
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);
function key_pressed(event:KeyboardEvent):void {
if (event.charCode==49) {
gotoAndPlay(1,"scene");
}
View 1 Replies
Jul 10, 2011
i've been looking around for answers to my problem to no avail. What I want to do is create a powerpoint style presentation. But rather than change slides, I have one large "graphic" that I am moving around and zooming into by "motion tweening" Now all I need to do is: (with a keyboard event) start the motion tween and then let it play out then start the next motion tween and let it play out and so on. all i have is this, which allows me to start and stop it when it is tweening, but isn't as effective as it stopping at then end of a motion tween, then allowing me to push a key and for it to go to the next "slide"
[Code]...
View 17 Replies
Jul 7, 2011
I am trying to learn JavaScript and I am wondering whether JavaScript has a event listener just like ActionScript's ENTER_FRAME. Basically, I want this event listener to listen "all the time" not just wait for any particular instance (mouse click, keyboard event) of event.
View 3 Replies
Nov 1, 2009
i have a question to ask about asynchronous key controls This was what i did
[Code]...
and i checked with [URL]...?newspage=6249 and it looked more or less the same, so why is it that when i move my character and when i hold down a key, it just keeps on listerning to that keypress event listener, instead of just executing the other event. So say, i tap left and after which i tap right, it will work just fine, but if i hold left and tap right, the event listerner will still be listening to the left key. So, i was wondering could anyone point me in a direction as to how should i make my code stop listening to an event as soon as another event has been dispatched?
View 1 Replies
Jul 8, 2011
I am doing this inside a module containing viewstacks and their childs.Calling onInit() on creationComplete of module.When I am inside one of the childs of a viewstack of this module and press Enter, it doesnt not invoke the listener function at all (bp inside this does not get hit).
private function onInit():void{
this.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
}[code]..........
View 2 Replies
Apr 23, 2009
When game starts, the car runs automatically. Then we click the SPACE button, movement of car stops. And the door of structure near car is available to CLICK.
But in coding I got this error code:
TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at shfg_fla::MainTimeline/key_pressed()
This is some part of my game code...
case Keyboard.SPACE :
removeEventListener(Event.ENTER_FRAME,car_movement);
--street_mc.bluehome_mc.door_btn.addEventListener(MouseEvent.MOUSE_DOWN,door_ready)
[Code]....
View 1 Replies
Jul 12, 2010
I'm creating a project with a number of different sections. I've created a index menu with invisible buttons on that takes you to the different sections. This works fine. In each section I wonted a means to get back to this index, so created a index button that is present throughout each section. I've put the event handler in the actions layer on the same frame that the button instance is on (frame 15).
[Code]....
View 5 Replies
Jul 4, 2009
I have a question about making a function for two different kinds of event. It's not critical but I would like to reduce my lines of code and just be more efficient. Basically I have a button on the stage called "Enter". I also want the user to have the option of hitting the enter button. I don't have a problem making these two separate handlers for these events (i.e. one handler for the KeyboardEvent and one handler for the MouseEvent):
[Code]...
View 1 Replies
Oct 24, 2011
how can you switch the mouse event with keyboard event in the folowing example:
Code:
var qno=0;var rnd1; var rnd2;
tick.visible=false;cross.visible=false;
var right_answers=0;var wrong_answers=0;
[Code]....
i know that u have too define key up and down functions and in the beginnig give the keys we are using the false value, but how to make it that after i pess of a key you cant press in again unless you go to the next question that is the enable_disable in the following code. How would that function looked in case of keyboard event
View 1 Replies
Mar 6, 2011
I have confirmed to my satisfaction that the following code never triggers the Event.COMPLETE of var loader:
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest(contact_url);
var variables:URLVariables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
[Code] .....
However, it does in fact send the emails it is designed to send! Why doesn't it complete when in fact the work is done?
View 3 Replies
Feb 1, 2010
My keyboard shortcuts have quit working. I'm not talking custom shortcuts that I have defined. The default Flash shortcuts just don't work anymore.Before anyone asks, yes, I have made sure the "Disable keyboard shortcuts" option is turned off. I'm running Flash CS4 on a Windows XP pro machine.
View 2 Replies
Mar 12, 2010
I am adding a key listener to my AIR application like so:
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
keyDown="onKeyDown(event)">
Yet only sometimes when I press keys does it actually invoke. I have no clue why, I thought maybe something else has focus. Well I cannot add key listeners to NativeWindow or NativeApplication, and I would assume if it is on the WindowedApplication which is the root element, that as long as my application has focus the key presses should invoke the listener.
View 1 Replies
Nov 20, 2010
can't figure out why the keyboard input isn't working. I got this warning, but I always get that warning and it always works. The warning says:Warning: 1090: Migration issue: The onKeyDown event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'keyDown', callback_handler).
View 1 Replies
Jul 5, 2009
ok so i am trying to change a boolean with a keyboard event
my code is this:
Code:
stage.addEventListener(KeyboardEvent.KEY_UP, keyPressed);
function keyPressed(evt:KeyboardEvent):void {
if (evt.keyCode==Keyboard.SPACE) {
if (!gamePaused) {
[Code]......
View 1 Replies
Jul 31, 2009
I'd like to arrange things so that I have a chain of keyboard event handlers in my flex application, all of whom are queried when key down events occur. Basically, when a visual component is on screen, it is a candidate for handling a key press event. Something like this (clearly this is pseudocode):
<application handles_keys="F5, F6">
<tabGroup>
<tab1 handles_keys="pgup, pgdn">
<control handles_keys="0,1,2,3,4,5,6,7,8,9" />
[code]...
I have a class written that will respond to the key events the way I want it to, so how do I register one or more instances of this class to have the results I want? Also, note that there are some situations where this class should receive events that would ordinarily be handled by a UI component. The TAB key is the main example; I have a few cases where I want my key down event handler to fire even when the focus is on a text field.
View 3 Replies
Mar 29, 2012
I'm trying to detect keyboard input and if the arrow keys are pressed, set the players next move to whatever was pressed. I'm listening for keyboard input using:
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
This is the function that gets called:
public function keyDown(event:KeyboardEvent):void
[code]....
View 1 Replies
Dec 29, 2010
Tracing the keyCode for the 'a' key (65) only works once for KEY_DOWN events and sometimes KEY_UP behaves in the same way, making development a pain when trying to do things quickly.
Clicking on the stage makes it start working, but why is it just the 'a' key that is affected?
This is on a new MBP running OSX 10.6.5, Flash version MAC 10,1,102,64
[URL]
The issue can be reproduced every time with this code:
ActionScript Code:
import flash.events.KeyboardEvent;
stage.addEventListener (KeyboardEvent.KEY_DOWN, keyDownHandler);
[Code]....
View 4 Replies
Mar 6, 2010
I have a button on the stage called enterCostBtn that when it is pressed it executes the code inside the calculateCost function. What I want to do is to be able to use the ENTER key on my keyboard to trigger that function. In other words I would like to be able to use the ENTER key or click directly on the enterCostBtn to trigger this function.
Code:
enterCostBtn.addEventListener(MouseEvent.CLICK,calculateCost,false,0,true);
function calculateCost(event:MouseEvent):void {
var material:Number=Number(Material_txt.text);
var labor:Number=Number(Labor_txt.text);
[Code].....
View 3 Replies
Sep 8, 2010
I'm an artist, not a developer, but I work with various media. I am so~so with AS3 and JS and a total noob with PHP and databases.Anyway, I am writing a Class based on keyboard events and I am finding that if the keys are hit too fast the triggered events don't complete.I'll explain further:I have a picture broken into parts (a red background here, a blue stroke there, and so on). Each one of these elements is a Library Object, and they are all set to alpha=0, and each one in turn, is tied to a key on the keyboard. When the key is struck, the picture element goes to alpha=1, plays a sound, and starts tweening back towards alpha=0.
Code:
public class TypedImageV4 extends MovieClip {
public function TypedImageV4() {
[code].....
View 8 Replies
Feb 14, 2011
I have been reading for about an hour online with no solution, if you are typing in a text field, you seem to not be able to read if the "enter" key is pressed, exmaple attached.
View 8 Replies
Jul 1, 2011
I'm still a beginner in programming ActionScript 3.0,
I had a problem with KeyboardEvent in ActionScript 3.0,
I created a simple shooting game, the game has 2 Frame,
1. Title Game (Frame 1)
2. Game Playing (Frame 2)
The problem is in Frame 1 when Button is clicked playinggame
then switched Frame to Frame 2 where the game takes place where the user can move the aircraft by using the keyboard, (Left Arrow, Up Arrow, Right Arrow & Down Arrow).
But when a keyboard button is pressed, KeyboardEvent not react at all, and aircraft can not be controlled.
Even more bizarre when the stage at the click KeyboardEvent can react and aircraft can be controlled.
The question is how to keep the button is clicked playinggame in Frame and the Frame 2, the aircraft can still be controlled using the keyboard
[URL]
View 2 Replies
Mar 27, 2011
I am trying to move an object on stage with arrow keys. I am using this code
[CODE]....
The problem is that it do not start to move immediately after I press the key and it takes few moments to move. I have uploaded the swf file here [URL]...oqwnlssewe.swf
View 1 Replies
Aug 26, 2011
I have looked at other questions and online but still cant figure out where I am going wrong I am adding 2 events to a externally loaded swf
One works, and one doesnt?!? the function names are correct so I can see what Im missing
my_loadedSwf = loadEvent.currentTarget.content as MovieClip;
my_loadedSwf.addEventListener(Event.ENTER_FRAME, my_loadedSwf.enterFrameHandler);
my_loadedSwf.addEventListener(KeyboardEvent.KEY_DOWN, my_loadedSwf.myOnPress);
addChild(my_loadedSwf);
[Code]....
set my_loadedSwf.tabEnabled = true; and it now works great
EDITS TO THE ABOVE Actually, it isnt working, I have to press 'tab' to take control of the player
ANSWER
I removed the tab index code and added focus to the loaded swf
View 2 Replies
Jan 3, 2010
1) My game is playing differently when i am debugging it & when am i testing the movie(ctrl+Enter), the difference is that in testing movie the keyboard keys(i hv called the keyboard event key up & key down ) are not working first time, when player loses the game fiirst time,key start to work properly
2) It is working slowly, when i loaded its compiled swf with another swf but working fine when played individually, i hv specified the different stage.framerate for both swf in their corresponding class.
View 1 Replies
Aug 2, 2010
When I go to full screen with stage.displayState = StageDisplayState.FULL_SCREEN the keyboard stops working. I cant even type in textboxes (or get any of my keyboard events).
View 4 Replies
May 14, 2008
I looked around but I didn't find any event sent by the TextField whe the keyboard cursor enters or leaves the field ?
View 5 Replies
Sep 15, 2009
Most flash games and interactive animations that use keyboard events are made to respond in different ways to different keys.I am working on games for toddlers, who basically just bang on the keyboard indiscriminately. The trouble I'm having is setting up keyboard eventlisteners (key_up) that each perform different function.We're talking games like: when key pressed, ducky dances; when key pressed, doggy dances; when key is pressed, ducky and doggy go to sleep. I've attempted removing the listener before adding the next one:
stage.addEventListener(KeyboardEvent.KEY_UP, doSomething);
function doSomething(evt:KeyboardEvent):void
{make it do something;
[code]....
View 12 Replies