Navigation:  Examples >

Example 5: Using Delay

Previous pageReturn to chapter overviewNext page

Example 5: Using Delay

Run This Example in New Window

Sometimes you may want to pause a while between two actions.  Delay is a flow control that designed for this use case.


Delay can be placed under event or other flow controls.  You can put some actions under the delay, or after the delay, these two ways are equivalent, you can choose any one you like:


Let create an interesting example: show a number when clicking on a button, hide it after 2 seconds.

First we need to place a TextBox and a Button element in the page.  Put a long number in the TextBox and change the text of Button to "Show Number".  Don't forget to unselect the "visible" checkbox for the TextBox element (so it will be hidden by default):


Create the behavior for the button (Button_1) and add "Element Clicked" event.  Choose "Operate on Element..." after clicking "Add Action" button in toolbar.


Choose the TextBox element (TextBox_1) as the target element, select "Change Visibility" action and then select "Make Element Visible" as parameter.  This action will make the TextBox element visible.


After creating the action, we can select the "Element Clicked" event again and add a delay by clicking the "Add Flow Control" button in toolbar.


You will see the window below if you select "Delay for a While".  Please input 2000 (2 seconds) and click "Ok" button.


Then we add another action to hide the TextBox element again.


Fill the action editor window like this:


Ok, below is the final behavior definition:


Now you can run the simulation and see how it works.  You can view this online example to see the result, or download the plot file.