Flex - 鼠标在一定区域内拖拽某个元件
作者:hangge | 2015-02-27 16:11
下面演示了一个鼠标拖动元件的样例,同时该元件拖动范围只限在父容器内部
protected function init(event:FlexEvent):void
{
cav.addEventListener(MouseEvent.MOUSE_DOWN, itemMouseDown);
cav.addEventListener(MouseEvent.MOUSE_UP, itemMouseUp);
}
private function itemMouseDown(event:MouseEvent):void{
var width:int = cav.parent.width - cav.width;
var height:int = cav.parent.height - cav.height;
cav.startDrag(false, new Rectangle(0, 0 , width, height));
}
private function itemMouseUp(event:MouseEvent):void{
cav.stopDrag();
}
全部评论(0)