Skip to content
This repository
Newer
Older
100644 54 lines (43 sloc) 1.553 kb
c6f7e39f »
2009-02-13 first commit
1 import flash.display.MovieClip;
2 import flash.events.MouseEvent;
3 import flash.display.SimpleButton;
4 import flash.text.TextField;
5 import flash.text.TextFieldAutoSize;
6 import flash.text.TextFormat;
7
8 class Clippy {
9 // Main
10 static function main() {
11 var text:String = flash.Lib.current.loaderInfo.parameters.text;
12
13 // label
14
15 var label:TextField = new TextField();
16 var format:TextFormat = new TextFormat("Arial", 10);
17
18 label.text = "copy to clipboard";
19 label.setTextFormat(format);
20 label.textColor = 0x888888;
21 label.selectable = false;
22 label.x = 15;
23 label.visible = false;
24
25 flash.Lib.current.addChild(label);
26
27 // button
28
29 var button:SimpleButton = new SimpleButton();
30 button.useHandCursor = true;
31 button.upState = flash.Lib.attach("button_up");
32 button.overState = flash.Lib.attach("button_over");
33 button.downState = flash.Lib.attach("button_down");
34 button.hitTestState = flash.Lib.attach("button_down");
35
36 button.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent) {
37 flash.system.System.setClipboard(text);
38 label.text = "copied!";
39 label.setTextFormat(format);
40 });
41
42 button.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent) {
43 label.visible = true;
44 });
45
46 button.addEventListener(MouseEvent.MOUSE_OUT, function(e:MouseEvent) {
47 label.visible = false;
48 label.text = "copy to clipboard";
49 label.setTextFormat(format);
50 });
51
52 flash.Lib.current.addChild(button);
53 }
54 }
Something went wrong with that request. Please try again.