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

Action Script code to restart air app at regular time intervals

Guest
May 27, 2013 May 27, 2013

I am hoping someone more versed in action script 3 for air can help me!

I have an app, which I am planning to display on the ipad at an exhibition. Would I be able to add some code to the action script,
which will restart the app after a certain amount of time (say 5 minutes) if it has not been interacted with i.e. the screen has not been touched?

I would be very grateful if someone could help me with this

TOPICS
ActionScript
688
Translate
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 , May 27, 2013 May 27, 2013

you can call a function when the idle time is 5 minutes and in that function reset whatever is appropriate for your app:

var fiveMin:int = 5*60*1000;

var timer:Timer=new Timer(fiveMin,0);

timer.addEventListener(TimerEvent.TIMER,resetAppF);

timer.start();

this.addEventListener(MouseEvent.MOUSE_DOWN, resetTimerF);

function resetTimerF(e:MouseEvent):void{

timer.reset();

timer.start();

}

function resetAppF(e:TimerEvent):void{

// do whatever to reset your app

}

Translate
Community Expert ,
May 27, 2013 May 27, 2013

you can call a function when the idle time is 5 minutes and in that function reset whatever is appropriate for your app:

var fiveMin:int = 5*60*1000;

var timer:Timer=new Timer(fiveMin,0);

timer.addEventListener(TimerEvent.TIMER,resetAppF);

timer.start();

this.addEventListener(MouseEvent.MOUSE_DOWN, resetTimerF);

function resetTimerF(e:MouseEvent):void{

timer.reset();

timer.start();

}

function resetAppF(e:TimerEvent):void{

// do whatever to reset your app

}

Translate
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
Guest
May 27, 2013 May 27, 2013

Aha! thank you, thank you! If I have boolean variables, will I need to call the to be reset?

Translate
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 ,
May 27, 2013 May 27, 2013
LATEST

yes, you should reset everything so it has the value at your app's start.  that's easiest done by initializing/declaring your variable types outside a function body and then assigning their initial values inside a function body.

you can then assign the initial values when your app starts and when you want to reset by calling that function:

var i1:int;

var b1:Boolean;

var a1:Array;

var mc1:MovieClip;

function intializeValues():void{

i1=0;

b1=false;

a1=[];

mc1=new MovieClip();

}

Translate
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