If you add the following line to the beginning of your script, you'll 
see that the view in question is not yet initialized:
            Debug.write(bugInstance.isinited);

Although they claim that this chapter is optional reading, I've found 
that in my own experience I've had to read it over and over again:
http://www.openlaszlo.org/lps-latest/docs/guide/initialization-and-instantiation.html

Generally I try to keep my code out of script blocks except for very 
special cases.  It's much better to have the code as methods of views, 
then you are much less likely to run into these sorts of problems.

hope that helps.

Mark Engelberg wrote:
> I keep running into weird behavior where attributes aren't initialized
> when I expect.  Here's an example that doesn't work, although it seems
> like it should.  Basically, I'm storing a reference to "cuteView" in
> the "storeView" attribute of the Bug class.  Yet, you'll see that
> bugInstance.storeView is null at the time the script is invoked.  Can
> someone please elucidate why this doesn't work?
>
> <canvas debug="true">
>       <class name="Bug">
>               <attribute name="storeView" type="expression"/>
>       </class>
>       <view name="cuteView"/>
>       <Bug name="bugInstance" storeView="$once{parent.cuteView}"/>
>       
>       <script>        
>               Debug.write(bugInstance.storeView);
>               bugInstance.storeView.setAttribute("x",2);
>       </script>
> </canvas>
> _______________________________________________
> Laszlo-user mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>   

-- 
Jason Stafford
Principal Developer
Inspiration Software, Inc.
The leader in visual thinking & learning

Introducing INSPIRATION(r) 8, the essential tool to visualize, think, 
organize and learn. Students use Inspiration to plan, research and 
complete projects successfully. Learn more at www.inspiration.com. 

503-297-3004 Extension 119
503-297-4676 (Fax)
9400 SW Beaverton-Hillsdale Highway
Suite 300
Beaverton, OR 97005-3300

_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to