-
Detecting mouse movement
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)
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++;
Let me know whether it works or if you need further help (e.g. for a smooth fading effect etc.)
-
Thank leifi. It works, but I wonder whether there will be better to use the command setInterval.
---
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;
}
Originally Posted by leifi
Let me know whether it works or if you need further help (e.g. for a smooth fading effect etc.)
I still have a lot of questions but I will return to these questions another time. Thank you again for helping.
Last edited by 3DH; 03-07-2010 at 11:21 PM.
-
Of course you can do it this way... But then it's better to use the Timer class of flash. The official documentation says:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|