Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Flex Timing issue - SetTimeout - preventDefault

Posted on 2011-03-17
2
Medium Priority
?
714 Views
Last Modified: 2012-05-11
On a textInput change event I will execute a search, but I really don't want it after every key press, only after a 2 second gap from when the user stops typing.

I was using SetTimeout, but I realize that it still executes. I thought after every new change event, the previous would be cancelled, but it doesn't.

How do I accomplish this?
0
Comment
Question by:coldchillin
2 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 2000 total points
ID: 35159293
I will recommend to declare in your class private variable and use setInterval instead

Example:

private var _textInputInterval:Number;
private var _textInputOutput:String;


private function onChange():void{
  clearInterval(_textInputInterval);
  _textInputOutput = textInput.text;
  _textInputInterval = setInterval(onChange, 2000);
  }
0
 
LVL 1

Author Comment

by:coldchillin
ID: 35183480
I see, the ClearInterval functionality is what I was missing when using SetTimeout.
0

Featured Post

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question