| Getting Started with Flex 2 > Lessons > Use View States and Transitions > Design a view state | |||
The sample application provides a simple search mechanism that meets the needs of most users. However, some users might prefer to have more search options. You can use view states to provide these options on request.
The New State dialog box appears.
The new state appears in the States view.
You can use the layout tools in Flex Builder to make changes to the appearance of the new state. You can modify, add, or delete components. As you work, the changes describing the new state are recorded in the MXML code.
The VBox container automatically aligns the controls vertically.
label property.label property.label property. The layout should look similar to the following:
Flex Builder inserted a <mx:states> tag after the opening <mx:Application> tag, so that the application appears as follows:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:states>
<mx:State name="Advanced">
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:VBox x="20" y="160" width="160" height="80" id="myVBox">
<mx:CheckBox label="Regular expression"/>
<mx:CheckBox label="Case sensitive"/>
<mx:CheckBox label="Exact phrase"/>
</mx:VBox>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Panel id="panel1" x="5" y="5" width="300" height="400" layout="absolute">
<mx:Label x="20" y="70" text="Search"/>
<mx:TextInput x="20" y="90"/>
<mx:Button x="185" y="90" label="Go"/>
<mx:LinkButton x="20" y="120" label="Advanced Options" id="linkbutton1"/>
</mx:Panel>
</mx:Application>
A browser opens and runs the application.
Your application does not display the controls you inserted in the new view state. By default, Flex applications display only the base state. You must define how users can switch view states, typically by clicking specific controls.
Flex 2.01