Example: If you do nothing with the mouse for about 3 seconds, hide the thumbnails. Otherwise, show a thumbnail.
How to do something like this?
Printable View
Example: If you do nothing with the mouse for about 3 seconds, hide the thumbnails. Otherwise, show a thumbnail.
How to do something like this?
You have to create a timer variable that will be reseted when the mouse moves. If the timer is bigger than the defined amount, the thumbnail will be hidden.
Here's a quite example (I haven't tested it but it should work)
Let me know whether it works or if you need further help (e.g. for a smooth fading effect etc.)Code:// Copy this into the "When movie starts" script.
var timer:uint = 0;
var lastMouseX:uint = 0;
var lastMouseY:uint = 0;
const timerLimit:uint = 60; // in frames
// Copy this into the "On every frame" script
if(mouseX != lastMouseX || mouseY != lastMouseY)
timer = 0;
element("thumbnail").visible = !(timer >= timerLimit);
lastMouseX = mouseX;
lastMouseY = mouseY;
timer++;
Thank leifi. It works, but I wonder whether there will be better to use the command setInterval.
---
I still have a lot of questions but I will return to these questions another time. Thank you again for helping.Code:done = function()
{
clearInterval(counter);
element ("thumbnail")._visible = false;
}
counter = setInterval(done, 3000);
_root.onMouseMove = function()
{
clearInterval(counter);
counter = setInterval(done, 3000);
element ("thumbnail")._visible = true;
}
Of course you can do it this way... But then it's better to use the Timer class of flash. The official documentation says:
Quote:
Instead of using the setInterval() method, consider creating a Timer object, with the specified interval, using 0 as the repeatCount parameter (which sets the timer to repeat indefinitely).
Source: http://livedocs.adobe.com/flash/9.0/...ml#setInterval