2 Replies Latest reply on Nov 2, 2006 1:08 PM by nHeroGo

    Changing states from within a component

    nHeroGo Level 1
      Let's say that I have a TileList that is rendering data in a VBox. Eventually the TileList fills up and starts scrolling. I want to change states when clicking on item in the TileList.

      I don't want to place the click-attribute in the TileList, because it will change states when I am scrolling the list without actually selecting anything.

      I want to say click="currentState='state2'" inside the VBox, but that does not work because state2 is at the root level, and I don't know how to get to the root-level (in lack of a better word) from withing the component.

      This is not the proper syntax, so misunderstand me the right way here... Is there an equivallence to click="currentState='_root.state2'" in mxml?

      Thanks for any suggestions or best practices. I want the easy way out.

      This is the general structure...


      <mx:State id="state1"/>
      <mx:State id="state2"/>
      <mx:State id="state3"/>

      <mx:TileList dataprovider="{...}">
      <mx:VBox id="ClickThisBoxToChangeStates">

        • 1. Re: Changing states from within a component
          peterent Level 2
          I assume from the code snippet that you want to change the state of the Application since it is at the Application that you have <mx:states> defined.

          So why doesn't: <mx:VBox click="currentState='state2' " /> work (assuming that something inside the VBox is clickable)?
          • 2. Re: Changing states from within a component
            nHeroGo Level 1
            Your assumption is right.

            It doesn't work because there is no state2-state defined within the mx:component.

            In the documentation about changing states it says that I can go from application level and change states within a component; like this: click="currentState='mycomponent.anotherstate'" but not how I can change a state at application level from within a state. When I try, it says (at runtime) that the state is not defined.

            So I don't know why <mx:VBox click="currentState='state2'"/> doesn't work.

            I apprechiate your expertese a lot.