2012-07-19 50 views

回答

2

所以,我推荐使用自定义组件而不是HDividedBox;)。

专门为你 - 基于事件的部件,其处理在分隔双击(200毫秒 - DOUBLECLICK间隔):

<?xml version="1.0" encoding="utf-8"?> 
<mx:HDividedBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="hdividedbox1_initializeHandler(event)"> 
    <mx:Metadata> 
     [Event(name="dividerDoubleClick", type="mx.containers.DividerDblClickEvent")] 
    </mx:Metadata> 
    <mx:Script> 
     <![CDATA[ 
      import mx.controls.Alert; 
      import mx.events.DividerEvent; 
      import mx.events.FlexEvent; 

      private var _timer:Timer = new Timer(200,1);       

      protected function hdividedbox1_initializeHandler(event:FlexEvent):void{ 
       this.addEventListener(DividerEvent.DIVIDER_PRESS, divider_press); 
      }   
      protected function divider_press(event:DividerEvent):void{ 
       if(_timer.running){ 
        event.preventDefault(); 
        event.stopPropagation(); // not sure what of it use 

        dispatchEvent(new DividerDblClickEvent(DividerDblClickEvent.DOUBLE_CLICK, event.dividerIndex)); 
       }else{ 
        _timer.start(); 
       } 
      }   
     ]]> 
    </mx:Script> 
</mx:HDividedBox> 

和定制事件

package mx.containers 
{ 
    import flash.events.Event; 

    public class DividerDblClickEvent extends Event{ 

     // Define static constant. 
     public static const DOUBLE_CLICK:String = "dividerDoubleClick"; 

     public var dividerIndex:int = -1; // not set 

     public function DividerDblClickEvent(type:String, dividerIndex:int = -1, bubbles:Boolean=false, cancelable:Boolean=false){ 
      super(type, bubbles, cancelable);// Call the constructor of the superclass. 

      this.dividerIndex = dividerIndex;// Set the new property. 
     } 

     // Override the inherited clone() method. 
     override public function clone():Event { 
      return new DividerDblClickEvent(type, dividerIndex); 
     } 
    } 
} 

使用的示例:

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

    <mx:Script> 
     <![CDATA[ 
      import mx.effects.easing.Cubic; 
     ]]> 
    </mx:Script> 

    <mx:AnimateProperty id="hide" easingFunction="{Cubic.easeIn}" target="{to_hide}" property="width" toValue="0" duration="700" /> 

<c:HDividedBoxD height="100%" width="100%" dividerDoubleClick="hide.play();" > 
    <mx:VBox height="100%" width="50%" backgroundColor="#00FF00"> 
     <mx:Label text=" some text left 1"/> 
     <mx:Label text=" some text left 2"/> 
    </mx:VBox> 
    <mx:VBox id="to_hide" height="100%" width="50%" backgroundColor="#0000FF"> 
     <mx:Label text=" some text right 3"/> 
     <mx:Label text=" some text right 4"/>  
    </mx:VBox>  
</c:HDividedBoxD>  
</mx:Application> 

您可以根据需要修改该模块。我只想感谢:)