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

ActionScript 3 paste image from clipboard

New Here ,
Jun 06, 2013 Jun 06, 2013

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.

TOPICS
ActionScript
1.6K
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
Guru ,
Jun 09, 2013 Jun 09, 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.

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
New Here ,
Jun 10, 2013 Jun 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.

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
Guru ,
Jun 10, 2013 Jun 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.

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
New Here ,
Jun 10, 2013 Jun 10, 2013
LATEST

I woudn't call it a 'hack' as long as Flash should have access to clipboard on the following restrictions:

1) The image should be already in clipboard

2) The data should be only available on paste handler (as you mentioned).

So I wonder why doesn't it work with Flash Player?

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