Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Feb 13, 2009
0 parents commit c6f7e39
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2008 Tom Preston-Werner

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
83 changes: 83 additions & 0 deletions README.md
@@ -0,0 +1,83 @@
Clippy - Helping you copy text to your clipboard
================================================

Clippy is a very simple Flash widget that makes it possible to place arbitrary
text onto the client's clipboard. Here is what Clippy looks like on GitHub:

![Clippy in action](http://img.skitch.com/20090213-cjiawnwig8udf5a6qf1c45cne8.png)

Here is a sample Rails (Ruby) helper that can be used to place Clippy on a
page:

def clippy(text, bgcolor='#FFFFFF')
html = <<-EOF
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="14"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=#{text}">
<param name="bgcolor" value="#{bgcolor}">
<embed src="/flash/clippy.swf"
width="110"
height="14"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="text=#{text}"
bgcolor="#{bgcolor}"
/>
</object>
EOF
end

Installation (Pre-Built SWF)
---------------------------

If you want to use Clippy unmodified, just copy `build/clippy.swf` to your
`public` directory or wherever your static assets can be found.

Installation (Compiling)
------------------------

In order to compile Clippy from source, you need to install the following:

* [haXe](http://haxe.org/)
* [swfmill](http://swfmill.org/)

The haXe code is in `clippy.hx`, the button images are in `assets`, and the
compiler config is in `compile.hxml`. Make sure you look at all of these to
see where and what you'll need to modify. To compile everything into a final
SWF, run the following from Clippy's root directory:

swfmill simple library.xml library.swf && haxe compile.hxml

If that is successful, copy `build/clippy.swf` to your
`public` directory or wherever your static assets can be found.

Contribute
----------

If you'd like to hack on Clippy, start by forking my repo on GitHub:

http://github.com/mojombo/clippy

The best way to get your changes merged back into core is as follows:

# Clone down your fork
# Create a topic branch to contain your change
# Hack away
# If you are adding new functionality, document it in README.md
# If necessary, rebase your commits into logical chunks, without errors
# Push the branch up to GitHub
# Send me (mojombo) a pull request for your branch

License
-------

MIT License (see LICENSE file)
Binary file added assets/button_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/button_over.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/button_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/clippy.swf
Binary file not shown.
54 changes: 54 additions & 0 deletions clippy.hx
@@ -0,0 +1,54 @@
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

class Clippy {
// Main
static function main() {
var text:String = flash.Lib.current.loaderInfo.parameters.text;

// label

var label:TextField = new TextField();
var format:TextFormat = new TextFormat("Arial", 10);

label.text = "copy to clipboard";
label.setTextFormat(format);
label.textColor = 0x888888;
label.selectable = false;
label.x = 15;
label.visible = false;

flash.Lib.current.addChild(label);

// button

var button:SimpleButton = 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.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent) {
flash.system.System.setClipboard(text);
label.text = "copied!";
label.setTextFormat(format);
});

button.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent) {
label.visible = true;
});

button.addEventListener(MouseEvent.MOUSE_OUT, function(e:MouseEvent) {
label.visible = false;
label.text = "copy to clipboard";
label.setTextFormat(format);
});

flash.Lib.current.addChild(button);
}
}
7 changes: 7 additions & 0 deletions compile.hxml
@@ -0,0 +1,7 @@
-swf build/clippy.swf
-swf-version 9
-swf-lib library.swf
-main Clippy
-swf-header 110:14:0
--flash-use-stage
--flash-strict
Binary file added library.swf
Binary file not shown.
10 changes: 10 additions & 0 deletions library.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<movie version="8" width="14" height="14" framerate="0">
<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"/>
</library>
</frame>
</movie>

0 comments on commit c6f7e39

Please sign in to comment.