I have a search field that searches on key press…so you type b and it will automatically return all the words that start with b…if you type ba it will return all the words that start with ba…and so on and so forth…what I want to do is put a delay of one or two seconds before the search actually starts after the user STOPS typing…because with large lists I am experiencing lag…so I want the search to start once the person stops typing…here is what I have…
keyListener.onKeyUp = function()
{
clearInterval(counter);
if(showLoad)
{
trace("....1");
var seconds = 2;
function Timer()
{
trace("....2");
seconds -= 1;
trace(seconds);
if (seconds==0)
{
trace("....3");
if(Key.getCode() != 38 && Key.getCode() != 40)
{
trace("....4");
//perform search function....
}
}
}
counter = setInterval(Timer, 1000);
}
}
the output trace is only the first one “…1”
Any ideas?