idle mode sceensaver time out for android app intrractive

Community Beginner ,
Jul 10, 2021 Jul 10, 2021

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!

 

 

Views

153

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 13, 2021 Jul 13, 2021
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...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 10, 2021 Jul 10, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

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.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

Okay. You saw the link I posted... right?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

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!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2021 Jul 12, 2021

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

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 13, 2021 Jul 13, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 13, 2021 Jul 13, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Thanks JC!!

 

this workd perfectly.  i adapted the code to my proyect and everything works fine.

 

thanks !!!!

 

o

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

LATEST

That's awesome! You're welcome!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines