A quick way to detect Idleing in flash actionscript 2

So I had this customer who asked me to do an flv player for his site, he wanted the controls of the player to fade out when the user is idle, now flash does not have an onIdle event of any kind and the only way around this was to trigger a signal when the mouse kept its position (did not move) for more than 3 second (or x seconds, customizable) or keys has not been pressed for x seconds.

Again, flash does not have an onMouseStill event so I had to do it this way:


this.onMouseMove=function(){
clearTimeout(toInt);
fadeControlsIn();
toInt=setTimeout(fadeOut,3000);

}
function fadeOut(){
//fading out code goes here...
}
function fadeControlsIn(){
/fading in code goes here....

}

A similar approach can be applied to keypresses.

Hope this helps.

Leave a Reply