Flex拖动原来如此简单

<?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[
                private function startMove(event:Event):void{
                    UIComponent(event.target).startDrag(); 
                }    
                private function stopMove(event:Event):void{
                    UIComponent(event.target).stopDrag(); 
                } 
     
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
        </fx:Declarations>
         
        <s:Panel id="mvPanel" mouseDown="startMove(event)" mouseUp="stopMove(event)" title="开始拖动吧" />
    </s:Application>
posted @ 2011-10-13 16:14  Marksion  阅读(298)  评论(0编辑  收藏  举报