diff --git a/README.md b/README.md index aefb2bc..13fddcf 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,18 @@ SWF, run the following from Clippy's root directory: If that is successful, copy `build/clippy.swf` to your `public` directory or wherever your static assets can be found. +Options +------- + +Clippy options can be specified using the `FlashVars` parameter; the currently +supported options are: + +* `text`: the text which will be copied to the user clipboard +* `func`: a JavaScript callback that will be called after every copy operation +* `label`: the message displayed next to the clipboard icon (default `copy to clipboard`) +* `feedback`: the message displayed after a copy operation (default `copied!`) + + Contribute ---------- diff --git a/build/clippy.swf b/build/clippy.swf index a01857f..23b28bc 100644 Binary files a/build/clippy.swf and b/build/clippy.swf differ diff --git a/clippy.hx b/clippy.hx index 325d05e..b892140 100644 --- a/clippy.hx +++ b/clippy.hx @@ -6,9 +6,16 @@ import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import flash.external.ExternalInterface; +class ButtonUp extends MovieClip {} +class ButtonOver extends MovieClip {} +class ButtonDown extends MovieClip {} + class Clippy { + static var text:String; static var func:String; + static var defaultLabelText:String; + static var feedbackLabelText:String; static var label:TextField; static var button:SimpleButton; static var format:TextFormat; @@ -16,12 +23,12 @@ class Clippy { static function upFunction (e:MouseEvent) { if(ExternalInterface.available) { ExternalInterface.marshallExceptions = true; - if(func != '') { + if(func != '' && func != null) { text = ExternalInterface.call(func); } } flash.system.System.setClipboard(text); - label.text = "copied!"; + label.text = feedbackLabelText; label.setTextFormat(format); } @@ -31,7 +38,7 @@ class Clippy { static function outFunction(e:MouseEvent) { label.textColor = 0x888888; - label.text = "copy to clipboard"; + label.text = defaultLabelText; label.setTextFormat(format); } @@ -39,13 +46,24 @@ class Clippy { static function main() { text = flash.Lib.current.loaderInfo.parameters.text; func = flash.Lib.current.loaderInfo.parameters.func; + defaultLabelText = flash.Lib.current.loaderInfo.parameters.label; + feedbackLabelText = flash.Lib.current.loaderInfo.parameters.feedback; + + if(defaultLabelText == null) + { + defaultLabelText = "copy to clipboard"; + } + if(feedbackLabelText == null) + { + feedbackLabelText = "copied!"; + } // label label = new TextField(); format = new TextFormat("Arial", 11); - label.text = "copy to clipboard"; + label.text = defaultLabelText; label.setTextFormat(format); label.textColor = 0x888888; label.selectable = false; @@ -56,10 +74,11 @@ class Clippy { // button button = new SimpleButton(); button.useHandCursor = true; - button.upState = flash.Lib.attach("button_up"); - button.overState = flash.Lib.attach("button_over"); - button.downState = flash.Lib.attach("button_down"); - button.hitTestState = flash.Lib.attach("button_down"); + + button.upState = new ButtonUp(); + button.overState = new ButtonOver(); + button.downState = new ButtonDown(); + button.hitTestState = new ButtonDown(); label.addEventListener(MouseEvent.MOUSE_UP, upFunction ); button.addEventListener(MouseEvent.MOUSE_UP, upFunction ); diff --git a/compile.hxml b/compile.hxml index a1a65e7..c78d67b 100644 --- a/compile.hxml +++ b/compile.hxml @@ -1,7 +1,8 @@ +-cp . -swf build/clippy.swf -swf-version 9 -swf-lib library.swf -main Clippy -swf-header 110:14:0 --flash-use-stage ---flash-strict \ No newline at end of file +--flash-strict diff --git a/library.swf b/library.swf index d997188..50ee05d 100644 Binary files a/library.swf and b/library.swf differ diff --git a/library.xml b/library.xml index 467f1b1..9425c00 100644 --- a/library.xml +++ b/library.xml @@ -1,10 +1,10 @@ - + - - - + + +