forked from mojombo/clippy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclippy.hx
More file actions
75 lines (61 loc) · 2.12 KB
/
clippy.hx
File metadata and controls
75 lines (61 loc) · 2.12 KB
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
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.external.ExternalInterface;
class Clippy {
static var text:String;
static var func:String;
static var label:TextField;
static var button:SimpleButton;
static var format:TextFormat;
static function upFunction (e:MouseEvent) {
if(ExternalInterface.available) {
ExternalInterface.marshallExceptions = true;
if(func != '') {
text = ExternalInterface.call(func);
}
}
flash.system.System.setClipboard(text);
label.text = "copied!";
label.setTextFormat(format);
}
static function overFunction (e:MouseEvent) {
label.textColor = 0x666666;
}
static function outFunction(e:MouseEvent) {
label.textColor = 0x888888;
label.text = "copy to clipboard";
label.setTextFormat(format);
}
// Main
static function main() {
text = flash.Lib.current.loaderInfo.parameters.text;
func = flash.Lib.current.loaderInfo.parameters.func;
// label
label = new TextField();
format = new TextFormat("Arial", 11);
label.text = "copy to clipboard";
label.setTextFormat(format);
label.textColor = 0x888888;
label.selectable = false;
label.x = 15;
flash.Lib.current.addChild(label);
// button
button = new SimpleButton();
button.useHandCursor = true;
button.upState = flash.Lib.attach("button_up");
button.overState = flash.Lib.attach("button_over");
button.downState = flash.Lib.attach("button_down");
button.hitTestState = flash.Lib.attach("button_down");
label.addEventListener(MouseEvent.MOUSE_UP, upFunction );
button.addEventListener(MouseEvent.MOUSE_UP, upFunction );
label.addEventListener(MouseEvent.MOUSE_OVER, overFunction);
button.addEventListener(MouseEvent.MOUSE_OVER, overFunction);
label.addEventListener(MouseEvent.MOUSE_OUT, outFunction);
button.addEventListener(MouseEvent.MOUSE_OUT, outFunction);
flash.Lib.current.addChild(button);
}
}