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
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
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
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now