CDHBookingEdge
11-05-2006, 12:51 PM
In trying to answer ljohnny18's post a bit ago I made the following quickie demo <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function OnViewChange() :void
{
if (accordion.selectedIndex == 1)
{
if (fldID.text.length == 0)
{
Alert.show("User ID has not been filled in.");
this.accordion.selectedIndex = 0;
}
else
{
Alert.show("Ok I'm in the Data View and I know my ID is " + this.fldID.text);
}
}
}
]]>
</mx:Script>
<mx:Panel title="Accordion Container Example"
height="90%" width="90%"
paddingTop="10" paddingLeft="10"
paddingRight="10" paddingBottom="10" layout="absolute">
<mx:Accordion id="accordion"
width="100%" height="100%" x="10" y="10"
change="OnViewChange();">
<!-- Define each panel using a VBox container. -->
<mx:VBox id="welcomeView" label="Welcome!" height="207" width="384">
<mx:Text text="Welcome to our Website. Please enter your ID before proceeding." fontFamily="Arial" fontSize="14" height="45" width="374" fontWeight="bold" textAlign="center"/>
<mx:Form backgroundColor="#ffffff">
<mx:FormItem label="User ID:">
<mx:TextInput id="fldID" editable="true" enabled="true"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox id="dataView" label="View Data" height="210" width="381">
<mx:DataGrid width="376" height="197">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<mx:VBox id="contactView" label="Contact Us" width="385" height="206">
<mx:Text text="How to contact us" width="379" height="201"/>
</mx:VBox>
</mx:Accordion>
</mx:Panel>
</mx:Application>
Now this is the behaviour I'm seeing which I find a bit strange. When the user clicks from the first view to the second view with the ID not filled in, the message is displayed but they are not returned to the first view. But if the user is on the contact page (3rd view) and clicks on the 2nd view they DO get returned to the 1st page. Is this behaviour that you guys would expect based on the code? If so why? What did I miss?
Thanks in advance,
Christopher
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function OnViewChange() :void
{
if (accordion.selectedIndex == 1)
{
if (fldID.text.length == 0)
{
Alert.show("User ID has not been filled in.");
this.accordion.selectedIndex = 0;
}
else
{
Alert.show("Ok I'm in the Data View and I know my ID is " + this.fldID.text);
}
}
}
]]>
</mx:Script>
<mx:Panel title="Accordion Container Example"
height="90%" width="90%"
paddingTop="10" paddingLeft="10"
paddingRight="10" paddingBottom="10" layout="absolute">
<mx:Accordion id="accordion"
width="100%" height="100%" x="10" y="10"
change="OnViewChange();">
<!-- Define each panel using a VBox container. -->
<mx:VBox id="welcomeView" label="Welcome!" height="207" width="384">
<mx:Text text="Welcome to our Website. Please enter your ID before proceeding." fontFamily="Arial" fontSize="14" height="45" width="374" fontWeight="bold" textAlign="center"/>
<mx:Form backgroundColor="#ffffff">
<mx:FormItem label="User ID:">
<mx:TextInput id="fldID" editable="true" enabled="true"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox id="dataView" label="View Data" height="210" width="381">
<mx:DataGrid width="376" height="197">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<mx:VBox id="contactView" label="Contact Us" width="385" height="206">
<mx:Text text="How to contact us" width="379" height="201"/>
</mx:VBox>
</mx:Accordion>
</mx:Panel>
</mx:Application>
Now this is the behaviour I'm seeing which I find a bit strange. When the user clicks from the first view to the second view with the ID not filled in, the message is displayed but they are not returned to the first view. But if the user is on the contact page (3rd view) and clicks on the 2nd view they DO get returned to the 1st page. Is this behaviour that you guys would expect based on the code? If so why? What did I miss?
Thanks in advance,
Christopher