----- Original Message ----- 
From: "malik_robinson" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, November 27, 2008 12:46 AM
Subject: [flexcoders] **View States Problem**


> Hi,
>
> I am using Flex 3
>
> I am trying to use "view states" in my Flex application. My code seems
> to work fine when I just have two "view states", but when I have 3
> states (including the base state), the screen never displays all 3 at
> the same time. I am displaying these states based on the result of a
> remote call, that part works fine so the remoting part of it is not
> the problem.
>
> In Flexbuilder 3 if I go into design view, I can traverse through the
> states (base, state2, state3), and the visual displays look correct.
>
> Anyone have any idea or thoughts?
>
> Here is my code below:

snip

Hi Malik,

I have amended your code to make it runnable as an example (something you 
should have done).

Basically I have added three buttons to the base state to switch state, 
plus made some stub data providers.

Everything works as expected (in terms of view states anyway), so I don't 
think your problem is related to view states.

Paul

Amended code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical">

<mx:Script>

<![CDATA[

import mx.collections.ArrayCollection;

[Bindable]

public var subSubAreaAC:ArrayCollection = new ArrayCollection(['E','F']);

[Bindable]

public var subAreaAC:ArrayCollection = new ArrayCollection(['A','B']);

[Bindable]

public var catAC:ArrayCollection = new ArrayCollection(['C','D']);

]]>

</mx:Script>

<mx:states>


<mx:State name="state2">


<mx:AddChild relativeTo="{frm}" position="lastChild" >


<mx:FormItem label="Select Sub Area:">

<mx:ComboBox

id="cb2"

dataProvider="{subAreaAC}"

labelField="state2"

width="216" left="10" top="40" minWidth="150" />

</mx:FormItem>


</mx:AddChild>


</mx:State>


<mx:State name="state3" basedOn="state2">


<mx:AddChild relativeTo="{frm}" position="lastChild" >

<mx:FormItem label="Select Sub-Sub Area:">

<mx:ComboBox

id="cb3"

dataProvider="{subSubAreaAC}"

labelField="state3"

minWidth="150" />

</mx:FormItem>

</mx:AddChild>


</mx:State>


</mx:states>




<!-- this is basically my base state, this gets showed by default -->

<mx:HBox>

<mx:Button label="base state" click="currentState=''"/>

<mx:Button label="state2" click="currentState='state2'"/>

<mx:Button label="state3" click="currentState='state3'"/>

</mx:HBox>

<mx:Form id="frm" x="10" y="10">

<mx:FormItem label="Select a Parent Category:">

<mx:ComboBox id="cb1"

labelField="ParentCategory"

width="150" left="10" top="40"

dataProvider="{catAC}"

rowCount="{catAC.length / 2}"

/>

</mx:FormItem>

</mx:Form>


</mx:Application>

Reply via email to