Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Flex Timing issue - SetTimeout - preventDefault

Posted on 2011-03-17
2
Medium Priority
?
706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

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…
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

670 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