Copy link to clipboard
Copied
Hi,
I have already posted a similar question to this one but wasn't able to solve my problem yet.
I have a few applications for museum kiosks that I want to restart after a few time without any touch.
I was using an AS3 that isn't working. It looks like it's working but after a few minutes it goes wierd and goes back to frame 1 even if there is someone touching the screen.
The AS3 I was using is:
var myTimer:Timer = new Timer(30000, 1);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.start();
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveMouse);
function moveMouse(evt:MouseEvent):void {
myTimer.reset();
myTimer.start();
}
function timerHandler(evt:TimerEvent):void {
gotoAndPlay(1);
}
Thank you all
AB
Hi again!
Thanks for sharing your FLA.
I think the problem happens because everytime the timeline is sent to frame 1, another timer is set, started and a mouse listener is added to the stage.
In this way, things get executed more than once.
What you can do is to run the timer intialization code only when the app is launched.
Like this:
...stage.displayState = StageDisplayState.FULL_SCREEN;
if (!this.hasBegun)
{
var myTimer:Timer = new Timer(30000, 1);
myTimer.addEventListener(TimerEvent.TIMER, timerH
Copy link to clipboard
Copied
Hi.
Can you share your FLA? There's no problem if you have to use placeholders and/or just part of the content.
Regards,
JC
Copy link to clipboard
Copied
Hi,
I didn’t note this answer
Are you still available to help me? How can I share my file with you?
Thank you
Ana
Copy link to clipboard
Copied
Hi.
No problem.
You can upload to Google Drive, Dropbox, WeTransfer, or something like these.
Regards,
JC
Copy link to clipboard
Copied
Thank you for your help,
Here is the original file, probably with many errors, maybe you can find what I am doing wrong .
[link removed by a moderator]
Thank you
AB
Copy link to clipboard
Copied
Hi again!
Thanks for sharing your FLA.
I think the problem happens because everytime the timeline is sent to frame 1, another timer is set, started and a mouse listener is added to the stage.
In this way, things get executed more than once.
What you can do is to run the timer intialization code only when the app is launched.
Like this:
stage.displayState = StageDisplayState.FULL_SCREEN;
if (!this.hasBegun)
{
var myTimer:Timer = new Timer(30000, 1);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.start();
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveMouse);
this.hasBegun = true;
}
function moveMouse(evt:MouseEvent):void
{
myTimer.reset();
myTimer.start();
}
function timerHandler(evt:TimerEvent):void
{
gotoAndPlay(1);
}
Please test and see if this works.
P.S.: Probably is a good idea to remove the link to your app. Is up to you.
Regards,
JC
Copy link to clipboard
Copied
Thank you. That makes sense
I will try just now and let you know if it is working.
AB
PS - I already deleted the linked folder, is there a way of delete the link from the forum?... Thank you again.
Copy link to clipboard
Copied
Nice!
And I removed the link for you.
Copy link to clipboard
Copied
Yeeeeeeeesssssssssss!
It worked, thank you so much, this was driving me crazy.
Best regards
Ana
Copy link to clipboard
Copied
\o/
This is excellent!
You're welcome!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now