I need to figure out which state I am currently seeing ...
& lt; Mx: states & gt; & Lt; Mx: state name = "state 1" & gt; & Lt; / Mx: addChild & gt; & Lt; / Mx: state & gt; & Lt; Mx: state name = "state2" & gt; & Lt; / Mx: addChild & gt; & Lt; / Mx: state & gt; & Lt; / Mx: states & gt;
Once I log in to my application, State 1 appears, but when I refresh the page it disappears again
As is the value of the session as of now, it is necessary to check that the session is correct, then grab the current position or go back to the default one.
You can determine the current state of the component from the current state of the property. Flex 3 is the empty string in the default state. When you refresh the browser page (which does it when using the Flash application?) You actually reload the entire Flash application, which means that all your components will be rebuilt. So if you check your session, then you have to allocate the current state of your constituent accordingly.
Based on your sample code, if you are looking at state 2, then the current state of your constituent defining state is now "state 2". This is the value that you have in your second state Is referred to as the name. To see the first state, you can
component. CurrentState = "state1";
Because it is the name of your first state. To move to the default (initial) state, you will do this:
element. CurrentState = "";
To verify that you are in another state, you do
(if.ContentState == "state2") doSomething ();
If your second state will be named "SecondState" instead of "State 2" then you will use it:
if (component.currentState == "SecondState") doSomething ();
At least this is the way for Flex 3, because as I think Flex4 introduces some changes related to the states.
Comments
Post a Comment