Adobe flex dateField
Posted
by
JonoB
on Stack Overflow
See other posts from Stack Overflow
or by JonoB
Published on 2011-01-08T22:23:54Z
Indexed on
2011/01/08
23:53 UTC
Read the original article
Hit count: 252
I have some code as follows:
private function onComboChange(evt:Event):void {
var temp:Date = df_date.selectedDate;
temp.date += 5;
df_dateDue.selectedDate = new Date(temp);
}
In essence, I am trying to add 5 days onto the selected date in df_date, and put that date into df_dateDue. This fires off via an EventListener on a combobox. Both df_date and df_dateDue are dateFields.
OK, so the first time that I run this, it works fine; df_date stays the same and df_dateDue is set to 5 days past df_date. However, the next time that I run it, df_dateDue increments by 10 days from df_date, the next time by 15, and so on.
So, stepping through the code shows that somehow df_date has become linked to the temp var, and that the temp var is not resetting itself each time the function is called.
Example: df_date = 01 Jan, df_dateDue = 01 Jan.
Fire off the event, df_date = 01 Jan, df_dateDue = 06 Jan
Fire off the event again. At this point, var temp = 06 Jan (even though df_date still shows 01 Jan), and df_dateDue is then set to 11 Jan
Fire off the event again. At this point var temp = 11 Jan (even though df_date = 01 Jan), and df_dateDue is then set to 16 Jan
What am I missing here?
© Stack Overflow or respective owner