有没有办法拥有全局 Flex 4 状态(用户角色)?
我的应用程序中存在弹性状态问题。我想要做的是在应用程序创建完成后,从服务器获取用户角色 guest/user/superUser (基于用户名和密码),然后根据该信息设置状态客户端。我的 .mxml 类需要包含基于该状态的某些图形元素。我遇到了包含基于项目应用程序级别定义的状态的元素的问题。我试图避免在每个需要它的 .mxml 文件中定义状态。
我觉得这可能是我忽略的简单事情,或者也许有更好的方法来做到这一点。任何示例输入都非常有帮助。
我知道这会返回当前状态
Application.application.currentState;
,但我希望
<mx:states>
<mx:State name="state1"/>
</mx:states>
从应用程序中定义的状态几乎“填充”每个 .mxml 文件
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在寻找动态状态 - 这里就是您的解决方案(前两个状态 -
default
和big
- 在编译时添加。第三个状态Bang-a-Gong
在运行时添加):在另一种情况下,如果我理解正确,您应该在 main 应用程序中创建一些对象,并通过
FlexGlobals.topLevelApplication
从所有子组件访问它。如果你想改变子组件的状态,你应该在一个地方有一些已经定义了最小状态的实例,然后将它们复制到子组件,但是如果它们都是自定义逻辑,那有什么意义呢?
所以,如果有帮助的话,请告诉我。
If you are looking for dynamic states - here is your solution (The first two states –
default
andbig
- are added at compile time. The third stateBang-a-Gong
is added at runtime):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.