views:

311

answers:

1

Flex 4 introduces states that are localized within a skin, and within a component. This makes sense on an MVC model, so the visual elements can have their own states (i.e. for a button: up, down, over, etc.) which are separate from a component's state. Yet, how would one go about making a global application state? Is there something already in the SDK similar to what I'm looking for?

Further clarification: Let's say we have an application that has 3 separate "modes" that will change not only the visual appearance of current elements, but the properties and elements of a container or component. Therefore, it would be highly useful to have states for not only every component and skin, but have states for the entire application. Basically, it's another layer of abstraction. Going back to the button example, say we have the up, down and over states, but then there are 3 separate up, down and over states for global application state 1, and another 3 separate states for global application state 2, and so on and so forth.

For you visual learners:

states in a custom skin for a button might look like this with global application states:

         <s:states>
   <s:ApplicationState name="mode1">
    <s:State name="up" />
    <s:State name="over" />
    <s:State name="down" />
   </s:ApplicationState>
   <s:ApplicationState name="mode2">
    <s:State name="up" />
    <s:State name="over" />
    <s:State name="down" />
   </s:ApplicationState>
   <s:ApplicationState name="mode3">
    <s:State name="up" />
    <s:State name="over" />
    <s:State name="down" />
   </s:ApplicationState>
  </s:states>

  <s:Button label.mode1.up="Application is in mode1" label.mode2.up="Application is in mode2" label.mode3.over="etc., etc., etc."/>

Thanks

A: 

no, there is not support for "sub" states like this. What you could do though is have mode1_up, mode1_over, mode1_down, mode2_up, mode2_over, mode2_down etc and then just have which mode you are in based on a private variable and switch out accordingly. do you think that would work for what you are trying to do?

Ryan Guill