package import flash display Sprite import flash events MouseEvent imp

 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
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.external.*;
import flash.system.System;
public class clipboard extends Sprite
{
private var text :String;
public function clipboard()
{
trace('load');
stage.addEventListener(MouseEvent.CLICK, copy );
}
private function copy(text:String):void{
trace('click event');
if(getText()){
System.setClipboard(text);
trace('Tetx in clipboard');
}else{
trace('clipboard error');
}
}
private function getText():Boolean{
if (ExternalInterface.available) {
text = ExternalInterface.call("getClipboardText()");
trace('ExternalInterface true');
return true;
}else{
trace('ExternalInterface false');
return false;
}
}
}
}