I have been searching for a while on how to make my Kiosk go to frame 1 if it is idle, and have found someting that seems helpfull, but it is from a few years ago. [L=Kiosk Link] http://www.flazoom.com/cooler/1043345201%2C45422%2C.shtml[/L] Is there a new better way to do this, and also i can't seem to get this example to work, can anyone help me please !! i am pulling my hair out trying to figure this out ! Thanks for any help !
stop(); this.onEnterFrame = function(){ _global.mouseXPosition = _root._xmouse; //save mouse position to a global variable _global.mouseYPosition = _root._ymouse; //trace(mouseYPosition); //if you want to test it... updateAfterEvent(); //reset } checkMouse = setInterval(whereMouse,1000); //look at the mouse position every second function whereMouse(){ oldMouseX = _global.mouseXPosition; // get the current mouse X position for this function oldMouseY = _global.mouseYPosition; // get the current mouse Y position for this function // trace(oldMouseX + ","+ oldMouseY); //just to test it if(_root._xmouse==oldMouseX && _root._ymouse==oldMouseY){ //if the mouse hasn't moved for a second.... gotoAndPlay(1); } } If you want the mouse to be idle for a longer period of time, just change the 1000 to 5000 (for 5 seconds). Also, if you want to delay it (like a "grace" period), just add a variable called "counter" in the function, and increment it (counter++). Then add an if statement that must be satisfied before you gotoAndPlay(1): if(counter>=20){ //a 20 second grace period gotoAndPlay(1); }
stop(); this.onEnterFrame = function(){ _global.mouseXPosition = _root._xmouse; //save mouse position to a global variable _global.mouseYPosition = _root._ymouse; //trace(mouseYPosition); //if you want to test it... updateAfterEvent(); //reset } checkMouse = setInterval(whereMouse,1000); //look at the mouse position every second function whereMouse(){ oldMouseX = _global.mouseXPosition; // get the current mouse X position for this function oldMouseY = _global.mouseYPosition; // get the current mouse Y position for this function // trace(oldMouseX + ","+ oldMouseY); //just to test it if(_root._xmouse==oldMouseX && _root._ymouse==oldMouseY){ //if the mouse hasn't moved for a second.... gotoAndPlay(1); } } If you want the mouse to be idle for a longer period of time, just change the 1000 to 5000 (for 5 seconds). Also, if you want to delay it (like a "grace" period), just add a variable called "counter" in the function, and increment it (counter++). Then add an if statement that must be satisfied before you gotoAndPlay(1): if(counter>=20){ //a 20 second grace period gotoAndPlay(1); }
Thanks Pazzoboy. Very much appreciated. Been at the same thing for many hours.
pazzoboy This is great man, but I got a quick question on it... I'm using it on an MC to remove the MC after 5 seconds... Now is the a ways I can add some code to another MC or button that forces the count back to 0 to keep the MC on the stage, or to force the count to 5000 to remove the MC...? If I'm not being clear enough, please tell me. I will clarify/
Yup, easy. On the other MC, for example, if you want a click to stop it, just do: on(release){ clearInterval(_root.checkMouse); } To keep the MC on stage, and give the user five more seconds (if you're using a counter): on(release){ _root.counter=0; } .
Hi, I found a glitch in how I am using your script from above. I have a touch screen kiosk with several scenes. I'm was using your script to send the playhead to the frame labled "Begin" if kiosk is idle for a set period of time. The time I have set to 20 seconds for development. In the production model it will be more like 3 minutes. I'm finding that the user of the touch screen kiosk will sometimes be sent back to "Begin" before it is time. Therefore I'm trying to add to your script to make a timer start if no mouse movement for 20 seconds. However this script doesn't work the way I'm intending either. Can you tell where the problem is in this script and if this is the correct way to solve the premature move to "Begin"? :) stop(); this.onEnterFrame = function(){ _global.mouseXPosition = _root._xmouse; _global.mouseYPosition = _root._ymouse; updateAfterEvent(); } checkMouse = setInterval(whereMouse, 1000); function whereMouse(){ oldMouseX = _global.mouseXPosition; oldMouseY = _global.mouseYPosition; if(_root._xmouse==oldMouseX && _root._ymouse==oldMouseY){ _root.timer = getTimer(); } } whatTime = setInterval(checkTime, 1000); function checkTime() { if (( getTimer() - _root.timer) > 1000 * 20 ) { _root.gotoAndStop("Begin"); clearInterval(whatTime); clearInterval(checkMouse); } }
Hmmm, no time to play with it now..but try putting whatTime = setInterval...... inside the "if" statement in the other function, just after the _root.timer = getTimer(); line. You're executing the whatTime interval right away, when it should only be called when there is no mouse movement when checkMouse runs, right?
pazzoboy I tried the addition you posted... Thing is it has no effect... If a user mouses over the same or multiple buttons a few times, the Interval decreeses... (the result my MC disapears way before 5 sec... more like .5 sec...) Maybe you can tell me what, if anything I've done wrong..?
For some reason I can't download this zip file. Please email it to me at hart_at_mail_dot_rochester_dot_edu
Good Morning. Thanks for the suggestion. I tried putting whatTime = setInterval...... inside the "if" statement in the other function, just after the _root.timer = getTimer(); line. It didn't work when re-entering the frame the way I had it set up. I'm still working through the newbie learning curve. It was a tough decision to shy away from this script after so much time invested. Cause I really wanted it to work. :) But the time is becoming an issue. I found another script and have altered it. It appears to function the way I need it for the kiosk. Again thanks Pazzoboy for getting me to think. Regards stop(); // Time value, in milliseconds, after which, failing any mouse movement, an action is to occur. numMouseTimeoutMS = (1000 * 10); // Define what is to happen should the mouse be moved. this.onMouseMove = function() { // Clear preceding setInterval ID. clearInterval(MouseID); // Set new interval. MouseID = setInterval(MouseCheck, numMouseTimeoutMS); }; // Function run by setInterval. MouseCheck = function () { // Clear interval. clearInterval(MouseID); // Whatever action is supposed to happen on timeout (go to "Begin"). gotoAndStop("Begin"); };
Please post a link to the script or a copy of yours... Just incase anyone else runs into this issue, :-) Also the more script I see the more I learn about AS...
Thanks GTW, I greatly appreciate it! Thanks you again pazzboy as well.
Don't see what you're looking for? Try a search.
|