Add a condition to a behavior
You can use standard behaviors to define a cause-and-effect relationship between an event (a mouse click, for example) and an action (playing a sound or redirecting to a web page, for example). You can use behaviors that have specified conditions to add another layer to the cause-and-effect relationship. When you use conditional behaviors, a condition is checked when a specified event occurs, and if the condition is met, an action is triggered.
For example, in response to a prompt for their logon credentials, a user types a name and password into a form, and then clicks Submit. The information that the user submitted is compared to data stored in a database. If the information matches the information in the database (the matching condition is met), the user is granted permission to enter the site.
Because a condition must evaluate to True in order for an action to be triggered, multiple actions must be defined to account for multiple conditions. For example, in the preceding scenario, if a second action is defined in which the information does not match the information in the database, the user is prompted to register.
Without writing any code, you can use Blend to create conditions for the actions that you have added to your project.
Add a condition
A condition is a statement that must evaluate to True for an action to occur. When you add an action from the Assets panel to the artboard, the Conditions category appears in the Properties panel. In the Conditions category, you can create the condition and then specify the comparison that you want to make.
To add a condition
In the Assets panel, click Behaviors, and then drag the action that you want onto an element on the artboard. The Conditions category appears in the Properties panel.
Click the plus sign next to Condition List to add a new condition.
To create the first statement (LeftOperand), in the drop-down list, select either Value or Data Store, and then do one of the following:
If you selected Value, type a value into the text box.
If you selected Data Store, in the drop-down list, select an existing property, or select Create New Property to create a new property in the data store.
In the Operator drop-down list, select the comparison that you want:
Equal
NotEqual
LessThan
LessThanOrEqual
GreaterThan
GreaterThanOrEqual
To create the second statement (RightOperand), in the drop-down list, select either Value or Data Store, and then do one of the following:
If you selected Value, type a value into the text box.
If you selected Data Store, in the drop-down list, select an existing property, or select Create New Property to create a new property in the data store.
Multiple conditions can be applied to an action. Repeat this procedure to create additional conditions.
To remove a condition
- In the Conditions List, click the minus sign next to the condition that you want to remove.
Change how conditions are evaluated
By default, all the conditions in the Conditions List must evaluate to True for the condition group to evaluate to True. If you want the action to be triggered if any of the conditions are true instead of requiring that all the conditions be true, you can change the evaluation criteria from All to Any in the Match drop-down list.
To change how conditions are evaluated
- In the Match drop-down list, select Any or All.