Applicazione con tre stati

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/halo"
               minWidth="1024" minHeight="768" 
               currentState="Stato1" >

  <s:states>
    <s:State name="Stato1"/>
    <s:State name="Stato2"/>
    <s:State name="Stato3"/>
  </s:states>
  
  <fx:Script>
    <![CDATA[

      import mx.events.FlexEvent;
      
      [Bindable]
      private var currentIndex:Number=0;
      
      protected function btnGiu_clickHandler(event:MouseEvent):void
      {
        currentIndex--;
        if(currentIndex<=0)currentIndex=0;
        currentState="Stato"+(currentIndex+1);
      }
      protected function btnSu_clickHandler(event:MouseEvent):void
      {
        currentIndex++;
        if(currentIndex>=2)currentIndex=2;
        currentState="Stato"+(currentIndex+1);
      }

    ]]>
  </fx:Script>
  
  <mx:Label id="label" text="{currentIndex+1}" x="25" y="16"  height="133" width="140"
           fontFamily="Arial" fontSize="120" textAlign="center" 
           color.Stato1="#ff0000" 
           color.Stato2="#00ff00"
           color.Stato3="#0000ff" />

  <s:Button id="btnGiu" includeIn="Stato2,Stato3" x="25" y="157" label="Giu" width="45"
            click="btnGiu_clickHandler(event)"/>
            
  <s:Button id="btnSu" x="117" y="157" label="Su" width="45" includeIn="Stato1,Stato2" 
            click="btnSu_clickHandler(event)"/>
            
  <s:layout><s:BasicLayout/></s:layout>
</s:Application>