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>

  • 相关阅读:
    BZOJ 4318: OSU!
    BZOJ 3450: Tyvj1952 Easy
    BZOJ 1426: 收集邮票
    BZOJ 1415: [Noi2005]聪聪和可可
    BZOJ 1778: [Usaco2010 Hol]Dotp 驱逐猪猡
    BZOJ 3270: 博物馆
    BZOJ 3143: [Hnoi2013]游走
    BZOJ 3166: [Heoi2013]Alo
    BZOJ 3261: 最大异或和
    BZOJ 1022: [SHOI2008]小约翰的游戏John
  • 原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100633.html
Copyright © 2011-2022 走看看