I got this working, and then desided that due to the nature of the app I am building would create my own TextInput extending the native TextInput.

This then would catch the "keyUp" event and prevent the native one from bubbling and then dispatch it's own keyUp event after X milli-seconds.

I have gotten it working to the point where it now dispatches both... argh.
So what I am trying to do is prevent the native event from bubbling, and can't find how to do this.

This is the code I have in the eventListener on the Key up:

private function handleKeyUp(event:Object):void{                       
            event.stopPropagation();//this didn't work
            event.stopImmediatePropagation();//and this didn't either...
            _tmKeyUp.reset();
            _tmKeyUp.start();                       
            //remove the eventlistener
            removeEventListener("keyUp",handleKeyUp);                   
        }


On 6/2/06, David Harris <[EMAIL PROTECTED]> wrote:
That's awesome thanks Sonja!
I'll get that working today!


On 6/2/06, Sonja Duijvesteijn < [EMAIL PROTECTED] > wrote:
Sorry, it send the mail too early:


private var timeSinceKeyPress:Timer;

private function init() {
    textfield.addEventListener(KeyboardEvent.KEY_UP,keyPressed);
   
     timeSinceKeyPress = new Timer(500);
     timeSinceKeyPress.addEventListener(TimerEvent.TIMER, stoppedTyping);
}

private function keyPressed(event:KeyboardEvent):void {
    timeSinceKeyPress.reset();
    timeSinceKeyPress.start();
}

private var stoppedTyping(event:TimerEvent):void {
    // whatever it needs to do.
}


So what it does is: When the first character is typed it starts a timer to check wether that's 500 ms ago already, if so, stop checking and do whatever you do. If someone types in between the timer is reset.


Code isn't checked so might be some slight mistakes, but this is the way you should look for a solution.

Kind regards,
Sonja Duijvesteijn

2006/6/1, Sonja Duijvesteijn < [EMAIL PROTECTED]>:
I don't have any working code but it would be something like:

private var timeSinceKeyPress:Timer;

private function init() {

}

2006/6/1, David Harris < [EMAIL PROTECTED]>:
Hi Guys,

Does anyone have an example like this:

I have a text input box and the user types in information.
When they have finished typing I would like to fire off an event.

The approach I would like is that once they have stopped typeing for
500ms, the event gets fired.

Has any done something like this and would like to shared code?

Cheers,

David


------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~->

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to