0 Replies Latest reply on Jan 17, 2008 7:37 AM by Subpacket24

    States and Code-behind

    Subpacket24
      I'm using the code-behind technique to separate my logic from display in my flex application. However, when using this method, states seem to get a bit weird.

      Here's a snippet of the mxml for my states:

      - - - SNIP - - -
      <app:MyApplication xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:app="Components.*" layout="absolute" x="0" y="0" currentState="Login" xmlns:ns1="*" creationComplete="creationHandler()">
      <app:states>
      <mx:State name="Login">
      <!-- Login panel code is here. Removed to shorten illustration -->
      </mx:State>
      <mx:State name="AddEvent">
      <mx:SetProperty target="{manageEvent}" name="visible" value="true" />
      </mx:State>
      <mx:State name="Addressbook">
      <mx:SetProperty target="{addressbook1}" name="visible" value="true" />
      </mx:State>
      </app:states>
      <ns1:addressbook id="addressbook1" x="0" y="22" visible="false"> <!-- Another mxml component -->
      </ns1:addressbook>
      <ns1:newEvent id="manageEvent" x="0" y="22" visible="false"> <!-- Another mxml component -->
      </ns1:newEvent>
      </app:MyApplication>
      - - - - SNIP - - - -

      What happens is that the login state works fine, but when trying to switch to the Addressbook or AddEvent states, they don't change the visible property like they're supposed to. This code works fine when taken out of code-behind, and it also works when setting the visible property in actionscript. I'd rather not have to manage this through actionscript since states are supposed to handle this automatically, and if I can avoid pasting all my code back into the mxml file, that would be ideal.

      Anyone have any ideas as to how to solve this problem?

      Scotty