Advertisement
Guest User

ZeroClipboard.swf

a guest
Jun 25th, 2013
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.*;
  4. import flash.events.*;
  5. import flash.external.*;
  6. import flash.system.*;
  7.  
  8. public class ZeroClipboard extends Sprite
  9. {
  10. private var button:Sprite;
  11. private var clipText:String = "";
  12.  
  13. public function ZeroClipboard()
  14. {
  15. stage.align = "TL";
  16. stage.scaleMode = "noScale";
  17. var _loc_1:* = LoaderInfo(this.root.loaderInfo).parameters;
  18. if (_loc_1.trustedDomain)
  19. {
  20. Security.allowDomain(_loc_1.trustedDomain.split("\\").join("\\\\"));
  21. }
  22. this.button = new Sprite();
  23. this.button.buttonMode = true;
  24. this.button.useHandCursor = false;
  25. this.button.graphics.beginFill(13434624);
  26. this.button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
  27. this.button.alpha = 0;
  28. addChild(this.button);
  29. this.button.addEventListener(MouseEvent.CLICK, this.mouseClick);
  30. this.button.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
  31. this.button.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
  32. this.button.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDown);
  33. this.button.addEventListener(MouseEvent.MOUSE_UP, this.mouseUp);
  34. ExternalInterface.addCallback("setHandCursor", this.setHandCursor);
  35. ExternalInterface.addCallback("setText", this.setText);
  36. ExternalInterface.addCallback("setSize", this.setSize);
  37. ExternalInterface.call("ZeroClipboard.dispatch", "load", this.metaData());
  38. return;
  39. }// end function
  40.  
  41. private function mouseClick(event:MouseEvent) : void
  42. {
  43. System.setClipboard(this.clipText);
  44. ExternalInterface.call("ZeroClipboard.dispatch", "complete", this.metaData(event, {text:this.clipText.split("\\").join("\\\\")}));
  45. this.clipText = "";
  46. return;
  47. }// end function
  48.  
  49. private function mouseOver(event:MouseEvent) : void
  50. {
  51. ExternalInterface.call("ZeroClipboard.dispatch", "mouseOver", this.metaData(event));
  52. return;
  53. }// end function
  54.  
  55. private function mouseOut(event:MouseEvent) : void
  56. {
  57. ExternalInterface.call("ZeroClipboard.dispatch", "mouseOut", this.metaData(event));
  58. return;
  59. }// end function
  60.  
  61. private function mouseDown(event:MouseEvent) : void
  62. {
  63. ExternalInterface.call("ZeroClipboard.dispatch", "mouseDown", this.metaData(event));
  64. if (!this.clipText)
  65. {
  66. ExternalInterface.call("ZeroClipboard.dispatch", "dataRequested", this.metaData(event));
  67. }
  68. return;
  69. }// end function
  70.  
  71. private function mouseUp(event:MouseEvent) : void
  72. {
  73. ExternalInterface.call("ZeroClipboard.dispatch", "mouseUp", this.metaData(event));
  74. return;
  75. }// end function
  76.  
  77. private function metaData(event:MouseEvent = , param2:Object = ) : Object
  78. {
  79. var _loc_4:String = null;
  80. var _loc_3:Object = {flashVersion:Capabilities.version};
  81. if (event)
  82. {
  83. _loc_3.altKey = event.altKey;
  84. _loc_3.ctrlKey = event.ctrlKey;
  85. _loc_3.shiftKey = event.shiftKey;
  86. }
  87. for (_loc_4 in param2)
  88. {
  89.  
  90. _loc_3[_loc_4] = param2[_loc_4];
  91. }
  92. return _loc_3;
  93. }// end function
  94.  
  95. public function setText(param1:String) : void
  96. {
  97. this.clipText = param1;
  98. return;
  99. }// end function
  100.  
  101. public function setHandCursor(param1:Boolean) : void
  102. {
  103. this.button.useHandCursor = param1;
  104. return;
  105. }// end function
  106.  
  107. public function setSize(param1:Number, param2:Number) : void
  108. {
  109. this.button.width = param1;
  110. this.button.height = param2;
  111. return;
  112. }// end function
  113.  
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement