antun
09-10-2004, 04:07 PM
You can pass a reference to a view to an instance using a constraint:
<canvas>
<view id="box" width="50" height="50" align="center" valign="middle" />
<class name="colorchangerbutton" extends="button">
<attribute name="viewtocontrol" type="expression" />
<method event="onclick">
this.viewtocontrol.setAttribute( "bgcolor", 0xff0000 );
</method>
</class>
<colorchangerbutton viewtocontrol="$once{box}">
Change color of said view to red
</colorchangerbutton>
</canvas>
You need to declare the attribute, and give it a type, "expression" - the default attribute type.
Enjoy!
<canvas>
<view id="box" width="50" height="50" align="center" valign="middle" />
<class name="colorchangerbutton" extends="button">
<attribute name="viewtocontrol" type="expression" />
<method event="onclick">
this.viewtocontrol.setAttribute( "bgcolor", 0xff0000 );
</method>
</class>
<colorchangerbutton viewtocontrol="$once{box}">
Change color of said view to red
</colorchangerbutton>
</canvas>
You need to declare the attribute, and give it a type, "expression" - the default attribute type.
Enjoy!