Okay, I ran into this issue and I’m hoping someone smarter than me (that’s a lot of you) has either run into this before or knows what the deal is. I think it’s probably something simple but in Googling it I turned up no results so I wanted to post here in case anyone else has issues in the future. Here’s the deal.
I’m using the sweet, out of the box, getters and setters and I’ve got one for date/time:
[as]public function set time (value:Date) : void
{
this._time = value;
}
public function get time () : Date
{
return this._time;
}
[/as]
With strings or any other variable type, that works fine. But when I try to create a date my time variable is always null. I’ve done it a couple of different ways to no avail. Try 1 (time is a property of the Waypoint class:
[as]
waypoint.time = new Date();
waypoint.time.setUTCFullYear(year, month, day);
waypoint.time.setUTCHours(hours, minutes, seconds);
[/as]
Try 2:
[as]
var tempDate : Date = new Date();
tempDate.setUTCFullYear(year, month, day);
tempDate.setUTCHours(hours, minutes, seconds);
waypoint.time = tempDate;
[/as]
I thought that might fire the setter correctly but time is still null after going through the function. Finally I had to set time to a public property and I could use method 1 from above just fine.
Anyone know what I’m doing wrong and how to fix it?
[tags]ActionScript3, getters and setters[/tags]
TweetRelated posts: