-
Originally Posted by kortex
Can you paste the error you are getting. My guess is it has something to do with this clock_txt.text=toClockPart(h) + ":" + toClockPart(m) + ":" + toClockPart(s) + "(" + toClockPartMS(ms) + ")";
1120: Access of undefined property klok_txt
edit: nice guessing
I hope to be as good in AS one day but right now these classes & the whole importing stuff is kinda frustrating, what to import and what not etc :s
Last edited by FlashAS3Newb; 01-07-2008 at 03:02 PM.
-
OOP is one letter from OOPS
Making the assumption that clock_txt is on you main time line try (take notice of parts bold font)
In main timeline:
import src.clock.DigiClock;
var clock:Clock = new Clock(clock_txt);
addChild(clock);
In the class:
package src.clock {
import flash.display.Sprite;
import flash.utils.*;
import flash.events.TimerEvent;
import flash.text.TextField;
public class DigiClock extends Sprite {
private var _textField:TextField
public function DigiClock(textField:TextField) {
this._textField = textField;
init();
}
private function init():void {
var myTimer:Timer=new Timer(5,0);
myTimer.addEventListener(TimerEvent.TIMER,updateCl ock);
//Start Timer
myTimer.start();
}
private function updateClock(eventObject:TimerEvent):void {
var my_dateate=new Date ;
var h:uint=my_date.getHours();
var m:uint=my_date.getMinutes();
var s:uint=my_date.getSeconds();
var ms:uint=my_date.getMilliseconds();
this._textField.text=toClockPart(h) + ":" + toClockPart(m) + ":" + toClockPart(s) + "(" + toClockPartMS(ms) + ")";
}
private function toClockPart(part:uint):String {
if (part < 10) {
return "0" + part.toString();
}
return part.toString();
}
private function toClockPartMS(part:uint):String {
if (part < 10) {
return "00" + part.toString();
} else if (part >= 10 && part < 100) {
return "0" + part.toString();
}
return part.toString();
}
}
}
-
Originally Posted by kortex
Making the assumption that clock_txt is on you main time line try (take notice of parts bold font)
Yes it's working. I'm trying to understand the code now
I don't know how to thank you for helping me out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|