PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/clippy.hx

http://github.com/in-src/clippy
Haxe | 72 lines | 55 code | 15 blank | 2 comment | 0 complexity | 1cc3636b2ad4c49f64df0470ae700f8a MD5 | raw file
Possible License(s): MIT
  1. import flash.display.MovieClip;
  2. import flash.display.Sprite;
  3. import flash.events.MouseEvent;
  4. import flash.display.SimpleButton;
  5. import flash.text.TextField;
  6. import flash.text.TextFieldAutoSize;
  7. import flash.text.TextFormat;
  8. import flash.external.ExternalInterface;
  9. import Std;
  10. class ButtonUp extends MovieClip {}
  11. class ButtonOver extends MovieClip {}
  12. class ButtonDown extends MovieClip {}
  13. class Clippy {
  14. static var text:String;
  15. static var func:String;
  16. static var label:Sprite;
  17. static var id:String = '';
  18. /* static var label:TextField;*/
  19. static function log (l) {
  20. ExternalInterface.call("(console.log('"+l+"'))");
  21. }
  22. static function upFunction (e:MouseEvent) {
  23. flash.system.System.setClipboard(text);
  24. ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseUp', null );
  25. ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'complete', text );
  26. }
  27. public static function setClip() {
  28. flash.system.System.setClipboard(text);
  29. }
  30. static function overFunction (e:MouseEvent) {
  31. ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseOver', null );
  32. }
  33. static function outFunction(e:MouseEvent) {
  34. ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseOut', null );
  35. }
  36. // Main
  37. static function main() {
  38. flash.system.Security.allowDomain("*");
  39. text = flash.Lib.current.loaderInfo.parameters.text;
  40. func = flash.Lib.current.loaderInfo.parameters.func;
  41. var width:Float = Std.parseFloat(flash.Lib.current.loaderInfo.parameters.width) * 2 + 150;
  42. var height:Float = Std.parseFloat(flash.Lib.current.loaderInfo.parameters.height) * 2 ;
  43. id = flash.Lib.current.loaderInfo.parameters.id;
  44. label = new Sprite();
  45. label.buttonMode = true;
  46. label.x = 0;
  47. label.y = 0;
  48. label.useHandCursor = true;
  49. label.graphics.beginFill(0xCCFF00);
  50. label.graphics.drawRect(0, 0, Math.floor(width), Math.floor(height));
  51. label.alpha = 0.0;
  52. flash.Lib.current.addChild(label);
  53. label.addEventListener(MouseEvent.MOUSE_UP, upFunction );
  54. label.addEventListener(MouseEvent.MOUSE_OVER, overFunction);
  55. label.addEventListener(MouseEvent.MOUSE_OUT, outFunction);
  56. }
  57. }