Copy link to clipboard
Copied
Hi!
Im totally new in everything relatied to programming, but im trying to do little project of mine and learning while doing it. Im stuck at this simpe coding, which i cant reslove no matter how i try.
I need to make ona frame which i will get by click of button and then it would tell me todays date, +3 days date, +10days date, and +120 days date.Can someone help me pls
thanks
Copy link to clipboard
Copied
as3 or js?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
for whatever number of days you want, create a date object by using dateF(). you can then use it's properties (day, date, month, year etc to display what you want).
var d:Date = new dateF(days);
var d:Date = dateF(days);
// for example, for 3 days from today, var d3:Date = new dateF(3);
var d3:Date = dateF(3);
// for 120 days from today var d120 = new dateF(120);
var d120:Date = dateF(120);
///////////// no need to edit /////////////////
function dateF(days:int):Date{
var d:Date = new Date();
return new Date(d.time+timeF(days));
}
function timeF(days:int):Number{
return days*24*60*60*1000;
}
////////////////////////////////////////////////////////
Copy link to clipboard
Copied
Copy link to clipboard
Copied
d120.date+"/"+d.120.month+"/"+d120.year
(or maybe d120.fullYear)
check the as3 date api.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi.
Maybe @kglad can answer your latest question here, but I think it would be better for you to create another topic so that it will easier for other users to find the possible answers you will receive.
Regards,
JC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
use a combobox component.
Copy link to clipboard
Copied
How to make it visible in text box?
melb.text = theNewDatenew.toString();
like that or?
Copy link to clipboard
Copied
melb.text = d120.date+"/"+(d120.month+1)+"/"+d120.fullYear;
Copy link to clipboard
Copied
Scene 1, Layer 'Actions', Frame 640, Line 7 1048: Method cannot be used as a constructor.
var d:Date = new dateF(days);
Copy link to clipboard
Copied
var d3:Date = new dateF(3);
///////////// no need to edit /////////////////
function dateF(days:int):Date{
var d3:Date = new Date();
return new Date(d3.time+timeF(days));
}
function timeF(days:int):Number{
return days*24*60*60*1000;
}
melb.text = d3.date+"/"+(d3.month+1)+"/"+d3.fullYear;
////////////////////////////////////////////////////////
Copy link to clipboard
Copied
that's my error. it should be:
var d:Date = dateF(days);
Copy link to clipboard
Copied
var rightNow = new Date();
var msRightNow = rightNow.getTime();
var threeDays = 3 * 24 * 60 * 60 * 1000;
var tenDays = 10 * 24 * 60 * 60 * 1000;
var hundredDays = 120 * 24 * 60 * 60 * 1000;
var finalTime3 = msRightNow + threeDays;
var finalTime10 = msRightNow + tenDays;
var finalTime100 = msRightNow + hundredDays;
var theNewDate3 = new Date(finalTime3);
var theNewDate10 = new Date(finalTime10);
var theNewDate100 = new Date(finalTime100);
melb.text = theNewDate3.dateUTC + "-" + (theNewDate3.monthUTC + 1) + "-" + theNewDate3.fullYearUTC;
melc.text = theNewDate10.dateUTC + "-" + (theNewDate10.monthUTC + 1) + "-" + theNewDate10.fullYearUTC;
meld.text = theNewDate100.dateUTC + "-" + (theNewDate100.monthUTC + 1) + "-" + theNewDate100.fullYearUTC;
I had these on Flas CS6, and it worked flawless. Now on Animate, i get wierds dates, without some digits...
Copy link to clipboard
Copied
var rightNow = new Date();
var msRightNow = rightNow.getTime();
var threeDays = 3 * 24 * 60 * 60 * 1000;
var tenDays = 10 * 24 * 60 * 60 * 1000;
var hundredDays = 120 * 24 * 60 * 60 * 1000;
var finalTime3 = msRightNow + threeDays;
var finalTime10 = msRightNow + tenDays;
var finalTime100 = msRightNow + hundredDays;
var theNewDate3 = new Date(finalTime3);
var theNewDate10 = new Date(finalTime10);
var theNewDate100 = new Date(finalTime100);
melb.text = theNewDate3.dateUTC + "-" + (theNewDate3.monthUTC + 1) + "-" + theNewDate3.fullYearUTC;
melc.text = theNewDate10.dateUTC + "-" + (theNewDate10.monthUTC + 1) + "-" + theNewDate10.fullYearUTC;
meld.text = theNewDate100.dateUTC + "-" + (theNewDate100.monthUTC + 1) + "-" + theNewDate100.fullYearUTC;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
As you see , only 7 digits are present???
Copy link to clipboard
Copied
I figure it out, i had to embed font in each text area