ActionScript 3.0 :: Keyboard Event Listeners No Longer Work On My Character?
Jun 23, 2009
Im trying to make a game at the moment, with a little character who runs around the screen. To do this i have keyboard event listeners on the character.I have an inventory which opens when you click a button, and has number of things to click on.My problem is that when i close the inventory, by clicking the close button, my keyboard event listeners no longer work on my character.
Keyboard events also dont work on the stage at this point, and i cant understand what i need to do.Its as if nothing has focus anymore for keyboard events. Mouse clicks still work fine.
View 1 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
Jan 10, 2011
function moveJoeOne():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
[code]....
I've got two different instances of two different MovieClips on the stage of the fla. Visually they're identical but one is facing left and one is facing right. When the file runs, the one that's facing left appears on the stage while the one that's facing right is set to be invisible. What I'm trying to do is have the one that's facing left go invisible when the right arrow is pressed and for the one that's facing right to appear in it's place and accept further input from the right arrow key. When I run the file, the one facing left moves just fine. My problem is that when I press right, the one facing left disappears and the one facing right appears in it's place but it just moves once and stops.
View 1 Replies
Nov 17, 2009
It currently has the following listeners active. When you click a blurb, you will zoom into it. When you click it again (or anywhere on the flash object) it will zoom back out.If you let it idle it will zoom in and out at roughly 10second intervals.There are also keyboard functions that when you click on the arrow keys it will move the camera in various ways. The keys only work in the zoomed out state and are disabled on zoom inThe problem that I'm having is with these. On startup, the keys work fine. If you let it idle and have it automatically zoom in then out, the keys will work fine. However, if you manually click out of a blurb, the keyboard event listeners stop working. I'm not sure why this happens since both the auto-zoom and the manual zoom both call the same function to zoom out.
At first it seems to be that the window is losing focus, since if I click on white space I can use the keyboard again. The problem though, is that when I use an DEACTIVATE event listener to test it, it doesn't show the flash object losing focus. Because of that, I'm not really sure how I would go about fixing this problem.
Code:
package com.jonchau.twitter {
import flash.display.MovieClip;
[code]......
View 1 Replies
Mar 30, 2011
I have been been testing for keyboard events one key at a time. Now I want to test two keys being pressed or released at the same time. I am unclear on how to do this. Do I need to indicate this intention in the functions parameter
Code:
if(event.keyCode==keyboard.LEFT&&keyboard.keyCode.RIGHT);
isn't cutting it.
View 6 Replies
Dec 12, 2010
What's wrong with my code?
function moveJoeOne():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);[code].....
I've got two different instances of two different MovieClips on the stage of the fla. Visually they're identical but one is facing left and one is facing right. When the file runs, the one that's facing left appears on the stage while the one that's facing right is set to be invisible. What I'm trying to do is have the one that's facing left go invisible when the right arrow is pressed and for the one that's facing right to appear in it's place and accept further input from the right arrow key. When I run the file, the one facing left moves just fine. My problem is that when I press right, the one facing left disappears and the one facing right appears in it's place but it just moves once and stops.
View 2 Replies
May 3, 2010
Just using the script below to output the key that is pressed in the output but I get the "Cannot access a property or method of a null object reference." warning on the addEventListener line, which I assume is because of the "stage" var. How do I correct that?
Code:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#123456" creationComplete="init();">[code].............
View 9 Replies
Nov 26, 2006
I decided to pick up a copy of O'reilly Actionscript 3 Cookbook today, and I have been going through. One of the first examples it has for keyboard events is:[code]But for some reason it will not work. According to the book stage.focus = this; is all you need for keyboard events to work, am i doing something wrong?
View 8 Replies
Sep 6, 2009
Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML? The rest of my game is running fine in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes any difference...
function goNow (event:KeyboardEvent): void { thisOtherKey = event.keyCode; if (thisOtherKey == 32) { nextCar.gotoAndPlay(2); parkingQue.play(); tries++; }}stage.addEventListener(KeyboardEvent.KEY_DOWN, goNow);
View 2 Replies
Jan 3, 2004
I've just finished a simple Flash 5 game in ActionScript. Everything about it works fine except when I try and turn it into a web page. After I create the page, the graphic controlled by the player no longer responds to the keyboard. Can anyone explain why this is and how I can fix it?
View 4 Replies
Jun 19, 2009
I have a pretty linear slide show presentation.It starts with a navigate function that listens fr keyboard presses(space, right or left arrows) and also a mouse click listener, and these either advance or rewind the show a slide at a time.On about a dozen of the 60 slides, I call an external swf or flv/f4v and i have built in conditions based on frame number, so that I can kill movies and unload swfs before moving on.Make sense?So, i'm wondering, is there a way to code all the exceptions once and have them bind to the mouse listener and the keyboard listener?Or should I just code all the exceptions in the mouse listener function and the keyboard case listener?Or am I totally going the wrong direction?Thinking out loud, I guess i could write 2 different simple functions, one that is straight advance frame -to- frame, and one that is for the "exceptions" frames, that kills a movie or unloads a swf, and set a boolean variable based upon what frame the movie is on.
View 1 Replies
Nov 14, 2007
I have a portfolio page that I put together with Flash MX.The interface is bsically a chart that has a bunch of buttons on it. These buttons each have a code similar to this;
on (release) {
getURL("javascript:openNewWindow
('file.html','thewin','height=600,width=800,toolbar=no,scrollbar=no,r esizable=no,menubar=no')");
}
This used to work - but not now. Even when I check my browser for pop-up/javascript enabling,it no longer works.
View 3 Replies
Apr 7, 2011
I have an swf that I created that contains links to other pages on our site. I can test this and it works fine. However, I then import that swf into my main fla's library. However, after I add it to the stage I test the main movie and the links that worked before in the imported swf no longer work. This seems like it should be a no brainer but for some reason it just isn't working.
View 12 Replies
May 7, 2006
The site I'm building has seperate swf's for each page...and I have the external swfs loading into the site. But my problem is that when I am on one of the external swf pages that has been loaded, and it has buttons on it, none of these buttons work. They work when I test the swf by itself, but once my main movie loads the swf into the site, the buttons within the swf no longer work.
View 1 Replies
Nov 24, 2011
I have this in my constructor:
[Code]..
The problem is I get Error: Error #2094: Event dispatch recursion overflow. Why does removechild keep getting called if this.parent does not exist? Why doesn't removing event listeners work?
View 1 Replies
Sep 3, 2009
Can event listeners only be added to the class which dispatched the event? I ask because I want to have the logic for the listener on the main class, and the action is dispatched on click from a thumb which is instantiated in a scroller class. Kinda like this:
ActionScript Code:
pseudo code:
class main {
main() {
[code]....
This doesn't work. Why can't the main class listen for an event on the thumb class?
View 1 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
May 23, 2010
I'm pretty new to Flex. Basically, anything I try to build with mxmlc fails to run now, giving me the above three errors depending on what I do. It was working 30 minutes ago, I've been spending that time trying to figure out what has changed. I redownloaded the Flex SDK, cleared my assetcache, have cleared Firefox's cache. (I'm using Linux.) Even if I compile with -static-link-runtime-shared-libraries=false, since it seems like #2048 is a RSL problem, it still refuses to run.
Another strange thing, if I keep
<policy-file-url>[URL]>
<rsl-url>textLayout_1.0.0.595.swz</rsl-url>
In my flex-config file, then firebug tells me that my swf file is trying to access a copy of that in the app's folder, giving error 2032. And if I stick the one I have in frameworks/rsls/ then it gives me error 2046. I don't know how it could not be properly signed, unless Adobe magically changed a signature and didn't update their flex SDK.
View 4 Replies
Feb 13, 2010
An odd thing is happening for me, my eventlisteners only fire off once then they seem to stop working.
This thing is a movieclip that slides up the parent movieclip and another movieclip within mc slides it down. They only work once.
ActionScript Code:
slider.up.addEventListener(MouseEvent.MOUSE_UP, activateSlider);
slider.down.addEventListener(MouseEvent.MOUSE_DOWN, activateSlider2);
var frameBoolean:Boolean = false;
[Code].....
View 9 Replies
May 31, 2009
Whenever I remove an event listener to a button then that button no longer works. Does it cause memory leaks to not remove these listeners.....come to think of it I have about 30 eventListeners that I cannot remove otherwise the application ceases to function correctly. Is my application a memory black hole? How should i proceed with garbage collection?
View 3 Replies
Jan 21, 2011
I have a custom component I've developed that's part of a dashboard.It does some polling based on a timer that's part of the component.
When the user navigates away from the view that contains this component I would like to stop the timer and hence stop the polling.I can obviously fire an event when the view's changed and catch it within the component but I was hoping that there might be a way to contain this all within the component.Is there an event or state change within a component that triggers and even when a component is currently be displayed?
Example:
]]>
</mx:Script>
<mx:TabBar x="10" y="10" dataProvider="viewstack1">
[code]....
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
Jan 22, 2010
Is there any way to control a character made with Adobe CS4 Bone Tool via keyboard buttons? Its limbs are linked up by IK chains built by Bone Tool.
View 1 Replies
Sep 12, 2010
I had FMS 3.5 developer package installed on my server installed about a month ago. I used to be able to go to the /webroot/ page to see the sample RTMP video play and it worked great. Today, I go to view that page and find that it no longer plays. I get "Connection Error. Please preee Play to try again."
Pressing the play button does nothing, so I click the RTMP thumbnail and it reloads ony to give me that same error again. I can click the HTTP thumbnail and see the video play just fine. But, I want RTMP and after over an hour on the phone with my managed hosting tech, we can't find anything wrong.
Here's the thing: I haven't done anything, I have not changed anything, I have not manipulated the server software whatsoever. It just stopped working and gives me "Connection Error."
[Code]...
View 6 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
Oct 9, 2010
In this script, I'm moving a sprite on the stage up and down using the keyboard. Works fine, except that there is a long delay after the SWF file has loaded until the key presses are registered and the sprite moves.
It takes about 5 seconds after I open the SWF file before the movement works.
[Code].....
View 5 Replies
Dec 8, 2010
In AS2, how can I get a roll over listner in a MC inside a scroll pane to display a MC tool tip on the stage outside of the scroll pane? I am using the following code in the main time line to display the tool tip and it dosn't seem to be working:
//****Sel******//
selectionTxt._visible = false;
Sel.onRollOver = function(){selectionTxt._visible = true;}
Sel.onRollOut = function(){selectionTxt._visible = false;}
View 8 Replies