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

Timer to go back to frame 1 and play

Explorer ,
Jul 08, 2018 Jul 08, 2018

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

789
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 , Aug 06, 2018 Aug 06, 2018

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

...
Translate
Community Expert ,
Jul 09, 2018 Jul 09, 2018

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

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
Explorer ,
Jul 16, 2018 Jul 16, 2018

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

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 ,
Jul 16, 2018 Jul 16, 2018

Hi.

No problem.

You can upload to Google Drive, Dropbox, WeTransfer, or something like these.

Regards,

JC

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
Explorer ,
Aug 06, 2018 Aug 06, 2018

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

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 ,
Aug 06, 2018 Aug 06, 2018

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

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
Explorer ,
Aug 06, 2018 Aug 06, 2018

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.

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 ,
Aug 06, 2018 Aug 06, 2018

Nice!

And I removed the link for you.

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
Explorer ,
Aug 06, 2018 Aug 06, 2018

Yeeeeeeeesssssssssss!

It worked,  thank you so much, this was driving me crazy.

Best regards

Ana

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 ,
Aug 06, 2018 Aug 06, 2018
LATEST

\o/

This is excellent!

You're welcome!

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