PDA

View Full Version : Warning trying to create component using script


AlB
12-26-2005, 11:58 AM
I was delving into adding components dynamically -- (I understand that this might be quite slow.) Nevertheless, I started out by simply trying to create a windowpanel using script in the following code:

<canvas width="100%"
height="450"
debug="true">

<debug x="36%" y="0" width="64%" height="100%"/>


<button text="show"
y="400"
width="50"
onclick="var w = new windowpanel(canvas,{width: 150, height: 150, x: 5});" />

</canvas>

In the Debug window, I get the following warning:

WARNING: Dynamic_Components.lzx:20: call to undefined function 'windowpanel'


Can anyone tell me why this doesn't work?

By the way, if I change the component to a 'button', it works fine. Does this mean I'm stuck with only creating buttons using script?

AlB
12-26-2005, 12:59 PM
It took a while to find it in the forum, but it turns out that when you create a (built-in) component using tags, the class definitions are auto-included. When you do it in script, you have to expliclity include it in your code. This code now works:

<canvas width="100%"
height="450"
debug="true">

<debug x="36%" y="0" width="64%" height="100%"/>

<include href="../../lps/components/lz/windowpanel.lzx"/>

<button text="create"
y="400"
width="50"
onclick="var w = new windowpanel(canvas,{width: 150, height: 150, x: 5});" />

</canvas>


It's a bit of a pain, but not unacceptable.

This explains why 'button' worked. Since I used a tag to create a button, that class was already auto-included when I called it from the script. Similiarly, LzText worked because it was called when the tagged button's label was set.

Oh, well.