forked from mojombo/clippy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clippy.hx
44 lines (35 loc) · 1.66 KB
/
Clippy.hx
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
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 {
// Main
static function main() {
var target:String = flash.Lib.current.loaderInfo.parameters.target;
if(target == null) target = "body";
flash.Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
flash.Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT;
// button
var button:SimpleButton = 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");
button.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
var text:String = ExternalInterface.call("function(target){ var data = { text: '' }; $(target).trigger('clippycopy', data); return data.text; }", target);
flash.system.System.setClipboard(text);
ExternalInterface.call("function(target){ $(target).trigger('clippycopied'); }", target);
});
button.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent) {
ExternalInterface.call("function(target){ $(target).trigger('clippyover'); }", target);
});
button.addEventListener(MouseEvent.MOUSE_OUT, function(e:MouseEvent) {
ExternalInterface.call("function(target){ $(target).trigger('clippyout'); }", target);
});
flash.Lib.current.addChild(button);
}
}