Copy link to clipboard
Copied
Hi, I'm building an interactive station. with different menus and videos. I have a startup screen that is a movieclip symbol with a video playing. I need help creating a timeout code to return the app to the initial state after 3 minutes of inactivity (no mouse movement or gestures).
will appreciatte any help.
thanks!
I'm not sure why.
Animate isn't recognizing my device so I cannot debug the app.
In this case let's go with the setTimeout approach. As an example, I have a very simple app that has two frames: the first one containing a start button and in the second one a timeout of 5 seconds is set and if the user doesn't touch the screen within 5 seconds the timeline returns to frame 1. The code is like this:
Frame 1:
import flash.events.MouseEvent;
import flash.utils.clearTimeout;
import flash.utils.s
...
Copy link to clipboard
Copied
Do you're saying you want to set some sort of timeout?
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
Copy link to clipboard
Copied
yes, when the interactive app is incative for 3 minutes (no touch gestutre or mouse events) should go to initial state. or make a movieclip visible.
Copy link to clipboard
Copied
Okay. You saw the link I posted... right?
Copy link to clipboard
Copied
yes , im trying to follow the info but nort sure how to integrate all ino a code that works. I dont have too mouch knowledge in coding.
any help on how to creat the code that works will be appreciated.
Im working on Animate - AIR for Android
thanks!
Copy link to clipboard
Copied
The same function exists in AS3.
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html
Copy link to clipboard
Copied
thanks, sill having trouble to understand.
i tryed a couple of codes to see if i can understan how it works. but i get an error:
Scene 1, Layer 'Layer_1', Frame 1, Line 1, Column 9 1037: Packages cannot be nested.
if you could point me directly to a code that would work for air android.
thanks
Copy link to clipboard
Copied
Hi.
The NativeApplication class has some really useful methods to handle these kind of situations. Have you tried it? You could write something like this:
import flash.desktop.NativeApplication;
import flash.events.Event;
function userIdleHandler(e:Event):void
{
trace("back");
// your reset code here
}
NativeApplication.nativeApplication.idleThreshold = 180; // time in seconds
NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE, userIdleHandler);
Please let us know if this works for you.
Regards,
JC
Copy link to clipboard
Copied
Thanks JC!
the code works perfectly when tested in animate (using air debug launcher(mobile))
but when i publish APK and install on android the timeout doesnt work.
could irt be a problem with the publish settings?
thanks!
o
Copy link to clipboard
Copied
I'm not sure why.
Animate isn't recognizing my device so I cannot debug the app.
In this case let's go with the setTimeout approach. As an example, I have a very simple app that has two frames: the first one containing a start button and in the second one a timeout of 5 seconds is set and if the user doesn't touch the screen within 5 seconds the timeline returns to frame 1. The code is like this:
Frame 1:
import flash.events.MouseEvent;
import flash.utils.clearTimeout;
import flash.utils.setTimeout;
var delay:uint = 5000;
var timeout:uint = 0;
function main():void
{
stop();
startButton.addEventListener(MouseEvent.CLICK, start);
stage.addEventListener(MouseEvent.MOUSE_DOWN, wake);
}
function start(e:MouseEvent):void
{
gotoAndStop(2);
}
function wake(e:MouseEvent):void
{
clearTimeout(timeout);
timeout = setTimeout(idle, delay);
}
function idle():void
{
gotoAndStop(1);
}
main();
Frame 2:
wake(null);
The FLA / source / code / files is in here:
https://github.com/joao-cesar/adobe/tree/master/animate%20cc/as3/idle
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Thanks JC!!
this workd perfectly. i adapted the code to my proyect and everything works fine.
thanks !!!!
o
Copy link to clipboard
Copied
That's awesome! You're welcome!
Copy link to clipboard
Copied
Hi JC,
Is it possible to adapt this code so it will work for Html 5 Canvas. I am creating a similar online intractive app in web page.
Thanks
M