Hello flexcoders!

I have had a little break since working with Flex1.5 but now I am back. And
I must say: Flex2.0 is great.

But there are still some issues which confuse me... States and ViewStacks is
one of it.
Please have a look at the following code, and maybe you can tell me whether
I have'nt understand the States stuff right or what's going on.

The Problem:
--------
There are two state, in which both do the same:
Set the selectedIndex of a ViewStack to 1.
But when you execute them one after another. The second to be executed
always sets the selectedIndex to 0 !

You probably ask yourself why I want do something like this. The complete
code is a bit more complicated, where I have two ViewStacks(v1,v2) and got
three states: v1SetTo1, v2SetTo1, v1AndV2SetTo1. It did not work and I could
isolate the problem to the following code.

Did I do something wrong, or is this a bug? 

Thanks for your help!
Christoph



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

    <mx:states>
    
        <mx:State name="s1" id="s1" >
                <mx:SetProperty target="{appViews}" name="selectedIndex"
value="1" />        
        </mx:State>
        
        <mx:State name="s2" id="s2" >
                <mx:SetProperty target="{appViews}" name="selectedIndex"
value="1" />
        </mx:State>
        
    </mx:states>
    
    
    <mx:TextInput id="stateField"/> 
    <mx:Button label="Set State from TextField"
click="currentState=stateField.text" /> 
    
    <mx:Text htmlText="State s1 and s2 should do the same!&lt;br&gt;Set
ViewStack.selectedIndex to 2, which is Panel 2 (p2)." width="200" />
    
    <!-- setting a state -->
    <mx:Button label="Set State s1" click="currentState='s1'" /> 
    <mx:Button label="Set State s2" click="currentState='s2'" />
    
    <mx:Button label="Set BaseState " click="currentState=''" />  
    


<mx:ViewStack id="appViews" width="100%" height="200"
change="txtDebug.text=txtDebug.text+ ','+appViews.selectedIndex">
    
    <mx:Panel title="Panel 1" id="p1" width="100%" height="100%">
          <mx:Text text="Panel 1" />        
    </mx:Panel>
    
   
    <mx:Panel title="Panel 2" id="p2" width="100%" height="100%"
backgroundColor="#ff0000">
    
          <mx:Text text="Panel 2" />
    </mx:Panel>
    
</mx:ViewStack>

<mx:TextArea creationComplete="txtDebug.text = 'appViews.selectedIndex=' +
appViews.selectedIndex "  id="txtDebug" width="400" height="100%"/>

    
</mx:Application>

Reply via email to