FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


A ActionScript,showing a running date.





jan4984
U should create a flash file and create a dynamic textfield named txtDate first.Move the source to the action script panel.

-------------------------------------------------------------------
function isLeapYear(year:Number):Boolean
{
if ((Number%4 == 0 && Number%100 != 0) || Number%400 == 0)
{
return true;
}
return false;
}
function getDateFromString(strDate:String):Date
{
var aMyDate:Array = strDate.split("-");
var nDay:Number = aMyDate[0];
var nMonth:Number = aMyDate[1]-1;
var nYear:Number = aMyDate[2];
trace(nDay+"-"+nMonth+"-"+nYear);
return new Date(nYear, nMonth, nDay);
}
if (txtDate.text == "")
{
trace("frame1:detected text is empty");
var dateNow:Date = new Date();
txtDate.text = String(dateNow.getDate())+"-"+String(dateNow.getMonth()+1)+"-"+String(dateNow.getFullYear());
trace("why?"+String(dateNow.getDate())+"-"+String(dateNow.getMonth()+1)+"-"+String(dateNow.getFullYear()));
}
else
plusDate();
setInterval(plusDate,100);
function plusDate():Void
{
trace("detected text is NOT empty:"+txtDate.text);
var dateNow:Date = getDateFromString(txtDate.text);
trace("dateNow:"+dateNow.toString());
var nMonth:Number = dateNow.getMonth()+1;
var nDay:Number = dateNow.getDate();
var nYear:Number = dateNow.getFullYear();
trace("DateNow:"+nDay+"-"+nMonth+"-"+nYear);
if (nMonth == 1 || nMonth == 3 || nMonth == 5 || nMonth == 7 || nMonth == 8 || nMonth == 10 || nMonth == 12)
{
if (nDay != 31)
{
nDay++;
}
else
{
nMonth++;
nDay = 1;
}
}
else if (nMonth != 2)
{
if (nDay != 30)
{
nDay++;
}
else
{
nMonth++;
nDay = 1;
}
}
else
{
if (isLeayYear(nYear))
{
if (nDay != 2Cool
{
nDay++;
}
else
{
nMonth++;
nDay = 1;
}
}
else if (nDay != 29)
{
nDay++;
}
else
{
nMonth++;
nDay = 1;
}
}
if (nMonth == 13)
{
nMonth = 1;
nYear++;
}
var dateNext:Date = new Date(nYear, nMonth-1, nDay);
txtDate.text = dateNext.getDate()+"-"+(dateNext.getMonth()+1)+"-"+dateNext.getFullYear();
trace("text of txtDate:"+txtDate.text);
}
Related topics
Download IPB 2.0.4
Actionscript, what about it ?
Giving Cats Pills
Giving Cats Pills
Mod Projects lots of info
Ill deal with your HijackThis logs for you.
Problems with the PHP date() function
Tables created in the database but problem in access
Apache/php running too slowly
Where do you stand on using Javascript in websites?
Best filemanager?
Megaman Phoenix
HHO: Hydrogen Electrolysis
What after XP?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.