Copy link to clipboard
Copied
Yes, Script number 2 is also causing the above issue. Animate cc 2017 Action script 3.0 Thanks again for looking
import flash.utils.Timer;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextFieldType;
var clockface:MovieClip;
var timedisplay:TextField;
var ticker:Timer = new Timer(250);
ticker.addEventListener(TimerEvent.TIMER, onTick);
ticker.start();
function onTick(e:TimerEvent):void {
currentTime = new Date();
var seconds:uint = currentTime.getSeconds();
var minutes:uint = currentTime.getMinutes();
var hours:uint = currentTime.getHours();
clockface.secondhand.rotation = 360 + (seconds * 6);
clockface.minutehand.rotation = 360 + (minutes * 6);
clockface.hourhand.rotation = 360 + (hours * 30) + (minutes * 0.5);
var displayMinutes:String = minutes < 10 ? "0" + minutes : "" + minutes;
timedisplay.text = hours + ":" + displayMinutes;
var displayMinutes:String = minutes < 10 ? "0" + minutes : "" + minutes;
timeDisplay.text = hours + ":" + displayMinutes;
}
errors are:
Scene 1, Layer 'action', Frame 1, Line 16, Column 10 1120: Access of undefined property currentTime.
Scene 1, Layer 'action', Frame 1, Line 17, Column 25 1120: Access of undefined property currentTime.
Scene 1, Layer 'action', Frame 1, Line 18, Column 25 1120: Access of undefined property currentTime.
Scene 1, Layer 'action', Frame 1, Line 19, Column 23 1120: Access of undefined property currentTime.
Scene 1, Layer 'action', Frame 1, Line 26, Column 6 1120: Access of undefined property timeDisplay.
Copy link to clipboard
Copied
OK,
Some important thing
On your stage you have to prepare:
MovieClip (clockface) and inside: secondhand, minutehand and hourhand MovieClips as well
You need text frame (Dynamic text Field) with instance name timeDisplay
You prepared some mistakes (duplicate variables, and no variable definitione)
then use this code
import flash.utils.Timer;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextFieldType;
var clockface:MovieClip;
var timedisplay:TextField;
var ticker:Timer = new Timer(250);
var currentTime // variable declaration
ticker.addEventListener(TimerEvent.TIMER, onTick);
ticker.start();
function onTick(e:TimerEvent):void {
currentTime = new Date();
var seconds:uint = currentTime.getSeconds();
var minutes:uint = currentTime.getMinutes();
var hours:uint = currentTime.getHours();
clockface.secondhand.rotation = 360 + (seconds * 6); // remember MovieClips here
clockface.minutehand.rotation = 360 + (minutes * 6);
clockface.hourhand.rotation = 360 + (hours * 30) + (minutes * 0.5);
var displayMinutes:String = minutes < 10 ? "0" + minutes : "" + minutes;
timeDisplay.text = hours + ":" + displayMinutes; // text Field here
}
Copy link to clipboard
Copied
it would be better to specify class type for currentTime:
var currentTime:Date;
// though if you're doing that it makes sense to declare seconds, minutes and hours outside onTick, too.
and timedisplay is not the same as timeDisplay and you either need to use the 'new' constructor to create a textfield or create one on stage with the text tool. in either case, use a consistent name.
import flash.utils.Timer;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextFieldType;
var clockface:MovieClip;
//var timedisplay:TextField=new TextField(); //add it if you're going to do this
var ticker:Timer = new Timer(250);
var currentTime:Date;
var seconds:uint;
var minutes:uint;
var hours:uint
ticker.addEventListener(TimerEvent.TIMER, onTick);
ticker.start();
function onTick(e:TimerEvent):void {
currentTime = new Date();
seconds = currentTime.getSeconds();
minutes = currentTime.getMinutes();
hours = currentTime.getHours();
clockface.secondhand.rotation = 360 + (seconds * 6);
clockface.minutehand.rotation = 360 + (minutes * 6);
clockface.hourhand.rotation = 360 + (hours * 30) + (minutes * 0.5);
var displayMinutes:String = minutes < 10 ? "0" + minutes : "" + minutes;
timedisplay.text = hours + ":" + displayMinutes;
var displayMinutes:String = minutes < 10 ? "0" + minutes : "" + minutes;
// timeDisplay.text = hours + ":" + displayMinutes; // this needs to be fixed
}
Copy link to clipboard
Copied
This was very helpful, my only error now seems to be timeDisplay.text = hours + ":" + displayMinutes;. any thoughts?
Copy link to clipboard
Copied
you can remove it - it's duplicated
But please remember to add dynamic text field on stage and give it the instanece name: timeDisplay
Pawel