Flash: Date+ Final + DescribeType + lack of IDate = Bug? Rant! November 7, 2008
One of my largest issues with the conversion of AS2 to AS3 is the finalization of types, and the lack of interfaces for basic types. Finalization I can understand from a performance standpoint, the latter is annoying.
Am I missing something? Did Adobe/ECMA think that the core Date class could provide all that might be done?
The case in point is I'm trying to finish porting a Date Extension Utility class from AS2 to AS3. I think it was originally based on this one. This should normally be straighforward. First snag, Date is now final...grrr. Okay so I'll wrap an inner Date object. Next issue, Date has lots of methods to implement, and no interface...meaning I have to manually code them, but and there's not way for other classes to treat the new object as a Date object even though it will provide the same features. Grrr! Which means all the places I used the extention now have to use "*" for type and type checking goes out the window..GRR!
I tried to shortcut and use describeType to help codeGen, but dammit only the accessors and 2 of the myriad of methods show up in the XML regardless if I use the static Date or an instance, the docs don't make it clear which properties are dynamic, which are most of them. Even so I tried for..in which should give some inclination and nothing either apparently it's not enumerable...what's up with that? Out of curiosity since it's dynamic I tried to see if they could be appended to, can't since it's final.
<pre lang="actionscript">
var d:Date = new Date();
d["oldDate"] = d.getDate;
d["getDate"] = function(){
trace("newGetDate");
return 3;
}
trace(d.oldDate() + " " + d.getDate());
//outputs
//Console: Warning: 3594: oldDate is not a recognized method of the dynamic class Date.
//Output window: 7 7
</pre>
This is not the first weirdness I've had with introspection, but that was in the early days. Kinda odd that half the introspection relies upon describeType (for the compile time) and the for-in for the dynamic type, instead of a consistent way. I was hoping that by now they would have fixed it.

Add a Comment: