flex图片拖动效果

[flex]图片拖动效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version= "1.0"  encoding= "utf-8" ?>
<mx:Application xmlns:mx= "http://www.adobe.com/2006/mxml"  layout= "horizontal"  horizontalScrollPolicy= "off"  verticalScrollPolicy= "off"  backgroundGradientAlphas= "0.5"  backgroundGradientColors= "black"  color= "#FFFFFF"  backgroundColor= "#FFFFFF" >
     <mx:Script>
  <![CDATA[
     import  mx.events.ListEvent;
   // horizontalScrollPolicy="off" verticalScrollPolicy="off" 这二个属性为off 时,是超过容器的边框时,不会有下拉框
   var  oldx,oldy: Number ;
   function  mouseMove(event:MouseEvent): void {
    if (event.buttonDown){
    var  x: Number =event.stageX-oldx; //移动的x坐标
    var  y: Number =event.stageY-oldy; //移动的y坐标
    oldx=event.stageX;  //把当时的坐标 给oldx oldy
    oldy=event.stageY;
    p.move(p.x+x,p.y+y); //move 是移动函数
    }
   }
   
   private  function  mouseDown(event:MouseEvent): void {
     CursorManager.removeAllCursors();
    cursorID = CursorManager.setCursor(BugDeleteIcon);
    oldx=event.stageX; // 当鼠标按下时,就把当时的坐标 给oldx oldy
    oldy=event.stageY;
 
   }
   
   private  function  mouseUp(event:MouseEvent): void {
     CursorManager.removeAllCursors();
    cursorID = CursorManager.setCursor(BugIcon);
   }
  ]]>
</mx:Script>
<mx:Script >
         <![CDATA[
             import  mx.managers.CursorManager;
  
             [Bindable]
             [Embed(source= "img/zhang.png" )]
             private  var  BugIcon:Class;
  
             [Bindable]
             [Embed(source= "img/quan.png" )]
             private  var  BugDeleteIcon:Class;
  
             private  var  cursorID: int ;
         ]]>
</mx:Script >
 
 
  <mx:Panel id= "p"  x= "180"  y= "128"  width= "1589"  height= "1640"  layout= "absolute"  title= "上海地铁总平面图"  mouseMove= "mouseMove(event)"
    mouseDown= "mouseDown(event)"   mouseUp= "mouseUp(event)"   backgroundImage= "@Embed(source='img/mapnew.gif')"  borderThicknessLeft= "0"  borderThicknessRight= "0"
    borderThicknessTop= "0"  rollOver= "cursorID = CursorManager.setCursor(BugIcon);"  rollOut= "CursorManager.removeCursor(cursorID);"  fontSize= "12"  color= "#1F5DB2"  backgroundSize= "100%" >
  </mx:Panel>
</mx:Application>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值