hoenie
10-25-2006, 01:25 AM
Hi, I am having problem with using getNumItems() in a JavaScript.
I have populated a list with four items using addItem() in JavaScript. Then I created a text view to indicate the number of item in the list. But it is always showing '0', both in the text view and the debug window. What's wrong with getNumItems()?
<canvas height="400">
<include href='lz/textlistitem.lzx'/>
<view height="300" width="200" x="10" y="10">
<simplelayout axis="y"/>
<list id="pool" itemclassname="textlistitem"/>
<text id="count" text="Ready!"/>
</view>
<script>
<![CDATA[
var i;
var names = ["John", "Mary", "Peter", "Henry"];
for (i=0; i<4; i++) {
pool.addItem(names[i], i);
}
Debug.write(pool.getNumItems());
count.setText(pool.getNumItems());
]]>
</script>
</canvas>
The funny thing is that if I type "pool.getNumItems()" in the debug window, it actually evaluates to 4. It just doesn't work in JavaScript.
Any idea? Thanks.
I have populated a list with four items using addItem() in JavaScript. Then I created a text view to indicate the number of item in the list. But it is always showing '0', both in the text view and the debug window. What's wrong with getNumItems()?
<canvas height="400">
<include href='lz/textlistitem.lzx'/>
<view height="300" width="200" x="10" y="10">
<simplelayout axis="y"/>
<list id="pool" itemclassname="textlistitem"/>
<text id="count" text="Ready!"/>
</view>
<script>
<![CDATA[
var i;
var names = ["John", "Mary", "Peter", "Henry"];
for (i=0; i<4; i++) {
pool.addItem(names[i], i);
}
Debug.write(pool.getNumItems());
count.setText(pool.getNumItems());
]]>
</script>
</canvas>
The funny thing is that if I type "pool.getNumItems()" in the debug window, it actually evaluates to 4. It just doesn't work in JavaScript.
Any idea? Thanks.