Highlighted

I am having trouble with analog clock

Community Beginner ,
Apr 22, 2019

Copy link to clipboard

Copied

here is the code I am trying so far

package  {

import flash.display.MovieClip;

import flash.utils.Timer;

import flash.events.TimerEvent;

public class analogClock extends MovieClip {

 

  var myDate:Date = new Date();

 

  var hours:Number = myDate.hours;

  var minutes:Number = myDate.minutes;

  var seconds:Number = myDate.seconds;

 

  var myTimer:Timer = new Timer(1000);

 

  public function analogClock() {

   // constructor code

  

   hourHandMC.rotation = hours * 30 + (minutes * 1/2);

   minuteHandMC.rotation = minutes * 6 + (seconds * 1/10);

   secondHandMC.rotation = seconds *6;

  

   myTimer.addEventListener(TimerEvent.Timer, updateClock);

   myTimer.start();

  }

 

  private function updateClock(e:TimerEvent){

   myDate = new Date();

  

   hours = myDate.hours;

   minutes = myDate.minutes;

   seconds = myDate.seconds;

  

   hourHandMC.rotation = hours * 30 + (minutes * 1/2);

   minuteHandMC.rotation = minutes * 6 + (seconds * 1/10);

   secondHandMC.rotation = seconds *6;

  }

}

}

I am getting these errors

C:\Users\steel\Videos\analogClock.as, Line 25, Column 40 1119: Access of possibly undefined property Timer through a reference with static type Class.

Scene 1, Layer 'hours_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Scene 1, Layer 'minutes_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Scene 1, Layer 'seconds_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

try:

TimerEvent.TIMER

Views

285

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

I am having trouble with analog clock

Community Beginner ,
Apr 22, 2019

Copy link to clipboard

Copied

here is the code I am trying so far

package  {

import flash.display.MovieClip;

import flash.utils.Timer;

import flash.events.TimerEvent;

public class analogClock extends MovieClip {

 

  var myDate:Date = new Date();

 

  var hours:Number = myDate.hours;

  var minutes:Number = myDate.minutes;

  var seconds:Number = myDate.seconds;

 

  var myTimer:Timer = new Timer(1000);

 

  public function analogClock() {

   // constructor code

  

   hourHandMC.rotation = hours * 30 + (minutes * 1/2);

   minuteHandMC.rotation = minutes * 6 + (seconds * 1/10);

   secondHandMC.rotation = seconds *6;

  

   myTimer.addEventListener(TimerEvent.Timer, updateClock);

   myTimer.start();

  }

 

  private function updateClock(e:TimerEvent){

   myDate = new Date();

  

   hours = myDate.hours;

   minutes = myDate.minutes;

   seconds = myDate.seconds;

  

   hourHandMC.rotation = hours * 30 + (minutes * 1/2);

   minuteHandMC.rotation = minutes * 6 + (seconds * 1/10);

   secondHandMC.rotation = seconds *6;

  }

}

}

I am getting these errors

C:\Users\steel\Videos\analogClock.as, Line 25, Column 40 1119: Access of possibly undefined property Timer through a reference with static type Class.

Scene 1, Layer 'hours_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Scene 1, Layer 'minutes_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Scene 1, Layer 'seconds_obj_', Frame 1 1119: Access of possibly undefined property containerType through a reference with static type Number.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

try:

TimerEvent.TIMER

Views

286

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
Apr 22, 2019 0
Adobe Community Professional ,
Apr 22, 2019

Copy link to clipboard

Copied

try:

TimerEvent.TIMER

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...
Apr 22, 2019 0