Before we start you need to be familiar with MouseEvent and Timer classes.
var _timer:Timer = new Timer(5000);
_timer.addEventListener(TimerEvent.TIMER, ShowMsg, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_MOVE, StopTimer, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, StopTimer, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, StopTimer, false, 0, true);
trace("There is no activity");
The first thing I’ve done is to setup a Timer object to count up to 5 seconds ( you can change that to what ever numer of seconds you want ).
The timer object also has an event listener so we can know when the 5 seconds are over.
I have setup some event listeners that will help detecting any actions of the mouse on the Stage ( MOUSE_DOWN, MOUSE_MOVE and MOUSE_UP )
If during those 5 seconds nothing happens ( mouse is not moved or performs a click ) ShowMsg() function will be fired up and give you a message of inactivity.
If the mouse is moved the StopTimer() function will be activated and reset timers count.
This is a useful and easy way to detect user activity.