views:

31

answers:

1

I am having an issue with flex states in my application. What I am looking to do is on creation complete of the application, obtain a user role guest/user/superUser (based on username and password) from a server, then set the state client side based on that information. My .mxml classes need to include certain graphic elements based on that state. I am running into the issues of including elements based on the states defined at the Application level of the project. I am trying to avoid having to define the states in each .mxml file that needs it.

I feel that this is possibly something easy that I am overlooking or maybe there is a better way to do this. Any examples input is very helpful.

I know that this returns the current state

Application.application.currentState;

but I am looking to almost "populate" the

<mx:states>
    <mx:State name="state1"/>
</mx:states>

of every .mxml file from the states defined in the Application

A: 

If you are looking for dynamic states - here is your solution.

In another case, if I understood in right way, you should create some Object in main application, and access it from all child components via FlexGlobals.topLevelApplication.

If you want to change child states, you should have some instance with already defined states as minimum in one place, and later copy them, to child components, but what sense if they are all custom logic?

So, let me know, if it helps.

Eugene
FlexGlobals.topLevelApplication.yourObject.isSuperuser==true
Eugene