ActionScript 3.0 :: KEY_UP Not Always Firing?
Sep 20, 2010
The problem is that I've done a lot of work in my game, and there's too much code bound to shift and control keys. For example you need to hold shift key to select multiple soldiers or control key to shoot or sometimes pause the game or even call a map, a lot of stuff in GUI depends on those keys as well. Both KEY_UP and KEY_DOWN are added to the stage object. But, time after time, there happens a very annoying thing, KEY_UP event just doesn't fire for shift or control (in most cases it does, but not always). That is, I press shift, start selecting soldiers, then release shift but Flash Player keeps thinking it's still pressed, so I can still select multiple soldiers, which is not good.
I found the exact same problem here: [URL]
View 6 Replies
Similar Posts:
Aug 25, 2010
I am trying to capture Ctrl+C. I have noticed that many times, there is no KEY_UP event for C key. I believe it happens in cases KEY_UP event for C key should be thrown just before or after KEY_UP event for Ctrlkey.
Why does this happen? How can I catch the KEY_UP for C key?
View 1 Replies
Mar 7, 2011
I have a typing game and I want to be able to detect period and commas, however unless you are holding down another key (any other key), the period and comma keys do not trigger KeyboardEvent.KEY_UP. I found that sometimes they would work when focus was set to the document class. After hours of debugging my game trying to figure it out, I decided to create a new project to JUST test this problem. Here's the absolute barbones example:
package
{
import flash.display.MovieClip;[code]..............
If you run this, it should automatically set focus to the document class. At this point, the period and the comma do not work. Now click the stage and you will find that the comma and period do not work UNLESS you hold down another key (for example hold down the m key and then press the comma key). Also at this time, focus is set to null.Now click the textfield, and the comma and the period work again.
View 1 Replies
May 18, 2011
I'm using very basic code to move an object around the stage using keys on the keyboard (W,A,S,D). However, I have noticed at times when the CPU hiccups, flash does not register that a key was released and in turn my object keeps moving in a direction without any keys pressed. The only way to stop the object from moving is to press the key corresponding to the direction the object is moving.
View 9 Replies
Feb 28, 2009
I'm trying to make as3 application which uses custom mouse pointer while pressing spacebar on my keyboard. Everything works fine when I don't move my mouse but when I do the KEY_UP event is dispatched to my listener almost immediately (and this is while I'm still pressing my key down). Below is simple main class which used to test this behaviour:
[Code]...
View 14 Replies
Jun 17, 2011
I have discovered a bug with KeyboardEvent.KEY_UP keyLocation values for the shift keys. how to reproduce this:
1.when no other keys are down the value for left shift is 1 and for right shift is 2 for KeyboardEvent.KEY_DOWN and KeyboardEvent.KEY_UP
2. when you have pressed shift and then press another key - when releasing shift the value for left and right become 0.
There is absolutely no reason why these values should report anything other then what they initially reported on key down as each key fires its own event with details for each , regardless of any key combinations. Im using cs5.5 windows 7 basic.
View 6 Replies
Mar 21, 2012
I´m trying to catch KEY_UP event if I press ENTER, without clicking on stage.
I´ve already disabled keyboard shorcuts for flash player, and added stage.focus = stage.
Not succeeding.
It only works if I click on stage.
It seems that for the other keys the KEY_UP works.
View 8 Replies
Aug 26, 2010
Try the following code:
myListener = new Object();
myListener.onKeyUp = function() {
if (Key.isDown(Key.CONTROL) && Key.getCode() == 67) {
[Code]....
hold Ctrl key and start pressing C. From some point you will notice that there is no KEY_UP event for the C key (there will also be no event for A,X,R,V and maybe more). For most of the button the KEY_UP event will still be dispatched.
View 1 Replies
Oct 4, 2010
here's the code.
var zipTimer:Timer = new Timer(1000, zipArray.length-1);
zipTimer.addEventListener(TimerEvent.TIMER, onTick);
zipTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
[code]....
Now, I can't see, for the life of me, why this isn't firing. It's almost exactly the code from Adobe's docs...zipArray.length is at least 32.
View 1 Replies
Dec 15, 2011
I'm working on a scene where the user can drag sugar, honey and syrup flavour to a cup of coffee and each time they collide, the coffee's happiness is increased by 1. I added a TweenLite so that sending any of the objects to their original positions is much more fluid. The problem is that the hitTestObject is now firing more than once (which makes sense and now happiness is increasing at more than one increment at a time) but how can I make it so happiness is increased just once?
Code:
public function hitsDecaf(e:Event):void{
if (myCounter.myHoney.hitTestObject(myCounter.decafSweetened)){
ifStartTimer = true;
stopDrag();
myCounter.steamHappy.gotoAndPlay(2);
[Code] .....
View 4 Replies
Jan 24, 2008
I have the following:A document class, extending from a custom class, extending from MovieClip. In my document class, I assign a handler to the FullScreenEvent like so:
Code:
addEventListener(FullScreenEvent.FULL_SCREEN, function(e) { toggle_fullscreen(); });
Also, I've set up a SimpleButton to call that same function, toggle_fullscreen, when clicked.Here's the catch:When I click the button, my app goes fullscreen. When I press Esc, the app goes back to normal but the FullScreenEvent doesn't get fired,so I can't catch it to re-align the elements on my stage.I've also tried to add the event listener to the stage object of my document class, but that doesn't work either.
View 4 Replies
Jan 19, 2010
I have some code where an event handler listening to Event.ID3 fires twice for an MP3 file. From searching the web, I found a few others asking a similar question, but I haven't seen any response.
Does anybody know what would cause the ID3 Event to fire twice for a single file? My only guess is that the MP3 file contains two versions of ID3 format.
The code looks like this:
Code:
var mySound:Sound;
function setup()
{
[Code]...
View 2 Replies
Feb 14, 2010
I am having a problem with my ProgressEvent.PROGRESS handler. It looks like this:
Code:
function handleProgress( event:ProgressEvent ):void {
var percent:Number = Math.round( event.bytesLoaded / event.bytesTotal * 100 );
trace("Uploading %" + percent);
}
It just traces "Uploading %100" every time
I am using a big file so I know its taking several seconds between calling URLLoader.load and complete. There just doesn't seem to be a report in between 0-100..
View 12 Replies
Nov 18, 2009
I keep running into problems where I want to add an event listener onto a class instance RIGHT after it's instantiated, like this:
Code:
storiesXML = new XML(XMLdata);
storyBook = new vStories(XML(storiesXML.stories));
storyBook.addEventListener("storyBookLoaded", storyBookLoaded);
. . .
But by the time we arrive at the third line, the "storyBookLoaded" event has very often (inconsistent) already been dispatched from my class instance:
Code:
var evt:Event = new Event("storyBookLoaded", true, false);
dispatchEvent( evt );
...
(Even though quite a lot has happened in the class before that.) To be clear, I don't want to add storyBook as a display child, and even if I did, the addChild() method would have to be called after instantiation of storyBook, so we'd have the same problem. I know I could set a timer in the vStories class to artificially delay the dispatching of the event, but that seems really hack-ish, and would have a real compounding problem if I have to do it too often as everything builds up. How to make sure custom communication events happen after their listeners are set?
View 4 Replies
Jul 13, 2010
I have a little flash app that I have running constantly on my server (I made it an exe). It runs great for a few days, but then eventually it just stops.
Code:
trace("test1");
var myTimer:Timer = new Timer(5000, 1);
myTimer.addEventListener(TimerEvent.TIMER, getData,false,0,true);
[Code].....
The code above should call the function getData once after 5 seconds have passed. This works 99.99% of the time, but for some reason (usually after a few days of it running) it doesn't call the getData function.
I have verified this through trace statements. When it eventually fails, it traces out test1, test2..... then nothing else. No test3.
I'm assuming I need to add an event listener for the timer object to check if it fails for whatever reason. How do I do this?
View 4 Replies
Sep 21, 2009
Can anyone see why my event.Complete isn't firing
[Code]...
View 4 Replies
Dec 5, 2009
I'm sure some users on this forum will be aware that AddThis are dropping the Clearspring Launchpad, so I'm writing a new API to get ready for the changeover. Part of that is a base UI that will create buttons for social network sharing destinations. At the moment, AddThis contain all the icons in a single long strip that is 16x3520 pixels in size [URL]...
What I'm trying to do is load this into a utility class, but the Event.COMPLETE event never fires, and if the Loader class that loads it is added to the stage, the bitmap is never shown. I thought it was maybe a dimensions issue, but what is curious is that if I place the PNG on a Flash stage and export as a SWF, it loads no problem. If I dump it out as a JPEG, no problem. Its ONLY when the file is a PNG that there are problems trying to load it. I even tried dropping it out as a 24-bit PNG (the original is 8) but that had no effect.
View 2 Replies
Oct 28, 2010
I am simply trying to link a button on my site to another webpage (an online store). The site is currently live at Higdon Florist (won't let me put the dot com address due to forum rules) The last 2 menu options (View Bouquets and Place Order) should link to (store dot higdon florist)
On PC, this works just fine every time.
However, I have reports that Mac users have trouble. The action never fires on the first 4 or 5 tries. Then, suddenly, it begins to work (and continues to work thereafter).
My AS3:
import flash.net.URLRequest;
import flash.net.navigateToURL;
navigateToURL(new URLRequest("(store address)"), "_self");
[Code]....
View 4 Replies
Jun 14, 2010
In my Flash project I have a movieclip that has 2 keyframes. Both frames contain 1 movieclip each.
frame 1 - Landing
frame 2 - Game
The flow of the application is simple:
User arrives on landing page (frame 1) User clicks "start game" button User is brought to the game page (frame 2) When the game is over, the user can press a "play again" button which brings them back to step 1
Both Landing and Game movieclips are linked to separate classes that define event listeners. The problem is that when I end up back at step 1 after playing the game, the Game event listeners fire twice for their respective event. And if I go through the process a third time, the event listeners fire three times for every event. This keeps happening, so if I loop through the application flow 7 times, the event listeners fire seven times. I don't understand why this is happening because on frame 1, the Game movieclip (and I would assume its related class instance) does not exist - but I'm clearly missing something here.
I've run into this problem in other projects too, and tried fixing it by first checking if the event listeners existed and only defining them if they didn't, but I ended up with unexpected results that didn't really solve the problem.
View 2 Replies
Nov 4, 2010
I'm new to ActionScript development and am using the FlashDevelop IDE. I've been playing around with some really simplistic things and have come across a problem I can't seem to solve.My application compiles and runs, and a function that watches click events fires perfectly and I can see the event in the console when I pass it to trace(), yet the same code watching for KeyboardEvent fails to fire at all.Here's my code:
package GameTesting
{
import flash.display.Bitmap;[code]............
The MouseEvent trace() fires every time as expected, but KeyboardEvent never fires, no matter what key I press.
View 2 Replies
Sep 18, 2011
I'm writing a SWF that I'd like to communicate with a Java process via Sockets. This is usually quite easy with standard Sockets, but for some reason the events described in the Socket documentation aren't firing when all signs say they should be.
On the Java side, I've set up a ServerSocket that's listening on port 8080. Using netcat I've confirmed it works as designed.[code]...
When I run the resulting SWF, all I get is "Called connect!" on the stage, and none of the events ever fire. Even more strangely, when I investigate the communication from the ServerSocket on the Java end, it receives and accepts a connection. When I close the SWF the code calling my Server completes as normal -- meaning it was hanging on a connection made with my SWF.
I'm left with a few questions...
With the exception of the event handlers, this is the end of control for my code (after the connection is established, we just wait for events and render them appropriately). Could the entire program be "terminating," and I'm just misunderstood about the Runtime model?Are there visibilty/naming requirements for the callbacks for them to be called? They're all public, but could it be that the Runtime isn't seeing them?Are there any gotchas with AS3 Socket programming? I kept thinking this was an issue of sandboxing, etc., but the SECURITY_ERROR didn't fire either.
View 2 Replies
Mar 30, 2012
I have a bit of a quandary. I need to call a function inside a MovieClip once a particular sound has finished playing. The sound is played via a sound channel in an external class which I have imported. Playback is working perfectly.Here is the relevent code from my external class, Sonus.
public var SFXPRChannel:SoundChannel = new SoundChannel;
var SFXPRfishbeg:Sound = new sfxpr_fishbeg();
var SFXPRfishmid:Sound = new sfxpr_fishmid();[code]....
osr.Sonus.PlayPrompt(...) and gui.Wait(...)
both work perfectly, as I use them in other contexts in this part of the project without error.Basically, after the sound finishes playing, I need Wait(false); to be called, but the event listener does not appear to be "hearing" the SOUND_COMPLETE event. Did I make a mistake somewhere? For the record, due to my project structure, I cannot call the appropriate Wait(...) function from within Sonus.
View 1 Replies
Feb 16, 2009
I was wondering for personal use how you would go about writing a function on a button that when the mouse click is down it would keep firing the function kinda like it does when using the onEnterFrame on key frame..
View 2 Replies
Sep 14, 2009
I've got a class which attempts to call a method upon Event.ADDED_TO_STAGE firing. Instances of this class are obviously added to my stage (I can see them) yet my onAddedToStage method never gets called.
HTML Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
[Code].....
View 9 Replies
Oct 13, 2009
I'm dynamically creating instances of a loader in a loop, adding a complete listener to it, and loading it. For some reason the complete function is not called. Is this syntax wrong?
[Code]...
View 2 Replies
Jun 29, 2010
I've a banner swf that triggers a popup when the user clicks a buttons(works fine).I use external interface to open the popup from the swf.
ActionScript Code:
var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.methodToExecute = function(param1:String) {
[code]......
View 0 Replies
Sep 30, 2010
I have set up the tab order of my movie clips and i can tab through them fine. When i get to a movieclip that has a mouse event to fire off a link it does not fire when i hit the enter key. I know in As2 you didn't have to do anything the enter key just worked. Does any one know how to resolve this?
View 6 Replies
Dec 15, 2010
Or at least that's the impression I'm getting. Locally in Flash, it all seems to work fine. When I open it in Safari or Firefox, it messes up some of my functions, and I THINK it's because the onChange function fires twice. Just can't figure it out.[code]Then changePage2() comes into play, but the problem is before this apparently.when I go to the URL directly, or when hitting the back button. It goes wrong when the change is triggered inside the movie.
View 0 Replies
Feb 3, 2012
I'm working on a little game, and everything is working great. Except for if you push a button, then drag, the button stays stuck. I found this is because the TOUCH_MOVE event fires then the TOUCH_END event doesn't. I've got some very simple code here, how can I fix this? Is there a function to tell if you are currently touching the button?
Code:
upButton.addEventListener(TouchEvent.TOUCH_BEGIN, upDownEvent);
upButton.addEventListener(TouchEvent.TOUCH_END, upDownUPEvent);
[code].....
View 0 Replies
Mar 24, 2010
When I run this code, I get to click on either the container "Big Box" or its contents "Poly". The associated trace states should fire but look at the tracer on "Poly" it fires twice. Why? [code]
View 2 Replies