ActionScript 3.0 :: Safely Switching Focus During Backspace Key Down Event?
Sep 1, 2008
I have a simple form that I'm building. It has a variable length list of entries, and I'm using a TextInput for each entry.
Because the list is variable in length, I'm allowing the user to delete elements from the list. One of the ways they can do this is to press the backspace key when the cursor is in an empty TextInput. I am handing KeyboardEvent.KEY_DOWN and checking for the backspace key, to accomplish this.
The problem I am having is that after I remove the deleted TextInput, I want to leave the focus in the TextInput above. I can do this using 'setFocus', and that works fine, however it seems that the backspace is still processing, and so after the focus is set, the content of the TextInput is delete which I don't want.
To get around this, I've created a one-shot timer with a 0ms delay which changes the focus after the KeyDown event has completed.
My workaround is successful, but feels very heavy handed. Is there a better way to achieve the same effect?
View 1 Replies
Similar Posts:
Mar 21, 2010
If I have a prompt window where I am asking the user for some input, is there some way I can prevent them from switching window focus to the other windows in my application? (switching to other applications is fine) I'd actually have preferred if the window didn't appear in the taskbar at all, but utility windows look awful and I'm using system chrome so lightweight is out.
View 5 Replies
Oct 25, 2011
How to call removeEventListener when I don't know the function which is the event handler?
View 3 Replies
Jan 22, 2012
I am working on a side scroller. The point is to collect 10 coins, and on that event, a door will open. I need to make it so when the character HitTest the door, while dooropen = 1 to go to the scene 2 and play it. Here is the code I have.
onClipEvent(load){
var dooropen: Number = 0;
}
onClipEvent(enterFrame){
[Code]....
View 3 Replies
Aug 31, 2007
I have a mouse trailer that lets the user smear paint splats over the stage area. The trailer works fine stand alone, but when I attach a listener to give the user the option to turn the trailer on/off via a pair of buttons, the trailer turns on/off but now fails to follow the mouse cursor!
Here's the trailer code... (I've attached the CS3 file just in case)
Code:
i = 0;
onMouseMove = function() {
var cur_x = _xmouse;
[Code].....
View 1 Replies
Jul 18, 2011
Is there a 'onFocus' event for individual radio buttons, or is it limited to the radiobutton group ?If there is a focus event for the buttons, how to I set it up ? I've set up an event listener with an 'onFocus' event, 'gotFocus' event, 'focus' event and nothing is triggered...
View 3 Replies
Jul 9, 2010
I'm having an issue where I don't get a "FOCUS_OUT" event called when I click around the stage. I do get the "FOCUS_IN" event when I click the TLFTextField.Here is some of the code I have:
txt_search.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
txt_search.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
private function onFocusOut(e:FocusEvent):void[code]...
View 1 Replies
Jan 17, 2011
Is it possible to override the default focus event on the in-built TextField class? So for example when a textfield gains focus a custom event is triggered rather than the default one? I know we can use the onSetFocus event, however we have over 1200 swfs that use TextFields so want to do it on a global scope rather than having to modify each individual swf. that on an Android tablet selecting a TextField brings up the android keyboard that not only shrinks the flash content, but defaults to the alpha keyboard when all we want is numeric (it's a Maths app).
View 1 Replies
Oct 16, 2011
I'm trying to add a focus event to a text box. For some reason the Focus_in works fine, but when I go to add the focus_out event it tells me that the name I am trying to assign to the listener is an undefined property???? of course it is I just created it and the one I created just before this for the same text box works just fine. here is the code: midTermGrade_txt.addEventListener(FocusEvent.FOCUS_IN, onFocusBevel);midTermGrade_txt.addEventListener(FocusEvent.FOCUS_OUT, offfocusbevel);As stated alread the first line of code works perfectly
View 10 Replies
Dec 18, 2009
I have a custom TitleWindow component that is registered to listen for keyboard events from the user (so that esc closes the window, enter saves, etc.). However, in my testing I've found a couple cases where my keyboard event handlers don't fire. My best guess as to why this is happening is that there is some child component somewhere that has stolen focus and is stopping the keyboard events from propagating.
Unfortunately, due to the large number of components in my TitleWindow, I have no good way of knowing who has stolen the focus. My question then is, are there any good tips / techniques / tools for debugging focus issues and event propagation in Flex? Basically, I need something that will tell me who has the focus at any given time and who's handling an event at any given time... is that possible?
View 1 Replies
Jan 17, 2011
Is it possible to override the default focus event on the in-built TextField class? So for example when a textfield gains focus a custom event is triggered rather than the default one? I know we can use the onSetFocus event, however we have over 1200 swfs that use TextFields so want to do it on a global scope rather than having to modify each individual swf.
The idea is that on an Android tablet selecting a TextField brings up the android keyboard that not only shrinks the flash content, but defaults to the alpha keyboard when all we want is numeric (it's a Maths app).
View 1 Replies
Sep 16, 2010
I have done an ovveride of the standard TextInput component In this component I have :
addEventListener( FocusEvent.FOCUS_OUT, handleFocusOut ); My method is trigerred when the field loose focus for another field (nice)Problem : It is trigerred alose when the whole flex application lose focus (when my field has the current focus inside my form)
View 2 Replies
Jan 15, 2011
My Sprite class keeps losing focus when I click with the mouse - specifically after the MOUSE_DOWN event (before the click is complete).
I have set mouseEnabled to false on the children, no change. I added a listener for FOCUS_OUT and noticed that the FocusEvent.relatedObject property is NULL, which is confusing me - doesn't that mean there is no new focus target, the focus is just getting lost?
The exact sequence of events I get, by tracing them, as I click:
[FocusEvent type="focusOut" bubbles=true cancelable=false eventPhase=2 relatedObject=null shiftKey=false keyCode=0]
[MouseEvent type="mouseDown" bubbles=true cancelable=false eventPhase=2 localX=355
[Code]....
View 2 Replies
May 13, 2010
I need to return to my original function after capturing an event (downloading something) with another function. The original function needs to return a value, which depends on the downloaded data. So, I'd like to pause original function for the time needed for the download and the eventhandler function to complete it's work, and resume it afterwards.
The obvious way is to set a flag value (both the original function and the eventhandler are within the same class) and make the original function check it until the eventhandler function changes the flag. But that would be wasteful, and my AS is slow enough already:) [other parts of the application utilise some heavy graphics]. Is there another way? Like an event that gets captured "in the middle" of the function? Or some other form of flow control?
View 2 Replies
Mar 27, 2005
If I put in some code like this...
Code:
this.onKeyDown = function():Void {
trace (Key.getCode());
}
Key.addListener(this
...it doesn't detect anything when I press the backspace key, or the enter key. What is wrong? How do I detect these?
View 4 Replies
Jul 16, 2006
im makeing a dynamic input field my code looks like this
Code:
on(keyPress "a") {
box.text += "a";
[code].....
View 3 Replies
Jul 27, 2009
How would you make a button event call a function which acts like a backspace keyboard event delete.I tried faking the dispatch keyboard event "keyup" "keydown" with keycode 8 and keynumber 8 without success.No other way than doing it by hand with begin and end select index plus substr ?I have a textinput i just want to add a button acting like a backspace.
View 2 Replies
Sep 3, 2010
I have noticed this bug when developing my flash application on a windows platform. If typing text in to a text box in a Flash swf running in Safari 5 browser on Windows then press backspace the browser will jump to the previous page in history rather than performing the function that backspace is supposed to - here is a link to another report of this apple bug.URL...
View 4 Replies
May 10, 2010
I have got everything working on a virtual keyboard, except the backspace button. Does anybody know of a method that uses the .appendTest() to delete the last character typed by a user???
Inputtext field is named "dirsearch"'
_del is the instance name of the button that hopefully act as a back space button.
my code so far:
_del.addEventListener(MouseEvent.CLICK, deletelast);
function deletelast(e:MouseEvent):void{[code]..
View 2 Replies
Jul 3, 2009
Running the latest version flex Builder 3.02
Ive only been able to find 1-2 other people with this bug and as it stands the application is unusable. [URL]
View 1 Replies
Mar 8, 2011
[Code]...
when i have this line active(the red one) it gives me automatic focus, so no clicking to be able to detect key input so i got that going for me which is nice BUT when i have it active(not commented out) i get this big yellow line which goes away when i click it(seeBelow)
View 1 Replies
Oct 20, 2011
I have the follwoing code to control a Flash-based presentation but BACKSPACE and ENTER lkey are not working. I am puzzled. PD: All the rest of the keys works fine.
[Code]...
View 3 Replies
Jul 13, 2009
Does anyone know how to do this in AS3?
View 3 Replies
Sep 14, 2010
can I set the keyboard focus for a TLFTextField? I tried stage.focus = myTLF but there is no cursor...
View 2 Replies
Feb 1, 2011
I have come against a problem whit this tutorial:i cant erase my lines now i have a bit more then just a pencil and a hole menu whit it,now i have even download the tutorial file and in the file it doesnt work eitheri use flash cs4.ow i dont whant to have anything complex like actionscript 3but still an solution and if it isnt to hard can i make a eraser to?
View 3 Replies
Mar 16, 2009
I have a TextField called textField on the first frame of the main timeline, and this simple code.
Code:
import flash.events.KeyboardEvent;
import flash.events.FocusEvent;
[code]......
View 2 Replies
Oct 22, 2011
I want to restrict Delete key, Backspace key, and Enter Key in TextArea.ow to restrict these 3 keys.
View 1 Replies
Mar 26, 2010
I am implementing a flex auto-suggest combobox - as the user types in each character: Consider the string 'Stackoverflow' and user input = 'st'
1) the data provider is filtered to show all items starting with 'st'
2) text is set to auto-suggest string such that the un-typed part is highlighted.
So for instance, the combobox text may contain st'ackoverflow', where 'ackoverflow' is highlighted using setSelectedIndex()When I hit back-space or delete, and check the 'this.text' value, I expect that the last un-highlighted character ('t' in the above case) gets deleted and the data provider is filtered to show all items starting with 's'. However the text property contains 'st', as before
View 2 Replies
Nov 17, 2009
How can I write this snippet of code for a button in AS3?I'm having a hard time completing this.Here is my AS2 code.It is attached to a button.[code]
View 2 Replies
Aug 23, 2011
i made a character that has 5 frames:
1st nothing
2nd axe
3rd spear
4th sword
5th bow
i am trying to make it so the weapons will switch when i press the a,b,c,d,e button on the keyboard( i will figure out the actual button l8r) i have made a mc clip button to make it switch which works but i cant figure out how to do it from the key board
[Code]...
View 1 Replies