Object states
Object States allow a method to programmatically detect an active status on a touched or targeted object within the wire.
A state may be initially declared at the object level and/or assigned from within an <action> using <set>. The state is then passed across the siblings using <set> and identified within a target with an ‘@'. The state's value can be defined as anything you wish.
Only one state can be present or active within a object set of siblings within the wire.
State declared at object level:
<panel name="button1" width="100px" height="100px" background="#333333" state="on"></panel> <panel name="button2" width="100px" height="100px" background="#666666" rightof="button1"></panel> <panel name="button3" width="100px" height="100px" background="#999999" rightof="button2"></panel>State assigned at an action level using the tostate attribute:
<action name="setState"> <set tostate="on" /> </action>Once a state has been declared, you can actively target the given object without explicitly defining the object by name or alias as well as pass the state from one selected object to another using the @ symbol within your target attribute. You may use object paths or alias to target an active state. This example will look for the active state within the navigation and alpha the object to .5. The touched object will be set to the state "buttonActive", and then alpha the selected object to 1.
<action name="setState"> <sync loop="no"> <set tostate="on" /> <alpha value=".5" time=".5" target="NAVIGATION/@on" /> <alpha value="1" time=".5" /> </sync> </action>
Extends
None
Requirements
Only one state may be assigned or active across siblings.
Sample code
<wire> <main> <panel name="navigation" alias="NAVIGATION" width="100%" height="20%"> <panel name="button1" width="100px" height="100%" align="center" background="#333333" state="on" onclickup="setState"></panel> <panel name="button2" width="100px" height="100%" background="#666666" rightof="button1" onclickup="setState"></panel> <panel name="button3" width="100px" height="100%" background="#999999" rightof="button2" onclickup="setState"></panel> </panel> </main> <actions> <action name="setState"> <sync loop="no"> <set tostate="on" /> <alpha value=".5" time=".5" target="NAVIGATION/@on" /> <alpha value="1" time=".5" /> </sync> </action> </actions> </wire>
Loading...
There was a problem loading this topic