[Laszlo-user] suggested way to check for class type in Wafflecone?
John Sundman
jsundman at laszlosystems.com
Thu Aug 30 08:48:55 PDT 2007
http://www.openlaszlo.org/lps4/docs/guide/language-
preliminaries.html#d0e1603
jrs
On Aug 30, 2007, at 11:27 AM, Elliot Winard wrote:
> All classes are fields in lz? Why's that?
> That seems kinda odd.
> -e
>
> P T Withington wrote:
>> On 2007-08-30, at 10:01 EDT, Elliot Winard wrote:
>>
>>> I have some window management code that iterates through an array
>>> of different windows & switches on the exact window type.
>>>
>>> It used to work with code like this -
>>> var w=getNextWindow();
>>>
>>> // classname can be composewindow, mailwindow,
>>> contactswindow
>>> if(w.classname == "composewindow")
>>> { return w;
>>> }
>>>
>>> This stopped working because w.classname is now Object.
>>> w.constructor.classname is, however, 'composewindow'
>>>
>>> What's the right way to do this? Should obj.classname be the
>>> same as obj.constructor.classname?
>>> I want to make sure this works when & if OpenLaszlo is updated.
>>
>> I think what you really want to do is say:
>>
>> if (w instanceof lz.composewindow) {
>>
>> The fact that there is a classname property on instances is an
>> accident of Javascript inheritance.
More information about the Laszlo-user
mailing list