PDA

View Full Version : Creating and using references to named views...


emily
02-12-2003, 12:43 PM
I am trying to avoid using ids by using named views rather than ids.

The following code example gives these errors:
arefview.lzx:15: reference to undefined property 'width'
arefview.lzx:15: reference to undefined property 'height'

I think that it's finding my refview, but doesn't know that refview is a pointer to canvas.sister.cousin.

By the way, when I change the <attribute> tag line to read:

<attribute name="refview" type="reference" />

I get the following:
Error: arefview.lzx:17:56: unknown attribute type: reference

I'm sure I'm doing something extremely stupid. Please help.

Thanks In Advance.

--Emily

<canvas width="500" height="500" debug="true">
<simplelayout axis="y" />
<view name="sister" bgcolor="red" >
<text
name="cousin"
width="100"
height="200" >
Cousin: (sister's daughter)
</text>
</view>
<view name="brother" bgcolor="blue" x="105">
<text
name="cousin"
oninit=
"this.refview=this.parent.parent.sister.cousin"
width="this.refview.width * 2"
height="this.refview.height" >
Cousin: (brother's son)
<attribute name="refview" />
</text>
</view>
</canvas>

antun
02-12-2003, 01:07 PM
Hey Emily

I think the issue is the order the views get instantiated.

If you put: debug.write('setting reference'); in the oninit attrubute (just before you set the reference), you'll see it appear in the debugger after the error messages, which means that it's not there when the constraints get applied.

<canvas width="500" height="500" debug="true">
<simplelayout axis="y" />
<view name="sister" bgcolor="red" >
<text name="cousin"
width="100"
height="200" >
Cousin: (sister's daughter)
</text>
</view>
<view name="brother" bgcolor="blue" x="105">
<text name="cousin"
width="parent.parent.sister.cousin.width * 2"
height="parent.parent.sister.cousin.height" >
Cousin: (brother's son)
</text>
</view>
</canvas>

You can reference them directly as shown above, and this does work.

Take care,

Antun

emily
02-12-2003, 01:24 PM
Thanks for your very prompt reply, Antun!

And, did I misunderstand that I need to set the type of an attribute if I want to use it as a reference?

<attribute name="refview" type="reference" />

--Emily

antun
02-12-2003, 01:41 PM
Hey Emily

You can't use <attribute type="reference">. That's a mistake in the LZX Reference. Instead use the init attribute:-

<canvas width="500" height="500" debug="true">
<simplelayout axis="y" />
<view name="sister" bgcolor="red" >
<text name="cousin"
width="100"
height="200" >
Cousin: (sister's daughter)
</text>
</view>
<view name="brother" bgcolor="blue" x="105">
<attribute name="refview" init="parent.sister.cousin" />
<text name="cousin"
width="parent.refview.width * 2"
height="parent.refview.height" >
Cousin: (brother's son)
</text>
</view>
</canvas>