Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create a PASTE event.

Guest
Oct 16, 2009 Oct 16, 2009

Flash says I can only use the Clipboard.getData only in a PASTE event. (CS4 & AS3)

But I don't know how to make a paste event? Can someone help me out?

TOPICS
ActionScript
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 16, 2009 Oct 16, 2009

Use

System.setClipboard( strToCopy )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 16, 2009 Oct 16, 2009

I want to access the clipboard to get the text out of it. I can already do it in AIR but to do it in a swf it needs to happen in a paste event.

But I don't know how to make a PASTE event..

function onPasteMessage(event:Event) {
    trace("lol");
}
myTextField.text = "LOL";
myTextField.addEventListener(Event.PASTE, onPasteMessage);

I tried that code with an textfield called myTextField on the stage, but when I rightclick and select Paste nothing happens.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 17, 2009 Oct 17, 2009
LATEST

First make sure that type of the tet field is "input". Programmatically is can be done:

myTextField.type = TextFieldType.INPUT;

Once it is done - it will show OS context menu (Copy, Paste, etc.)

According to documentation TextField doesn't dispatch Event.PASTE. Read this:

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/events/Event.html#PASTE

If you want to detect changes in the TextField you may want to listen to Event.CHANGE.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 17, 2009 Oct 17, 2009

No one kows this? Because Flash says I can only do it within a PASTE event, so there should be a way to make a paste event right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 17, 2009 Oct 17, 2009

I'd see it as a security breach if any app on the interwebs could read my clipboard without me going Ctrl/Cmd-V...

No tellin' what's on the clipboard: passwords, CC numbers etc.

In other words, I would not be surprised if it was not possible.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 17, 2009 Oct 17, 2009

Yeah but read this:http://drawlogic.com/2008/09/28/flas...save-and-load/

It says: the new ActionScript 3.0 method Clipboard.generalClipboard.getData() may be used to read the contents of the system Clipboard, but only when it is called from within an event handler processing a flash.events.Event.PASTE event.

And even Flash itself says: you can only do this within a Paste event.. so it IS possible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 17, 2009 Oct 17, 2009

I've not tested it, but I suppose it is only possible when processing a PASTE event like the docs say. You cannot 'create' such an event. The user must explicitly do so by Ctrl-V or whatever.

Just like an ordinary KeyboardEvent. You cannot generate it by code, the user must press a key. You can call an eventhandler meant to handle keyboard event, but there won't be an actual KeyboardEvent in that case.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 17, 2009 Oct 17, 2009

So how am I going to do that? I've already put an PASTE event handler on a textfield but if I rechtclick > paste or ctrl+v it doesn't work.Help me please.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines