Copy link to clipboard
Copied
hello,
i have a problem with a clock that does current date and time. i am newbie and tried all other forums relating to this problem. i tried every possible solution i could find, nothing seemed to work.
can anyone please complete my actionscript 3.0 code?
Thank you a lot in advance,
Kind regards,
Bregt
var today_date:Date = new Date();
var thisday:uint = today_date.getDate();
var thismonth:uint = today_date.getMonth();
var today_time;
var currentTime:Date = new Date();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var hours = currentTime.getHours() * 30 + currentTime.getMinutes() / 2;
var month:Array = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var day:Array = new Array('zondag','zaterdag','vrijdag','donderdag','woensdag','dinsdag','maandag');
var fileName:String = (today_date.getDate()+month[thismonth]+day[thisday]+today_date.getFullYear()+"_"+currentTime.hours + currentTime.minutes + currentTime.seconds);
trace(fileName);
Copy link to clipboard
Copied
it would be a dream, do i have to make another post, or wil this get picked up?
grts
Copy link to clipboard
Copied
no other posts are needed.
Copy link to clipboard
Copied
My friend you've already done the main part of the project you want, you only need to design the clock and it's easy just use the text tool to create some dynamic text fields on the stage and apply the code to them:
1 - Create 3 text fields (day_txt, date_txt and clock_txt) use one for the day, one for the date and the last one for the clock.
2 - Create 3 strings:
var _day:String;
var _date:String;
var _clock:String;
3 - onTimer update the strings and set the text:
_day = String(day[today_date.day]);
_date = String(today_date.date + " " + month[today_date.month]+ " " +today_date.fullYear);
_clock = String(padF(today_date.hours) + ":" + padF(today_date.minutes) + ":" + padF(today_date.seconds));
day_txt.text = _day;
date_txt.text = _date;
clock_txt.text = _clock;
4 - Choose and embed the font then set the text fields properties, all that can be done manually.
I think you're here to learn but when you ask other people to done the project for you then you'll lean nothing!
Regards.
Copy link to clipboard
Copied
And when you face a problem you can post a question.
Copy link to clipboard
Copied
Thank you a lot,
here's the definitive code ![]()
var today_date:Date = new Date();
function padF(n:Number):String{
var s:String=n.toString();
while(s.length<2){
s='0'+s;
}
return s;
}
var month:Array = new Array('Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Ok tober','November','December');
var day:Array = new Array('zondag','maandag','dinsdag','woensdag','donderdag','vrijdag','zaterdag');
var fileName:String = (day[today_date.day]+ " " +today_date.date + " " + month[today_date.month]+ " " +today_date.fullYear + " " + padF(today_date.hours) + ":" + padF(today_date.minutes) + ":" + padF(today_date.seconds));
var _day:String;
var _date:String;
var _clock:String;
trace(fileName);
var tf:TextField=new TextField();
tf.width =300;
addChild(tf);
tf.x=tf.y=100;
var myTimer:Timer = new Timer(1000) // this timer will call the function every 1000 milliseconds after you add a timer event listener to it.
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
function onTimer(e:TimerEvent):void
{
today_date = new Date();
_day = String(day[today_date.day]);
_date = String(today_date.date + " " + month[today_date.month]+ " " +today_date.fullYear);
_clock = String(padF(today_date.hours) + ":" + padF(today_date.minutes) + ":" + padF(today_date.seconds));
day_txt.text = _day;
date_txt.text = _date;
clock_txt.text = _clock;
};
myTimer.start();
it is exactly what i wanted, now i can easily study this code and try new things to learn.
Kind regards,
Bregt
Copy link to clipboard
Copied
You're welcome and good luck.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more