So i wanted to create an Idle timer for my OS application and reached to this ..
Enjoy ..

 

//stop Time line Whenever its needed …
stop();

//Declare our Vars outside the functions
var X:Number = new Number();
var Y:Number = new Number();
var X2:Number = new Number();
var Y2:Number = new Number();
var timer:Number = 0;
var Idle:Number = 10;
var Idle2:Number = 20;

//Mouse Listener…
// Creates listener object, MouseListener.
var MouseTrack:Object = new Object();
// functions for listener object , If User is Not Idle Anymore Execute the Actions
MouseTrack.onMouseMove = function() {
trace(“Mouse Moved”)
timer_txt.text = “user is Not Idel”;
Mouse.removeListener(MouseTrack);
clearInterval(intervalID);
startInterval();

}

//Create a Text field and assign its x & y Positions …
this.createTextField(“timer_txt”, this.getNextHighestDepth(), 0, 0, 100, 22);
function updateTimer(){
timer += 1;
trace(timer);
if(timer == Idle) {
getMouse()

}else if(timer == Idle2) {
checkMouse();

}

}

//get Mouse X & Y Positions for the first 10 Sec
getMouse =function () {
X = _root._xmouse;
Y = _root._ymouse;
trace(X);
trace(Y);
}
//Get the Mouse X & Y Positions for the next 10 sec [ 20 sec total ]
checkMouse = function() {
X2 = _root._xmouse;
Y2 = _root._ymouse;
trace(X2);
trace(Y2);
if (X2 == X && Y2 == Y) {
trace((X2 == X && Y2 == Y));
clearInterval(intervalID);
Mouse.addListener(MouseTrack);
timer_txt.text = ” User is Idle “;

}else{
//reset timer
timer =0;
}

}

function startInterval() {
timer = 0;
_global.intervalID= setInterval(updateTimer, 1000);
}

startInterval();