A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: questions about TextEvent

  1. #1
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508

    questions about TextEvent

    I want the "end result" of a user entering text but the TextEvent fires after each character is entered....is there a way to get it to wait until after the last character is entered? the main problem is that it's always one character behind, so if I've entered:

    "Jason"

    my last entry reflects:

    "Jaso"

    obviously that's not what I want!

    is there a different property or method that will give me what I want? please advise, thx!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    How do you mean finished? Does the user have to hit enter afterward, or can they just stop typing, or what?

    Here's a technique that I've used before.
    Code:
    var textTimer:Timer = new Timer(100, 1);
    tf.addEventListener(TextEvent.TEXT_INPUT, resetTimer);
    textTimer.addEventListener(TimerEvent.TIMER, doText);
    
    function resetTimer(event:TextEvent):void{
      textTimer.reset();
      textTimer.start();
    }
    
    function doText(event:TimerEvent):void{
      //do stuff in here.
    }
    This basically waits until 100ms after the user stops typing to call doText. Depending on your user you may want to raise or lower the time.

  3. #3
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    that's a good technique, thx....I'm surprised there's not more "built-in" ways to support this though!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center