PDA

View Full Version : (newbie) layout issue


chuckgom
07-06-2005, 05:42 AM
Hi!
I want to make 10 buttons with a for loop.
However the "simplelayout" doesn't seem to work, so I can only see 1 button.
Could someone explain what to change in the following code to make it work?

thanks.

<canvas debug="true">

<class name="a1">
<button/>
</class>

<view oninit="create_items()">
<simplelayout axis="x"/>

<method name="create_items">
<![CDATA[
for(var tt=0;tt < 10;tt++)
{
debug.write('hello');
new a1();
}
]]>
</method>
</view>
</canvas>

jim_cakalic
07-06-2005, 11:49 AM
Hi. Try:

new a1(this);

The first argument to a class constructor is the parent view. Without this I suppose that canvas is used as the default. Since the method creating the buttons is in another view you need to specify that view as the parent for layout purposes. You can also supply a dictionary of initialization arguments.

See LzNode.construct() (http://www.laszlosystems.com/lps-3.0/docs/reference/node.html#meth-construct)

Jim