[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>
|