Skip to main content
May 27, 2013
Answered

Action Script code to restart air app at regular time intervals

  • May 27, 2013
  • 1 reply
  • 730 views

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

This topic has been closed for replies.
Correct answer kglad

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

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
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

}

May 27, 2013

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

kglad
Community Expert
Community Expert
May 28, 2013

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();

}