Time-out in flash
- Started
- Last post
- 31 Responses
- Inkyfingers
I need my flash movie to detect the activity of the user. I need the movie to skip to a screensaver after a certain time of inactivity i.e. if the movie isn't being used the screensaver kicks in. Any ideas? Thanks in advance.
- ********0
have a counter adding one each time.
check the mouse position or click, everytime it has change set the counter to 0
if the counter> X amount, then do your screensaver thing
- ********0
an example... http://www.universaldesignstudio…
if you leave the site for a while
- Inkyfingers0
it is a touch screen kiosk. Is there anyother ways of achieving this? Any ideas?
- ********0
that still tracks a mouse though doesn't it? or a click... so no difference.
- Inkyfingers0
I have got so far but it isn't working. Any ideas where I'm going wrong?
var counter=0
for (counter=0; counter
- ********0
if (xmouse !=_xmouse or ymouse_ymouse){
counter=0;
} else {
counter++
}if (counter>200){
screenSaverMode=1;
} else {
screenSaverMode=0;
}xmouse = _xmouse;
ymouse = _ymouse;
- UndoUndo0
create a function that shows yr screensaver.
set an interval with a timelength you want for the timeout.
when the function is called clear the interval.
use the onMouseMove event handler to clear the interval and then reset it back to the original time period
- joyride0
exactly what ^ said +
don't forget the function for when the screensaver is on. So onMouseMove delete or hide the screensaver again.
- alloyd0
Use setTimeout instead of setInterval. That's if your using Flash 8. Just one step easier. You don't have to clear the interval once it expires. If you want to end it early just use clearTimeout.
Then do what Undo says.
- Inkyfingers0
Hi there. Still struddling. Anyone kind enough to have a butchers at this?
checkLoaded = function(){
if (xmouse != _root._xmouse or ymouse != _root._ymouse){
clearInterval(intervalID);
} else {
gotoAndStop(5);
}
}intervalID = setInterval(checkLoaded, 10000);
xmouse = _root._xmouse;
ymouse = _root._ymouse;stop();
- Inkyfingers0
The code I broadcast earlier seems to work but only once i.e. if you move your mouse it will clear the interval OR if you do not touch your mouse then it will timeout and load the screensaver.
I need to be able to reset the interval i.e. move your mouse clear interval reset and look for inactivity onve again. Any clues?
- UndoUndo0
whats on frame 5?
- Inkyfingers0
thats where the screensaver is
- UndoUndo0
here try this
you'll need to make a transparent MC on the root called "mouseMC"
which is the active area detecting mouse movement. i havent tested it but it "should" work
- st33d0
*slaps UndoUndo on wrist for using _root
I've done a version which makes a dummy MC to monitor this situation. It requires nothing from you but the name of the function you want to fire on 'idle'.
- UndoUndo0
*slaps UndoUndo on wrist for using _root
haha you AS snob :)
- joyride0
if you want to get AS snobby... onEnterFrame???? you can do better then that! setInterval would be a better solution, less processor intensive.
- caseyc0
Damn, thanks guys for the flash-nerd comedy this morning. I love st33d calling out UndoUndo for using _root, then in his code he is evaluating everything ie:
this["mouseDetection"]["event"] = func;
Awesome.
- st33d0
Dude - If you put that function into an AS2.0 class - it will still work. That's why the loads of evals.
Otherwise Flash won't compile it. And I work entirely from AS2.0 classes.
The onEnterFrame is just proof of concept. I was expecting someone to post a setInterval version of my script.
You dissappointed me.
All of you.
*folds arms, shakes head in dissapproval
- lvl_130
please see "know it alls" thread.
:)