Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to change also the text of the label and the "copied" text #6

Open
lmammino opened this issue Oct 23, 2010 · 6 comments
Open

Comments

@lmammino
Copy link

To apply internationalization to clippy it would be really good to have the possibility to edit also the text of the label and the "copied" text...
The following implementation probably will work:

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;
    var labelText:String = flash.Lib.current.loaderInfo.parameters.labelText;
var copiedText:String = flash.Lib.current.loaderInfo.parameters.copiedText;

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

    label.text = labelText;
    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 = copiedText;
      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 = labelText;
      label.setTextFormat(format);
    });

    flash.Lib.current.addChild(button);
  }
}
@johannesnagl
Copy link

+1

3 similar comments
@nicolasiensen
Copy link

+1

@stjernstrom
Copy link

+1

@incubus
Copy link

incubus commented Dec 6, 2011

+1

@simonc
Copy link

simonc commented Jan 21, 2012

🆙

@ghepting
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants