
Define how users switch view states 169
4. Select the LinkButton control in the layout of the Advanced view state, and then specify
the following
click property in the Flex Properties view:
currentState=''
Specify an empty string (two single quotes with no space between them) as the value of
currentState. An empty string specifies the base state, so when the user clicks the
LinkButton control in the Advanced view state, the base state is restored.
If you change to Source view, you will notice that Flex Builder added an
<mx:SetEventHandler> tag to the application. The final application source code should
look like the following:
<?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:SetEventHandler target="{linkbutton1}" name="click"
handler="currentState=''"/>
</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"
click="currentState='Advanced';" id="linkbutton1"/>
</mx:Panel>
</mx:Application>
Commentaires sur ces manuels