View Full Version : VDividedBox not restoring the divider position after switching states

02-18-2009, 08:25 PM
I've got two panels in a VDividedBox: a top panel and a bottom panel. Then I create a 'new' state, which will replace the top panel with a third panel. When switching back to the base state, however, the top panel doesn't occupy the original divided space, it is pushed all the way to the top and is minimized. Also, what I noticed is that, if I change the divider position before switching the states, everything works fine. Please see code attached and help me with this hopefully quick issue. Thank you.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">

<mx:VDividedBox id="navigation" width="300" height="100%">
<mx:Panel id="topPanel" title="Top" width="100%" height="50%">
<mx:Button label="New" click="{currentState='new'}"/>
<mx:Panel id="bottomPanel" title="Bottom" width="100%" height="50%"/>

<mx:Panel id="contentPanel" title="Content" width="100%" height="100%"/>

<mx:State name="new">
<mx:RemoveChild target="{topPanel}"/>

<mx:AddChild relativeTo="{navigation}" position="firstChild">
<mx:Panel id="newPanel" title="New">
<mx:Button label="Back" click="{currentState=''}"/>
<mx:SetProperty target="{newPanel}" name="width" value="{topPanel.width}"/>
<mx:SetProperty target="{newPanel}" name="height" value="{topPanel.height}"/>

<mx:SetProperty target="{bottomPanel}" name="enabled" value="false"/>
<mx:SetProperty target="{contentPanel}" name="enabled" value="false"/>