Get Timer (I think)

Hi guys,
I am needing to create a movie with preloaders and transitions, fine.
The movie will be embedded into a web page, with HTML hyperlinks in the page.
But my client needs to me to make this movie in such a way that if none of the links, whether in the swf or on the web page are click for two minutes, then the movie will go into “screensaver” mode, and flip through a series of images (ie: gotoAndPlay a specific frame or series of frames).
So I think that there must be an action or script i can use in the movie to detect whether the movie has been loaded for two minutes ???
Am I making myself clear ?
Help much appreciated.
Dave

To accomplish this you need 2 things, 1. Knowing when interaction happened in the flash movie. 2. Check if time elapsed since the last interaction is greater than threshold. Here’s some sample code.


IDLE_MS = 2*60*1000;// 2 minutes

function onTick () {
	if (getTimer () - this._iLastInteract > IDLE_MS) {
		this.onIdle ();
	};
};

function start () {
	Mouse.addListener (this);
	Key.addListener (this);

	this._iTickId = setInterval (this, "onTick", 1000);
	this.onInteract ();	
};

function onInteract () {
	this._iLastInteract = getTimer ();
	// you will need to have some code here to come out of the screensaver mode.
};

function onIdle () {
	// add idle code here to perform the screensaver switch.
};

function onKeyDown () {
	this.onInteract ();
};

function onMouseDown () {
	this.onInteract ();
};

start ();

You might want to add additional event handlers like for mouse move, to take this further.

Thanks a stack mate . . .
I THINK I understand that ???
I will give it a bash, quick one though, will the onMouseDown etc call the action if the mouse is clicked ANYWHERE, even off the movie ?

I don’t think so. If browser focus is outside the flash movie, the mouse down event won’t be picked up.