• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

idle mode sceensaver time out for android app intrractive

Explorer ,
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

614

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

Community Expert , 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
...

Votes

Translate

Translate
LEGEND ,
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

Votes

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
Explorer ,
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.

 

 

Votes

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
LEGEND ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

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

Votes

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
Explorer ,
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!

Votes

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
LEGEND ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Votes

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
Explorer ,
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

 

 

 

Votes

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 Expert ,
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

Votes

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
Explorer ,
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

 

Votes

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 Expert ,
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

Votes

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
Explorer ,
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

Votes

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 Expert ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

That's awesome! You're welcome!

Votes

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 ,
May 30, 2022 May 30, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

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