PDA

View Full Version : Can I create an association for objects I created in my javascript code?


enzhu
11-09-2007, 01:59 PM
Hello! I have another question here. In OL, I have always used associations like:
<view x="${parent.width-100}"/>
So the view will always at a certain position comparing with its parents.
My question here is if I can put such an association on objects I created in my javascript code? I have a code looks like:
<canvas debug="true">
<class name="pview" width="50" height="20" bgcolor="red"/>

<window width="600" height="400" resizable="true">
<handler name="oninit">
for (var i=0; i &lt; 10; i++) {
var p = new pview(this, {x: this.width-100, y: i*30+10});
}
</handler>
</window>
</canvas>
I'd like my red bars always start at 100 pixels from the window right border. Can I put such an association on the objects I created? I know I can solve this by using an extra view which contains my red bars and put association on that view. However, I'd like to know if it's doable without it, I'd like to put association on the red bars directly. Thank you very much.

senshi
11-10-2007, 03:06 AM
Read this thread... (http://forum.openlaszlo.org/showthread.php?t=10898)

enzhu
11-12-2007, 02:39 PM
Hello senshi, thank you very much! :)