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

How do I trigger an event in Adobe Animate based on the current time?

New Here ,
Aug 12, 2019 Aug 12, 2019

In short, I have a movie clip on the stage that has 12 frames (all with actionscript set to stop on each frame)

I would like a button to Get the Hour of the current time, and then go to that frame number.

ie, if it's 3,30, I want the movie clip to go to frame 3, i it's 11.00, I want themovie clip to go to frame 11 etc.

I can make events occur on 'direct information' I write in my code, but I can't work out how to set an event to occur as the result of a 'trace' - that being the 'get hour'.

Your help would be greatly appreciated as I am in the process of creating a 'time telling' game for my nephew.

Cheers

436
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 12, 2019 Aug 12, 2019

Hi

I moved your query from Adobe Creative Cloud to Adobe Animate where you will get a better response.

~ Jane

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 12, 2019 Aug 12, 2019

Hi.

If I understood correctly what you want, your code could be something like this:

import flash.events.MouseEvent;

function hourToFrame(e:MouseEvent):void

{

    var date:Date = new Date();

    var hour:uint = date.hours; // 'date.hours' is an integer from 0 to 23

  

    // here we limit the value to the 12-hour clock format

    if (hour > 11)

        hour = hour - 12;

  

    numbers.gotoAndStop(hour); // 'numbers' is the 12 frames Movie Clip instance

}

button.addEventListener(MouseEvent.CLICK, hourToFrame);

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
Community Expert ,
Aug 12, 2019 Aug 12, 2019
LATEST

I am not exactly sure what your trying to do, but try this tutorial. It's a timer and shows you how to trigger an event.

Timer Class in AS3

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