+1
Searching answer

Access target using an 'if'

storycode 8 years ago updated by icahill (Administrator) 8 years ago 1
Is there a way to use the action on the target of the action?

For example, if an action is called with a target of "abc" and I want to check if a child of "abc" called "def" has an alpha of 1, how can I do it (without using an alias of the target/child)?
This can be accomplished by using an assign tag to create a wire variable for the value of the alpha attribute in question.


<main>
<panel name="panel1" height="10" width="10" _alpha="1" onclickup="action1"></panel>
<panel name="abc" height="100" width="100" align="center" >
<panel name="def" height="50" width="50" vaign="center" alpha="1"></panel>
</panel>
</main>
<actions>
<action name="action1">
<assign property="var:def-alpha" value="_alpha"/>
<if lhs="[var:def-alpha]" operator="e" rhs="1">
<play anim="action2"/>
</if>


Since the alpha attribute is not currently a supported object property for a panel, you will want to create an object variable (_alpha) and give it the same value as your alpha state for def. If an action changes your alpha value, you also need to create an assign tag that will change your _alpha as well.

Then when you want to reference that [var:def-alpha] for example, you can run and if statement to perform an action based on whether or not the var is set to a 1 or not 1.