Actionscript 3 条件表达式问题的弹性估值(数据绑定?)

Actionscript 3 条件表达式问题的弹性估值(数据绑定?),actionscript-3,apache-flex,data-binding,actionscript,Actionscript 3,Apache Flex,Data Binding,Actionscript,我在Flex中遇到了条件表达式赋值的问题 让我解释一下 我有这个: <s:Label text="SomeTextLawyer" includeInLayout="{Session.isLawyer()}" visible="{Session.isLawyer()}"/> <s:Label text="SomeTextDoctor" includeInLayout="{Session.isDoctor()}" visible="{Session.isDoct

我在
Flex
中遇到了条件表达式赋值的问题

让我解释一下

我有这个:

    <s:Label text="SomeTextLawyer" includeInLayout="{Session.isLawyer()}"
 visible="{Session.isLawyer()}"/>
    <s:Label text="SomeTextDoctor" includeInLayout="{Session.isDoctor()}"
 visible="{Session.isDoctor()}"/>
我有一个改变用户的机制,所以我的用户可以先是医生,然后是律师。问题是,我的标签保持其第一次估值。如果我先以医生身份连接,如果我将用户更改为律师,我仍然会显示医生标签。反之亦然

在AS代码中,我的用户是优秀的用户,但在我的
mxml
文件中却不是这样。。。因此,只有显示的部分看不到用户切换

有什么想法吗


提前谢谢你

尝试使用可绑定的布尔变量检查用户类型,例如:

[Bindable] public var isDoctor:Boolean;
[Bindable] public var isLawyer:Boolean; 
并在显示控件例程中设置它们的值,例如:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

                [Bindable] public var isDoctor:Boolean;
                [Bindable] public var isLawyer:Boolean; 

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                isDoctor = Session.isDoctor();
                isLawyer = Session.isLawyer();
            }

        ]]>
    </fx:Script>
    <s:VGroup>
        <s:Label text="Some Text Lawyer" includeInLayout="{isLawyer}"  visible="{isLawyer}"/>
        <s:Label text="Some Text Doctor" includeInLayout="{isDoctor}"  visible="{isDoctor}"/>
    </s:VGroup>
</s:Application>


方法
isLawyer()
没有在会话``类``中定义?是的,只是编辑了我的代码(我的代码是法语的,很糟糕,我知道,但像这样…)这不是问题,我指的是方法名??我让函数的法语名,但是isLaywer()定义得很好,我编辑了代码…你更新了显示吗?如果没有,您应该更新它,通过此更新,标签将重新加载方法
isDoctor()
isLawyer
好吧,我有一个奇怪的行为,因为我只去creationCompleteHandler一次。我先是以律师身份连接,然后是以医生身份连接,我只使用了一次creationCompleteHandler函数。我提到它只是作为创建完成时的示例,但每次用户连接时,您都应该更改布尔值,例如连接方法,我使用了[Bindable]属性的解决方法,必要时正确设置每个布尔值,效果会更好。我不知道为什么它不能直接工作。。。谢谢你的主意
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

                [Bindable] public var isDoctor:Boolean;
                [Bindable] public var isLawyer:Boolean; 

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                isDoctor = Session.isDoctor();
                isLawyer = Session.isLawyer();
            }

        ]]>
    </fx:Script>
    <s:VGroup>
        <s:Label text="Some Text Lawyer" includeInLayout="{isLawyer}"  visible="{isLawyer}"/>
        <s:Label text="Some Text Doctor" includeInLayout="{isDoctor}"  visible="{isDoctor}"/>
    </s:VGroup>
</s:Application>