Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------

Expand Down
Binary file modified build/clippy.swf
Binary file not shown.
35 changes: 27 additions & 8 deletions clippy.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,29 @@ 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;

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);
}

Expand All @@ -31,21 +38,32 @@ class Clippy {

static function outFunction(e:MouseEvent) {
label.textColor = 0x888888;
label.text = "copy to clipboard";
label.text = defaultLabelText;
label.setTextFormat(format);
}

// Main
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;
Expand All @@ -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 );
Expand Down
3 changes: 2 additions & 1 deletion compile.hxml
Original file line number Diff line number Diff line change
@@ -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
--flash-strict
Binary file modified library.swf
Binary file not shown.
8 changes: 4 additions & 4 deletions library.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<movie version="8" width="14" height="14" framerate="0">
<movie version="9" width="14" height="14" framerate="0" frames="1" as3="1">
<frame>
<library>
<clip id="button_up" import="assets/button_up.png"/>
<clip id="button_over" import="assets/button_over.png"/>
<clip id="button_down" import="assets/button_down.png"/>
<clip id="ButtonUp" import="assets/button_up.png"/>
<clip id="ButtonOver" import="assets/button_over.png"/>
<clip id="ButtonDown" import="assets/button_down.png"/>
</library>
</frame>
</movie>