首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

DragManager拖沓控制

2012-11-12 
DragManager拖拉控制讨厌的DragManager ?在一个容器上覆盖了层,透明png,然后容器里面就接受不到drag的任何

DragManager拖拉控制

讨厌的DragManager

?

在一个容器上覆盖了层,透明png,然后容器里面就接受不到drag的任何事件了。翻看flex框架代码发现是在DragProxy里面做的判断,还是没有对drag忽略的代码。

?

没辙了,只好用MouseMove来做了:

    <?xml?version="1.0"?> ??<!--?Simple?example?to?demonstrate?the?ComboBox?control.?--> ??<mx:Application?xmlns:mx="http://www.adobe.com/2006/mxml"?xmlns:local="*"? ??????applicationComplete="applicationCompleteHandler()"> ??????<mx:Canvas?id="ppp"?width="440"?height="267"??backgroundColor="#FFFFFF"??????????blendMode="{BlendMode.LAYER}"> ????????<mx:Image??source="Creek.jpg"? ??????????maintainAspectRatio="false"???????????mouseEnabled="false"?mouseChildren="false"?width="100%"?height="100%"/> ???????<mx:Canvas?id="c"?width="80%"?height="80%"???????????horizontalCenter="0"?verticalCenter="0"?borderStyle="solid"?borderThickness="20"? ???????????borderColor="#33003E"?backgroundColor="#E8E8E8"/> ???????<local:DragIgnoreImage ???????????mouseEnabled="false"?mouseChildren="false"?width="100%"?height="100%"/>????? ??????</mx:Canvas> ??????<mx:Image?id="p"?width="100"?height="100"?source="Desert?Landscape.jpg"?mouseDown="imageMouseDownHandler(event)"/> ??????????<mx:List?dragEnabled="true">? ??????????<mx:dataProvider> ??????????????<mx:String>AK</mx:String> ??????????????<mx:String>AL</mx:String> ??????????????<mx:String>AR</mx:String> ??????????</mx:dataProvider> ??????</mx:List> ??????<mx:Script> ??????????<![CDATA[ ??????????????import?mx.core.IFlexDisplayObject; ??????????????import?mx.core.DragSource; ??????????????import?mx.core.UIComponent; ??????????????import?mx.events.DragEvent; ??????????????import?mx.managers.DragManager; ??????????????private?function?applicationCompleteHandler():void?{ ??????????????????stage.addEventListener(MouseEvent.MOUSE_DOWN,stageMousedownhandler); ??????????????} ?????????????? ??????????????private?function?stageMousedownhandler(e:MouseEvent):void?{ ??????????????????stage.addEventListener(MouseEvent.MOUSE_MOVE,stageMouseMovehandler); ??????????????????stage.addEventListener(MouseEvent.MOUSE_UP,stageMouseUpHandler); ??????????????} ?????????????? ??????????????private?function?stageMouseMovehandler(e:MouseEvent):void?{ ??????????????????var?p:Point?=?new?Point(e.stageX,e.stageY); ??????????????????p?=?c.globalToLocal(p); ?????????????????? ??????????????????if(DragManager.isDragging)?{ ??????????????????????if(c.getBounds(c).containsPoint(p))?{ ??????????????????????????c.setStyle("backgroundColor",0xFFFFF000); ??????????????????????} ??????????????????????else?{ ???????????????????????????c.setStyle("backgroundColor",0xFF00F000); ??????????????????????} ??????????????????} ??????????????} ?????????????? ??????????????private?function?stageMouseUpHandler(e:MouseEvent):void?{ ??????????????????stage.removeEventListener(MouseEvent.MOUSE_MOVE,stageMouseMovehandler); ??????????????????stage.removeEventListener(MouseEvent.MOUSE_UP,stageMouseUpHandler); ??????????????} ?????????????? ??????????????private?function?imageMouseDownHandler(e:MouseEvent):void?{ ??????????????????var?dragInitiator:Image=p; ??????????????????var?ds:DragSource?=?new?DragSource(); ??????????????????ds.addData(dragInitiator,?"img");??????????????? ?????????????????? ??????????????????var?d:Image?=?new?Image(); ??????????????????d.width?=?d.height?=?100; ??????????????????d.source?=?p.source; ??????????????????DragManager.doDrag(dragInitiator,?ds,?e,d); ??????????????} ??????????]]> ??????</mx:Script> ??

热点排行