Highlighted

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

New Here ,
Aug 12, 2019

Copy link to clipboard

Copied

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

Views

90

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Aug 12, 2019

Copy link to clipboard

Copied

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

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2019 0
Adobe Community Professional ,
Aug 12, 2019

Copy link to clipboard

Copied

Hi

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

~ Jane

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 12, 2019 1
Adobe Community Professional ,
Aug 12, 2019

Copy link to clipboard

Copied

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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 12, 2019 0
Adobe Community Professional ,
Aug 12, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 12, 2019 0