Copy link to clipboard
Copied
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
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
}
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
Aha! thank you, thank you! If I have boolean variables, will I need to call the to be reset?
Copy link to clipboard
Copied
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();
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now