[Laszlo-dev] Using 'this' within static LzNode.initialize
Donald Anderson
dda at ddanderson.com
Fri Dec 14 11:47:45 PST 2007
I don't see a way in the AS3 API to get from a Class instance to its
parent Class instance.
Seems like I should emit a list of classes along with their
superclasses.
var classlist = { { Foo, FooParent }, { Bar, BarParent } };
....
(or whatever the proper syntax).
Also it seems like we need everything to inherit from a class we
control,
so we can put something into its constructor to catch initialization -
and eventually call initialize (?)
So I should inherit from what, LzObject? LzSWF9Object?
Maybe this is probably something that the tag compiler should send
me a pragma about, since I probably don't want to do this for every
class in the LFC.
#pragma lzclass
public class foo {
}
Tells me to insert 'extends' if missing, and to add the class/super
to a list.
?
- Don
On Dec 14, 2007, at 10:27 AM, P T Withington wrote:
> We need to reconcile the need (in our class system) to be able to
> get from an instance to both it's class and superclass. In the
> current system, the constructor property of an instance is its
> class and the constructor.prototype.constructor is its superclass.
> That would conflict with this proposal.
>
> But maybe the answer is that we should create a new property for
> our superclass chains.
>
> On Dec 13, 2007, at 18:33, Donald Anderson <dda at ddanderson.com> wrote:
>
>> If I'm in a static function (like initialize), I get errors when I
>> reference 'this'.
>> Reading http://livedocs.adobe.com/flex/201/langref/
>> Object.html#constructor
>> it seems like we can get to the 'this' object using the prototype,
>> provided
>> the object wasn't created with a 'constructor function'.
>>
>> Here's what I had in mind:
>>
>> // class initializer
>> static function initialize (prototype) {
>>
>> var thisobj;
>> if ($swf9) {
>> thisobj = prototype.constructor;
>> }
>> else {
>> thisobj = this;
>> }
>>
>> // Hereafter use thisobj in place of this, needed for SWF9.
>>
>> // was: if (this.hasOwnProperty('tagname')) ....
>>
>> if (thisobj.hasOwnProperty('tagname')) {
>>
>> Does that seem like it would work?
>>
>> - Don
>>
>> --
>>
>> Don Anderson
>> Java/C/C++, Berkeley DB, systems consultant
>>
>> Voice: 617-547-7881
>> Email: dda at ddanderson.com
>> WWW: http://www.ddanderson.com
>>
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
Voice: 617-547-7881
Email: dda at ddanderson.com
WWW: http://www.ddanderson.com
More information about the Laszlo-dev
mailing list