-
Notifications
You must be signed in to change notification settings - Fork 4
/
CloudCursor.as
169 lines (120 loc) · 4.65 KB
/
CloudCursor.as
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package
{
public class CloudCursor
{
import mx.collections.ArrayCollection;
import mx.managers.CursorManager;
private static var cursors:Array = new Array();
private static var lastCursorID:int = 0;
public static var NO_CURSOR:int = -1;
// Cursors
public static var NORMAL:int;
public static var HAND:int;
// Translate
public static var TRANSLATE:int;
public static var TRANSLATE_HORI:int;
public static var TRANSLATE_VERT:int;
// Rotate
public static var ROTATE:int;
public static var ROTATE_CW:int;
public static var ROTATE_CCW:int;
// Scale
public static var SCALE:int;
public static var SCALE_HORI:int;
public static var SCALE_VERT:int;
// DRAW
public static var DRAW_BRUSH:int;
public static var DRAW_LINE:int;
public static var DRAW_CURVE:int;
public static var DRAW_RECTANGLE:int;
public static var DRAW_ELLIPSE:int;
public static var DRAW_POLYLINE:int;
public static var DRAW_SHAPE:int;
// MISC
// TEXT
// IMAGE
// Navigator Cursors
/*
public static var MOUSEOVER_UNSELECTED_CLOUD:int;
public static var MOUSEOVER_SELECTED_CLOUD:int;
public static var MOUSEOVER_TRANSLATE_BTN:int;
public static var MOUSEOVER_ROTATE_BTN:int;
public static var MOUSEOVER_SCALE_BTN:int;
public static var MOUSEDOWN_TRANSLATE_BTN:int;
public static var MOUSEDOWN_ROTATE_BTN:int;
public static var MOUSEDOWN_SCALE_BTN:int;
public static var MOUSEMOVE_TRANSLATE_BTN:int;
public static var MOUSEMOVE_ROTATE_BTN:int;
public static var MOUSEMOVE_SCALE_BTN:int;
public static var MOUSEUP_TRANSLATE_BTN:int;
public static var MOUSEUP_ROTATE_BTN:int;
public static var MOUSEUP_SCALE_BTN:int;
*/
// TODO: dynamic image cursor, ajustable scale? for the draw tools
public function CloudCursor()
{
// NORMAL CURSOR
NORMAL = CursorManager.NO_CURSOR;
//NORMAL = cursors.push({cusorClass: Globals.g_assets.CursorArrow, priority: 1.0,
// offsetX: -2, offsetY: -2});
// HAND CURSOR
HAND = cursors.push({cusorClass: Globals.g_assets.CursorHand, priority: 1.0,
offsetX: -9, offsetY: -2});
// TRANSLATE CURSOR
TRANSLATE = cursors.push({cusorClass: Globals.g_assets.CursorTranslate, priority: 2.0,
offsetX: -16, offsetY: -16});
TRANSLATE_HORI = cursors.push({cusorClass: Globals.g_assets.CursorTranslateHori, priority: 2.0,
offsetX: -16, offsetY: -16});
TRANSLATE_VERT = cursors.push({cusorClass: Globals.g_assets.CursorTranslateVert, priority: 2.0,
offsetX: -16, offsetY: -16});
// DRAW CURSORS
DRAW_BRUSH = cursors.push({cusorClass: Globals.g_assets.CursorBrush, priority: 1.0,
offsetX: 0, offsetY: 0});
DRAW_LINE = cursors.push({cusorClass: Globals.g_assets.CursorLine, priority: 2.0,
offsetX: -7, offsetY: -7});
DRAW_CURVE = cursors.push({cusorClass: Globals.g_assets.CursorCurve, priority: 2.0,
offsetX: -7, offsetY: -7});
DRAW_RECTANGLE = cursors.push({cusorClass: Globals.g_assets.CursorRectangle, priority: 2.0,
offsetX: -7, offsetY: -7});
DRAW_ELLIPSE = cursors.push({cusorClass: Globals.g_assets.CursorEllipse, priority: 2.0,
offsetX: -7, offsetY: -7});
DRAW_SHAPE = cursors.push({cusorClass: Globals.g_assets.CursorShape, priority: 2.0,
offsetX: -7, offsetY: -7});
/*
// Rotate
ROTATE = CursorManager.setCursor(Globals.g_assets.CursorRotate, 2.0);
ROTATE_CW = CursorManager.setCursor(Globals.g_assets.CursorRotateCW, 2.0);
ROTATE_CCW = CursorManager.setCursor(Globals.g_assets.CursorRotateCCW, 2.0);
// Scale
SCALE = CursorManager.setCursor(Globals.g_assets.CursorScale, 2.0);
SCALE_HORI = CursorManager.setCursor(Globals.g_assets.CursorScaleHori, 2.0);
SCALE_VERT = CursorManager.setCursor(Globals.g_assets.CursorScaleVert, 2.0);
*/
// Set normal cursor by default
SetCursor(NORMAL);
}
private static var lastCursorIndex:int = -1;
public static function SetCursor(cursorID:int):void
{
if(cursorID == -1)
{
CursorManager.removeAllCursors();
//CursorManager.setCursor(CursorManager.NO_CURSOR);
}
if(lastCursorID != cursorID) // changed cursor
{
//var lastCursor:Object = cursors[lastCursorID];
if(lastCursorIndex >= 0)
{
CursorManager.removeCursor(lastCursorIndex);
}
var cursor:Object = cursors[cursorID-1];
if(cursor)
{
lastCursorIndex = CursorManager.setCursor(cursor.cusorClass, 2.0, cursor.offsetX, cursor.offsetY);
}
lastCursorID = cursorID;
}
}
}
}