zoukankan      html  css  js  c++  java
  • flex中简单的拖曳

    下面是源码:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init();">
    <mx:Script>
       <![CDATA[
        private function init(){
         this.gic.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
        }
       
        private function onMouseDown(event:MouseEvent):void{
    //     (event.currentTarget as Sprite).startDrag();
         gic.startDrag();
         gic.removeEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
         stage.addEventListener(Event.ENTER_FRAME,onEnterFrames);
         stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
        }
       
        private function onMouseUp(event:MouseEvent):void{
    //     (event.target as Sprite).stopDrag();
         gic.stopDrag();
         stage.removeEventListener(Event.ENTER_FRAME,onEnterFrames);
         stage.removeEventListener(MouseEvent.MOUSE_UP,onMouseUp);
         gic.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
        }
       
        private function onEnterFrames(event:Event):void{
         txt.x=gic.x+gic.contentWidth;
         txt.y=gic.y;
        }
       ]]>
    </mx:Script>

    <mx:HBox>
       <mx:Image source="img/test.gif" id="gic"/>
       <mx:TextInput id="txt" />
    </mx:HBox>
    </mx:Application>

  • 相关阅读:
    e552. 取Applet的参数
    e551. 精简的Applet
    e558. 在Applet中多图片交互显示
    e1087. try/catch语句
    e1086. if/else语句
    e1087. 用For循环做数组的遍历
    e1084. 捕获错误和异常
    Zookeeper 应用程序
    Zookeeper API
    Java并发编程:volatile关键字解析
  • 原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100633.html
Copyright © 2011-2022 走看看