Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 有没有一种方法可以使全局Flex 4状态(用户角色)保持一致?_Apache Flex_Flex4_Mxml_States - Fatal编程技术网

Apache flex 有没有一种方法可以使全局Flex 4状态(用户角色)保持一致?

Apache flex 有没有一种方法可以使全局Flex 4状态(用户角色)保持一致?,apache-flex,flex4,mxml,states,Apache Flex,Flex4,Mxml,States,我的应用程序中存在flex状态问题。我要做的是在应用程序创建完成后,根据用户名和密码从服务器获取用户角色guest/user/superUser,然后根据该信息设置状态客户端。My.mxml类需要包含基于该状态的某些图形元素。我遇到了基于项目应用程序级别定义的状态包含元素的问题。我试图避免在每个需要它的.mxml文件中定义状态 我觉得这可能是我忽略的一件容易的事情,或者可能有更好的方法来做到这一点。任何示例输入都非常有用 我知道这会返回当前状态 Application.application.c

我的应用程序中存在flex状态问题。我要做的是在应用程序创建完成后,根据用户名和密码从服务器获取用户角色guest/user/superUser,然后根据该信息设置状态客户端。My.mxml类需要包含基于该状态的某些图形元素。我遇到了基于项目应用程序级别定义的状态包含元素的问题。我试图避免在每个需要它的.mxml文件中定义状态

我觉得这可能是我忽略的一件容易的事情,或者可能有更好的方法来做到这一点。任何示例输入都非常有用

我知道这会返回当前状态

Application.application.currentState;
但我希望几乎可以在

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

如果您正在寻找动态状态,那么在应用程序中定义的状态中的每个.mxml文件中,您的解决方案是否为前两个状态(默认状态和大状态)都是在编译时添加的。在运行时添加第三个状态Bang-a-Gong:

private function init():void {
    // Create a new state and give it a name.
    var stateBang:State = new State();
    stateBang.name = 'Bang-a-Gong';

    // Set the overrides with an array of AddChild, AddItems,
    // RemoveChild, SetEventHandler, SetProperty, and SetStyle
    stateBang.overrides =
        [ new SetProperty( btn, "label", "Bang-a-Gong" ),
          new SetProperty( btn, "height", "150" ),
          new SetProperty( btn, "width", "300" ),
          new SetStyle( btn, "fontSize", "22" ),
          new SetStyle( btn, "fontWeight", "bold" ),
          new SetStyle( btn, "color", "#FF0000" ) ];

    // Add our new state to the available states of this component.
    this.states.push( stateBang );

    // Just for kicks lets add a transition for this state.
    var transition:Transition = new Transition();
    transition.toState = 'Bang-a-Gong';

    // Create a new transition effect.
    var resize:Resize = new Resize( btn );

    // Create an composite effect, either: Sequence or Parallel.
    var sequence:Sequence = new Sequence();

    // Add our resize effect.
    sequence.addChild( resize );

    // now add our composition effect to the transition we created.
    transition.effect = sequence;

    // Push our new transition into the transitions array for this component.
    this.transitions.push( transition );
}

在另一种情况下,若我理解正确,您应该在主应用程序中创建一些对象,并通过FlexGlobals.topLevelApplication从所有子组件访问它

如果您想更改子状态,您应该在一个地方有一些已定义状态为最小值的实例,然后再将它们复制到子组件,但如果它们都是自定义逻辑又有什么意义呢


所以,如果有帮助,请告诉我。

FlexGlobals.topLevelApplication.yourObject.isSuperuser==true