Flex拖拽控件效果 博客分类: Flex flex
程序员文章站
2024-02-18 23:49:22
...
这里主要的是事件监听
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.SandboxMouseEvent;
protected function button1_mouseDownHandler(event:MouseEvent):void
{
event.target.startDrag(false,new Rectangle(this.x,this.y,this.width,this.height));
systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_UP, StopDrag);
systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE,StopDrag);
}
private function StopDrag(e:Event):void
{
e.currentTarget.stopDrag();
systemManager.getSandboxRoot().removeEventListener(MouseEvent.MOUSE_UP,StopDrag);
systemManager.getSandboxRoot().removeEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE,StopDrag);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="28"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="115"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="86"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="57"/>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.SandboxMouseEvent;
protected function button1_mouseDownHandler(event:MouseEvent):void
{
event.target.startDrag(false,new Rectangle(this.x,this.y,this.width,this.height));
systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_UP, StopDrag);
systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE,StopDrag);
}
private function StopDrag(e:Event):void
{
e.currentTarget.stopDrag();
systemManager.getSandboxRoot().removeEventListener(MouseEvent.MOUSE_UP,StopDrag);
systemManager.getSandboxRoot().removeEventListener(SandboxMouseEvent.MOUSE_UP_SOMEWHERE,StopDrag);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="28"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="115"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="86"/>
<s:Button label="Drag" mouseDown="button1_mouseDownHandler(event)" x="65" y="57"/>
</s:Application>
推荐阅读
-
Flex拖拽控件效果 博客分类: Flex flex
-
flex4 ComboBox下拉框怎么清空?? 博客分类: Flex flexflex4comboboxselectedIndexs
-
Flex4本地文件读写 博客分类: Flex flex
-
[Flex 2 + ActionScript 3]读书清单(不断更新中...) 博客分类: Flex AIR AS3 FlexActionScript读书Adobe出版
-
Flex 项目启动,只有短短20天 :~( 博客分类: Flex AIR AS3 FlexJSPTomcatPHPDAO
-
flex单击和双击响应事件区分处理 博客分类: flex flex
-
flex单击和双击响应事件区分处理 博客分类: flex flex
-
Flex与JS相互调用 博客分类: 开发杂记 flexjavascript
-
Flex和js互调 博客分类: 开发杂记 flexjavascript
-
Flex和js互调 博客分类: 开发杂记 flexjavascript