1.21 gigawatts
1.21 gigawatts

Reputation: 17878

How to create a state that includes other states

I have a mobile app where I have 3 states in it. There is the default portrait and landscape and I would to add a third state that includes the other two.

<s:states>
    <s:State name="portrait"/>
    <s:State name="landscape"/>
    <s:State name="panel" stateGroups="portrait, landscape"/>
</s:states>

In this third state called, "panel", I want to include the portrait and landscape states in it. When I do this I get the following error:

Identifier 'landscape' used for both a state group and a state.

BTW I've been trying to understand stateGroups and I don't think I'm getting it.

UPDATE
Here is more context. I have a container called, "appMenu" that I want to make visible when the user presses the menu key. So I want to create a state for this. Right now only one value that changes and that is the "y" property. Since this is an mobile application the device will be in a portrait or landscape mode (state). I don't want to take the user out of those states only apply this new property to whatever state they were in.

<s:BorderContainer id="appMenu"
                   borderVisible="false"
                   width="100%" 
                   height="120" 
                   y="-120"  
                   y.panelVisible="0" 
                   backgroundColor="0"
                   >
    <s:HGroup right="10" verticalCenter="0">
        <s:Label text="Feedback" 
                 color="#ffffff" 
                 fontSize="18" 
                 fontWeight="bold"/>
    </s:HGroup>
</s:BorderContainer>

Upvotes: 0

Views: 195

Answers (1)

RIAstar
RIAstar

Reputation: 11912

There are two possible answers to your question.

If the "panel' state has nothing more than what's in the two other states, then the following is all you need:

<s:states>
    <s:State name="portrait" stateGroups="panel" />
    <s:State name="landscape" stateGroups="panel" />
    <s:State name="someOtherState" />
</s:states>

If on the other hand other things are also included in the 'panel' state, then it might look more like this:

<s:states>
    <s:State name="portrait" stateGroups="panel" />
    <s:State name="landscape" stateGroups="panel" />
    <s:State name="justThePanel" stateGroups="panel" />
    <s:State name="someOtherState" />
</s:states>

If you now have

<s:Group id="a" includeIn="portrait" />
<s:Group id="b" includeIn="landscape" />
<s:Group id="c" includeIn="someOtherState" />
<s:Group id="d" includeIn="panel" />
<s:Group id="e" />

then

  • e is always displayed
  • a is only displayed in 'portrait' state
  • b is only displayed in 'landscape' state
  • c is only displayed in 'someOtherState' state
  • d is displayed in 'portrait', 'landscape', and 'justThePanel' states (because all three of these are members of the 'panel' stateGroup)

Upvotes: 1

Related Questions