Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.*;
- import flash.events.*;
- import flash.external.*;
- import flash.system.*;
- public class ZeroClipboard extends Sprite
- {
- private var button:Sprite;
- private var clipText:String = "";
- public function ZeroClipboard()
- {
- stage.align = "TL";
- stage.scaleMode = "noScale";
- var _loc_1:* = LoaderInfo(this.root.loaderInfo).parameters;
- if (_loc_1.trustedDomain)
- {
- Security.allowDomain(_loc_1.trustedDomain.split("\\").join("\\\\"));
- }
- this.button = new Sprite();
- this.button.buttonMode = true;
- this.button.useHandCursor = false;
- this.button.graphics.beginFill(13434624);
- this.button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
- this.button.alpha = 0;
- addChild(this.button);
- this.button.addEventListener(MouseEvent.CLICK, this.mouseClick);
- this.button.addEventListener(MouseEvent.MOUSE_OVER, this.mouseOver);
- this.button.addEventListener(MouseEvent.MOUSE_OUT, this.mouseOut);
- this.button.addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDown);
- this.button.addEventListener(MouseEvent.MOUSE_UP, this.mouseUp);
- ExternalInterface.addCallback("setHandCursor", this.setHandCursor);
- ExternalInterface.addCallback("setText", this.setText);
- ExternalInterface.addCallback("setSize", this.setSize);
- ExternalInterface.call("ZeroClipboard.dispatch", "load", this.metaData());
- return;
- }// end function
- private function mouseClick(event:MouseEvent) : void
- {
- System.setClipboard(this.clipText);
- ExternalInterface.call("ZeroClipboard.dispatch", "complete", this.metaData(event, {text:this.clipText.split("\\").join("\\\\")}));
- this.clipText = "";
- return;
- }// end function
- private function mouseOver(event:MouseEvent) : void
- {
- ExternalInterface.call("ZeroClipboard.dispatch", "mouseOver", this.metaData(event));
- return;
- }// end function
- private function mouseOut(event:MouseEvent) : void
- {
- ExternalInterface.call("ZeroClipboard.dispatch", "mouseOut", this.metaData(event));
- return;
- }// end function
- private function mouseDown(event:MouseEvent) : void
- {
- ExternalInterface.call("ZeroClipboard.dispatch", "mouseDown", this.metaData(event));
- if (!this.clipText)
- {
- ExternalInterface.call("ZeroClipboard.dispatch", "dataRequested", this.metaData(event));
- }
- return;
- }// end function
- private function mouseUp(event:MouseEvent) : void
- {
- ExternalInterface.call("ZeroClipboard.dispatch", "mouseUp", this.metaData(event));
- return;
- }// end function
- private function metaData(event:MouseEvent = , param2:Object = ) : Object
- {
- var _loc_4:String = null;
- var _loc_3:Object = {flashVersion:Capabilities.version};
- if (event)
- {
- _loc_3.altKey = event.altKey;
- _loc_3.ctrlKey = event.ctrlKey;
- _loc_3.shiftKey = event.shiftKey;
- }
- for (_loc_4 in param2)
- {
- _loc_3[_loc_4] = param2[_loc_4];
- }
- return _loc_3;
- }// end function
- public function setText(param1:String) : void
- {
- this.clipText = param1;
- return;
- }// end function
- public function setHandCursor(param1:Boolean) : void
- {
- this.button.useHandCursor = param1;
- return;
- }// end function
- public function setSize(param1:Number, param2:Number) : void
- {
- this.button.width = param1;
- this.button.height = param2;
- return;
- }// end function
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement