ボタン付きのパネルがあります。ボタンをクリックすると、パネルが「State2」の状態になり、さらに 2 つのボタンがパネルに追加されます。状態の変更中に、最初にパネルのサイズを変更してから、新しく追加された 2 つのボタンを表示するようにしたいので、状態の変更にトランジションを適用しました。
私の質問は:
HBox 内の addChild タグのすぐ下に 2 つのボタンを配置すると、正常に動作します。ただし、同じコード (2 つのボタンを含む HBox) で新しいコンポーネントを作成し、新しいコンポーネントをパネルに追加すると (コメントされたコードの Comp)、サイズ変更効果は表示されません。
誰かがこれを修正する方法を教えてもらえますか? 前もって感謝します。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
currentState="State2";
}
]]>
</mx:Script>
<mx:transitions>
<mx:Transition>
<mx:Sequence targets="{[comp,panel1]}">
<mx:Resize target="{panel1}" />
<mx:AddChildAction />
</mx:Sequence>
</mx:Transition>
</mx:transitions>
<mx:states>
<mx:State name="State2">
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:HBox id="comp">
<mx:Button label="B" />
<mx:Button label="C" />
</mx:HBox>
<!--<local:Comp id="comp" />-->
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Panel layout="horizontal" borderThickness="1" borderStyle="solid" id="panel1" title="AB">
<mx:Button label="A" click="button1_clickHandler(event)"/>
</mx:Panel>
</mx:Application>