给HDividedBox的dividerPress

本文介绍了一种使用HDividedBox组件实现一侧界面动态隐藏和显示的方法。通过监听dividerPress事件,结合resize效果实现界面的展开与收起。文中详细展示了具体的Flex代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我希望,点击HDividedBox的divider时,HDividedBox的一侧隐藏,而当我再次点击divider时显示。

了解到HDividedBox针对divider有:dividerDrag、dividerPress、dividerRelease三个事件。

分别是拖拽、按下、释放。

我选择在按下的时候触发一个事件。然后,在隐藏时,给了一个resize的效果。。。源码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
<mx:Style>
HDividedBox{
horizontalDividerCursor:Embed(source="assets/allow.png");
}

</mx:Style>
<mx:Script>
<![CDATA[
   import mx.core.UIComponent;
   import mx.events.DividerEvent;

        
   private function hiddenLeft(event:DividerEvent):void{
    var child:UIComponent = event.target.getChildAt(0);
    if(child.width == 0){
     expand1.play();
    }else{
     expand.play();
    }
   }

   ]]>
</mx:Script>
<mx:Resize id="expand" target="{childcontain}" widthTo="0"
        duration="1000"/>
<mx:Resize id="expand1" target="{childcontain}" widthTo="400"
        duration="1000"/>         
<mx:HDividedBox width="100%" height="100%" dividerPress="hiddenLeft(event)" id="container">
<mx:VDividedBox width="400" height="100%" id="childcontain">
<mx:Panel width="100%" height="600" id="pan"/><mx:VBox width="100%" height="100%"/>
</mx:VDividedBox>
<mx:Canvas height="100%" width="100%"/>
</mx:HDividedBox>
</mx:Application>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值