Skip to main content
Participant
June 6, 2013
Question

ActionScript 3 paste image from clipboard

  • June 6, 2013
  • 1 reply
  • 1676 views

Is it possible to paste image from clipboard using ActionScript 3 and Flash Player 11?

Need web solution only, not AIR.

Use case:

- User opens image some in some native image editor.

- Selects part of image and clicks Ctrl+C (Command+C on Mac). Now part of image is in clipboard.

- User open web application that is running in Flash Player

- User inputs image by clicking Ctrl+V (Command+V on Mac) or using context Menu->Paste.

I browsed the docs for Clipboard at: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html

The only format that seems reasonable would be Clipboard.getData(BITMAP_FORMAT) on paste events. This seems to be supported by AIR only.

Are there any ways to implement the given use case with Flash Player?

Thanks!

P.S.: There is some support of paste events in HTML in Chrome and Firefox, but Internet Explorer 10 and Apple Saffari 6 seems still have issues with pure-HTML approach.

--

Cheers,

Ignat.

This topic has been closed for replies.

1 reply

Inspiring
June 10, 2013

This seems to be supported by AIR only.

What gives you the impression?

AIR-only functions are marked with a fancy AIR logo

(like the first one in this list: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/images/sprite-index.png )

and getData doesn`t have it, so it should work without problems in the "normal" Flash Player if you follow the recepy:

Note for Flash Player applications: In Flash Player 10, a paste operation from the clipboard first requires a user event (such as a keyboard shortcut for the Paste command or a mouse click on the Paste command in a context menu). Clipboard.getData() will return the contents of the clipboard only if the InteractiveObject has received and is acting on a paste event. Calling Clipboard.getData() under any other circumstances will be unsuccessful.

Participant
June 10, 2013

Thanks for your reply.

These user events is exactly I'm working on. Can I receive an image data on paste events in Flash Player?

I managed to receive only text data.

I wonder if ActionScript has support for image objects?

--

Cheers, Ignat.

Inspiring
June 10, 2013

Sorry, i didn`t see this restriciton, makes sense, otherwise a flash hack could easily transfer a screenshot of your desktop to a server. So no way around that I guess.