annotate plugins/redmine_checkout/assets/images/ZeroClipboard.as @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents b4b72f1eb644
children
rev   line source
Chris@16 1 package {
Chris@16 2 // Simple Set Clipboard System
Chris@16 3 // Author: Joseph Huckaby
Chris@16 4
Chris@16 5 import flash.display.Stage;
Chris@16 6 import flash.display.Sprite;
Chris@16 7 import flash.display.LoaderInfo;
Chris@16 8 import flash.display.StageScaleMode;
Chris@16 9 import flash.events.*;
Chris@16 10 import flash.display.StageAlign;
Chris@16 11 import flash.display.StageScaleMode;
Chris@16 12 import flash.external.ExternalInterface;
Chris@16 13 import flash.system.Security;
Chris@16 14 import flash.utils.*;
Chris@16 15 import flash.system.System;
Chris@16 16
Chris@16 17 public class ZeroClipboard extends Sprite {
Chris@16 18
Chris@16 19 private var id:String = '';
Chris@16 20 private var button:Sprite;
Chris@16 21 private var clipText:String = '';
Chris@16 22
Chris@16 23 public function ZeroClipboard() {
Chris@16 24 // constructor, setup event listeners and external interfaces
Chris@16 25 stage.scaleMode = StageScaleMode.EXACT_FIT;
Chris@16 26 flash.system.Security.allowDomain("*");
Chris@16 27
Chris@16 28 // import flashvars
Chris@16 29 var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters;
Chris@16 30 id = flashvars.id;
Chris@16 31
Chris@16 32 // invisible button covers entire stage
Chris@16 33 button = new Sprite();
Chris@16 34 button.buttonMode = true;
Chris@16 35 button.useHandCursor = true;
Chris@16 36 button.graphics.beginFill(0xCCFF00);
Chris@16 37 button.graphics.drawRect(0, 0, Math.floor(flashvars.width), Math.floor(flashvars.height));
Chris@16 38 button.alpha = 0.0;
Chris@16 39 addChild(button);
Chris@16 40 button.addEventListener(MouseEvent.CLICK, clickHandler);
Chris@16 41
Chris@16 42 button.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event) {
Chris@16 43 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseOver', null );
Chris@16 44 } );
Chris@16 45 button.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event) {
Chris@16 46 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseOut', null );
Chris@16 47 } );
Chris@16 48 button.addEventListener(MouseEvent.MOUSE_DOWN, function(event:Event) {
Chris@16 49 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseDown', null );
Chris@16 50 } );
Chris@16 51 button.addEventListener(MouseEvent.MOUSE_UP, function(event:Event) {
Chris@16 52 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'mouseUp', null );
Chris@16 53 } );
Chris@16 54
Chris@16 55 // external functions
Chris@16 56 ExternalInterface.addCallback("setHandCursor", setHandCursor);
Chris@16 57 ExternalInterface.addCallback("setText", setText);
Chris@16 58
Chris@16 59 // signal to the browser that we are ready
Chris@16 60 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'load', null );
Chris@16 61 }
Chris@16 62
Chris@16 63 public function setText(newText) {
Chris@16 64 // set the maximum number of files allowed
Chris@16 65 clipText = newText;
Chris@16 66 }
Chris@16 67
Chris@16 68 public function setHandCursor(enabled:Boolean) {
Chris@16 69 // control whether the hand cursor is shown on rollover (true)
Chris@16 70 // or the default arrow cursor (false)
Chris@16 71 button.useHandCursor = enabled;
Chris@16 72 }
Chris@16 73
Chris@16 74 private function clickHandler(event:Event):void {
Chris@16 75 // user click copies text to clipboard
Chris@16 76 // as of flash player 10, this MUST happen from an in-movie flash click event
Chris@16 77 System.setClipboard( clipText );
Chris@16 78 ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'complete', clipText );
Chris@16 79 }
Chris@16 80 }
Chris@16 81 }