Home » Actionscripts library » Date Object
|
Clock and Date
//Here I made an clock:
movieclip.prototype.analoguhr = function () {
Zeit = new Date();
sekunden=Zeit.getSeconds();
minuten=Zeit.getMinutes();
stunden=Zeit.getHours();
sek._rotation = sekunden*6;
min._rotation = minuten*6;
std._rotation = stunden*30+minuten*0.5
}
movieclip.prototype.datum = function() {
zeit=new Date();
tag=zeit.getDate();
monat=zeit.getMonth()+1;
jahr=zeit.getFullYear();
if (tag < 10) { tag = "0"+tag;}
if (monat < 10){ monat = "0" + monat;}
zeitfeld= (tag+"."+monat+"."+jahr);
}
datum()
//Have fun with it.
Posted by: Matthias Kannengiesser | website http://www.flashstar.de |
///////////first frame////////////////
today = new Date();
seconds = Math.floor((event.getTime()-today.getTime())/1000);
minutes = Math.floor(seconds/60);
hours = Math.floor(minutes/60);
days = Math.floor(hours/24);
cday = days;
if (cday<10) {
cday = "0"+cday;
}
chour = hours%24;
if (chour<10) {
chour = "0"+chour;
}
cminute = minutes%60;
if (cminute<10) {
cminute = "0"+cminute;
}
csecond = seconds%60;
if (csecond<10) {
csecond = "0"+csecond;
}
//create a dynamic text named input
input = cday+" "+chour+" "+cminute+" "+csecond;
// year, month -1, day, hour
event = new Date(2001, 11, 31, 24);
///////second frame//////////
gotoAndPlay (1);
Posted by: futre | website http://www.peopleforfun.com |
/*I did not like to update the page telling my age each and every year after my birthday
Now I use a dynamic text field with the variable named age and this useful function*/
my_date = new Date();
function date_to_age(my_year, my_month, my_day) {
mem = my_date.getTime();
my_date.setFullYear(my_year, my_month-1, my_day);
myage = my_date.getTime();
mem = mem-myage;
my_date.setTime(mem);
trace("years/age: "+(my_date.getFullYear()-1970)+" month: "+my_date.getMonth()+" days: "+my_date.getDate()+" by www.advance-media.com");
return (my_date.getFullYear()-1970);
}
age = date_to_age(1970, 7, 21);
/*also useful if telling your visitor for how many years your company is doing biz...e.g.
No more updates needed*/
Posted by: Folko Langner | website http://www.advance-media.com |
/*here is a simpler function in comparison to the other (birth)date
to age function I have posted here
It might be easier to understand yet you'll get a hard time to find out
since how many days you are here :-)*/
my_date = new Date();
function date_to_age(my_year, my_month, my_day) {
my = my_date.getFullYear();
if (my_date.getMonth()<my_month-1 or (my_date.getMonth() == my_month-1 and my_date.getDate()<my_day)) {
my--;
}
return (my-my_year);
}
trace("2003 by www.advance-media.com \n your age in YEARS: "+date_to_age(1970, 7, 21));
/*also useful if telling your visitor for how many years your company is doing biz...e.g.
No more updates needed, say 'yes' to dynamic! Cheers*/
Posted by: Folko Langner | website http://www.advance-media.com |
//Please note, I can not take credit for this script.
//I found it while searching the newsgroups. Someone named Steve wrote it.
//Kudos to Steve, who ever you are,
//this is the best pause function I have found.
//In your main "action" timeline, frame 1 put the following code:
////////////////// Pause Function /////////////////////
this.createEmptyMovieClip("timer",50);
timer.onEnterFrame = function()
{
if (this.startTime>0)
{
var diff = getTimer()-this.startTime;
if (diff>this.timerLength)
{
this.target.play();
this.startTime = 0;
}
}
};
function pauseFor(theTime)
{
stop();
timer.timerLength = theTime;
timer.startTime = getTimer();
timer.target = this;
}
///////////////////////////////////////////////////
//Then on the frame you want to pause, add: pauseFor(3000)
//this would pause for 3 seconds.
Posted by: Bob Place | website http://www.placemedia.com |

