Here's an example of something that tripped me up when handling a 
dividerRelease event for a divided box.

In the event handler I was using the width of an element inside the divided box 
and using the revised width in a calculation (after all the divider had been 
dragged), but after some experimentation it seemed that the calculations were 
always 'one drag behind', never the expected width.

Turns out that when the dividerRelease event is called, the components inside 
the divided box haven't yet been resized!

Small example application below (which includes a workaround by handling the 
component resize directly, rather than via the dividerRelease).

Just in case some others might trip up on this like I did!

Paul

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical">
<mx:Script>
 <![CDATA[
  private function dividerReleased(event:Event):void {
   dividerReleaseText.text="releasehandler box1 width = "+box1.width;
  }
  
  private function boxResized(event:Event):void {
   boxResizedText.text="resizehandler box1 width = "+box1.width;
  }
 ]]>
</mx:Script>
<mx:HDividedBox id="db"  dividerRelease="dividerReleased(event)" width="200">
 <mx:Box id="box1" width="50%" height="25" backgroundColor="red" 
backgroundAlpha="1.0"
   resize="boxResized(event)"
  />
 <mx:Box id="box2" width="50%" height="25" backgroundColor="green" 
backgroundAlpha="1.0" />
</mx:HDividedBox>

<mx:Text text="bound box1 width {box1.width}" />
<mx:Text id="dividerReleaseText" text="not set" />
<mx:Text id="boxResizedText" text="not set" />
</mx:Application>

Reply via email to