The clock hand is not rotating action script 3

+3 Lev Singkh · November 16, 2014
import flash.events.Event;

var time: Date = new Date(); var sec:int = time.seconds;

hour_mc.addEventListener(Event.ENTER_FRAME,Rot);

function Rot(e:Event):void {

hour_mc.rotation = sec*6;

}

i want to make a clock with event listener in action script 3 and when i run this movie it just shows the current second and doesn't move what am i doing wrong here?

Post a Reply

Replies

Oldest  Newest  Rating
0 Brendon McBain · November 26, 2014
Hello Lev,

Are you still stuck on this? I'll give you some of my thoughts... 
I suspect that you aren't updating the date seconds. You're currently only grabbing the seconds once, when the program is opened. What you need to do is move "var sec:int" into your Event function so that it is being updated.

import flash.events.Event;

hour_mc.addEventListener(Event.ENTER_FRAME,Rot);

// Hook this function to a TimerEvent for 1000 milliseconds
function Rot(e:Event):void {
   var time: Date = new Date();
   var sec:int = time.seconds;

   // Has a second gone by? If so, move the second hand by one second...
   hour_mc.rotation = sec*6;
}

http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f0e.html
I hope this helped. :D
  • 1

ActionScript

106,975 followers
About

Create website animations, games, and other interactive applications for Flash.

Links
Moderators
Bucky Roberts Administrator