Apache flex currentStateChange和currentStateChanging不会在Flex中触发

Apache flex currentStateChange和currentStateChanging不会在Flex中触发,apache-flex,Apache Flex,我想在我的应用程序中使用currentStateChange事件,但在此事件中调用的任何代码都没有执行,因此我认为我的代码可能有问题,所以我尝试在adobe live docs中的一个示例上测试它。 所以我举了这个例子 我所做的就是在面板一的currentStateChange和currentStateChanging两个事件中都放置了一个警报,但我在单击面板时没有收到警报。 我还尝试用一个函数调用来替换内联代码,使警报也不会发生任何事情 我在这里做的有什么不对吗 谢谢您正在收听p1的状态

我想在我的应用程序中使用currentStateChange事件,但在此事件中调用的任何代码都没有执行,因此我认为我的代码可能有问题,所以我尝试在adobe live docs中的一个示例上测试它。 所以我举了这个例子


我所做的就是在面板一的currentStateChange和currentStateChanging两个事件中都放置了一个警报,但我在单击面板时没有收到警报。 我还尝试用一个函数调用来替换内联代码,使警报也不会发生任何事情

我在这里做的有什么不对吗


谢谢

您正在收听
p1
的状态更改,但您从未更改该面板的状态:
p1。当前状态保持不变。状态不是自动继承的或类似的。

如果希望看到状态更改,请在正在设置其状态的容器上添加侦听器。在您链接到的示例中,它位于应用程序标记上。

我似乎误解了currentState的部分,因为我认为单击“currentState='One'”会将p1的当前状态从基本状态更改为状态“One”,而不是容器的状态。谢谢,当我将事件移动到应用程序标记时,它现在正在工作。
<mx:states>
    <mx:State name="One">
        <mx:SetProperty target="{p1}" name="x" value="110"/>
        <mx:SetProperty target="{p1}" name="y" value="0"/>
        <mx:SetProperty target="{p1}" name="width" value="200"/>
        <mx:SetProperty target="{p1}" name="height" value="210"/>
        <mx:SetProperty target="{p2}" name="x" value="0"/>
        <mx:SetProperty target="{p2}" name="y" value="0"/>
        <mx:SetProperty target="{p2}" name="width" value="100"/>
        <mx:SetProperty target="{p2}" name="height" value="100"/>
        <mx:SetProperty target="{p3}" name="x" value="0"/>
        <mx:SetProperty target="{p3}" name="y" value="110"/>
        <mx:SetProperty target="{p3}" name="width" value="100"/>
        <mx:SetProperty target="{p3}" name="height" value="100"/>
    </mx:State>
    <mx:State name="Two">
        <mx:SetProperty target="{p2}" name="x" value="110"/>
        <mx:SetProperty target="{p2}" name="y" value="0"/>
        <mx:SetProperty target="{p2}" name="width" value="200"/>
        <mx:SetProperty target="{p2}" name="height" value="210"/>
        <mx:SetProperty target="{p3}" name="x" value="0"/>
        <mx:SetProperty target="{p3}" name="y" value="110"/>
        <mx:SetProperty target="{p3}" name="width" value="100"/>
        <mx:SetProperty target="{p3}" name="height" value="100"/>
    </mx:State>
</mx:states>

<!-- Define Transition array with one Transition object.-->
<mx:transitions>
    <!-- A transition for changing from any state to any state. -->
    <mx:Transition id="myTransition" fromState="*" toState="*">
        <!-- Define a Parallel effect as the top-level effect.-->
        <mx:Parallel id="t1" targets="{[p1,p2,p3]}">
            <!-- Define a Move and Resize effect.-->
            <mx:Move  duration="400"/>
            <mx:Resize duration="400"/>
        </mx:Parallel>
    </mx:Transition>
</mx:transitions>

<!-- Define the Canvas container holding the three Panel containers.-->
<mx:Canvas id="pm" width="100%" height="100%" >
    <mx:Panel id="p1" title="One" 
            x="0" y="0" width="100" height="100"
            click="currentState='One'" currentStateChange="Alert.show('change')" currentStateChanging="Alert.show('changing')" >
        <mx:Label fontSize="24" text="One"/>
    </mx:Panel>

    <mx:Panel id="p2" title="Two" 
            x="0" y="110" width="100" height="100"
            click="currentState='Two'" >
        <mx:Label fontSize="24" text="Two"/>
    </mx:Panel>

    <mx:Panel id="p3" title="Three" 
            x="110" y="0" width="200" height="210" 
            click="currentState=''" >
        <mx:Label fontSize="24" text="Three"/>
    </mx:Panel>
</mx:Canvas>