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
Actionscript 3 Flex:更改状态有时无法更改显示_Actionscript 3_Apache Flex_Flex3 - Fatal编程技术网

Actionscript 3 Flex:更改状态有时无法更改显示

Actionscript 3 Flex:更改状态有时无法更改显示,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,我有一个flex3 web应用程序,它使用states类在同一页面上显示服务器的一些数据 MXML代码部分如下所示: <mx:states> <mx:State name="Chart"> <mx:AddChild position="lastChild"> <ns2:ChartPanel right="10" top="182" left="10" bottom="10"></ns2:Char

我有一个flex3 web应用程序,它使用states类在同一页面上显示服务器的一些数据

MXML代码部分如下所示:

<mx:states>
    <mx:State name="Chart">
        <mx:AddChild position="lastChild">
            <ns2:ChartPanel right="10" top="182" left="10" bottom="10"></ns2:ChartPanel>
        </mx:AddChild>
    </mx:State>
    <mx:State name="List">
        <mx:AddChild position="lastChild">
            <ns2:TabularPanel right="10" top="182" left="10" bottom="10"></ns2:TabularPanel>
        </mx:AddChild>
    </mx:State>
    <mx:State name="ChatHistory">
        <mx:AddChild position="lastChild">
            <ns2:ChatHistoryPanel right="10" top="182" left="10" bottom="10"></ns2:ChatHistoryPanel>
        </mx:AddChild>
    </mx:State>
</mx:states>
初始状态为“图表”

问题是:

除了从“聊天历史记录”切换到“列表”时,在状态之间切换工作正常。显示不会更改,但仍保留在ChatHistoryPanel内容上

我完全不知道问题出在哪里。我找不到任何解决办法。 任何建议都将不胜感激,甚至可以作为我正在尝试做的工作的变通方法

我使用的是:Flash Builder 4.5、Flex3、Windows 7、Chrome

非常感谢


在您的状态切换代码中,您有以下内容:

    if (btnList.selected)
    {
        UsersDataController.getListOfParticipants();
        currentState == "List"; //This checks equality instead of updating the property
    }
您应该将其更改为:

    if (btnList.selected)
    {
        UsersDataController.getListOfParticipants();
        currentState = "List"; //This effectively updates your currentState property
    }
因此,这只是一个打字错误:p


干杯

向我们展示执行实际切换的代码。有什么理由不使用ViewStack吗?我继承了这段代码并添加了我自己的状态,我将研究ViewStack。用于更改当前状态的代码段已添加到上述文章中。谢谢天哪,这样一个蹩脚的错误:)在Flash Builder 4.5中,对于这种情况,没有警告或编译器错误吗???@oferbar,没有警告或错误(因为它不是一个错误,而且代码非常好)。然而,正如Dennis提到的,您可能应该使用ViewStack而不是states。它使用起来更简单,我记得在Flex3中,状态是个麻烦。Flex 4有了很大改进:)
    if (btnList.selected)
    {
        UsersDataController.getListOfParticipants();
        currentState = "List"; //This effectively updates your currentState property
    }