Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

action Script - dates

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
Hi i Have two dynamic text boxes on stage. This script works great to set the value of the first text box:
Code:
date2 = new Date();
	this.yearval = date2.getFullYear();
	curday = date2.getDate();
	SetMY(date2.getMonth() + 1, this.yearval);	//1 based month
	delete date2;
	ShowCal();


The dynamic text boxes have a default value of: "dd - mm - yy"

If i wanted to check if this is the value of the first text box (text box Var: ckin, second text box Var: ckout), and if not the default dd-mm-yy value then use it in the script.
My problem is that when i trace date2 below i get value of:
22 May 2007
And when i trace date2 after the "}else{" i get:
Tue May 1 12:10:33 GMT-0700 2007

I think the formatting of the two date2 in either senerio are screwing up the script, any thoughts on how to fix it/make it work? Thanks

Code:
function ShowToday()
{
	if (_root.ckin <> "dd - mm - yy") {
	date2 = _root.ckin;  //SetMY(date2.getMonth() + 1, this.yearval);

//trace(date2);

	this.yearval = date2.getFullYear();
	curday = date2.getDate();
	SetMY(date2.getMonth() + 1, this.yearval);	//1 based month
	delete date2;
	ShowCal();

	}else{

	date2 = new Date();
			//trace(date2);
	this.yearval = date2.getFullYear();
	curday = date2.getDate();
	SetMY(date2.getMonth() + 1, this.yearval);	//1 based month
	delete date2;
	ShowCal();
	}
}
 
[tt]date2 = _root.ckin;[/tt]

That's not the way to construct Date object. You have to do something like:

[tt]date2 = new Date(2007, 4, 2);[/tt]

to create a Date 2nd May 2007 for example.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top