PDA

View Full Version : Using 'new": Explicit tag must exist somewhere first?


tspratt
02-05-2004, 06:22 PM
When instanitating an object using the "new" keyword, it appears that there must be an existing tag some where in the app first, or the object won't instantiate.

In this tiny example below, the new checkbox does not appear unless the invisible <checkbox> tag is uncommented.

<canvas >
<!--checkbox visible="false"/-->
<button text="clickMe!">
<method event="onClick">
var ochkbox = new checkbox(detail);
ochkbox.setAttribute("text","newcheckbox");
</method>
</button>
<view id="detail" x="150" />
</canvas>

Is this intended behavior?

Tracy

vfunshteyn
02-06-2004, 03:19 PM
The reason why you had to uncomment the invisible checkbox is because the autoinclude mechanism (described in the reference page for <include> tag) only applies to unresolved tags. It cannot infer what should be pulled in when the only place a class is referenced is inside a script, such as in your example. To specify the component you would like compiled into your app without relying on the autoinclude feature, use the explicit include syntax, like this:

<include href="lz/checkbox.lzx"/>

tspratt
02-06-2004, 05:51 PM
Thanks!

tspratt
02-06-2004, 06:11 PM
I can include all the components using this syntax:

<include href="lz/library.lzx"/>
<include href="base/library.lzx"/>
<include href="utils/library.lzx"/>

That makes my life a lot easier!

Thanks!