3

I have a requirement that we should be able to copy an image displayed in our application, to Clipboard and paste it outside (Like on Excel).

I was trying the below code snippet (Inside a button Click).

Clipboard.generalClipboard.clear(); var dataLoaded:Boolean = Clipboard.generalClipboard.setData(ClipboardFormats.RICH_TEXT_FORMAT, byteArray, false);

The dataLoaded object is true, however it does not paste anything when tried on Excel or MsPaint.

Do we have any way to achieve this?

Thanks.

Himanshu
  • 43
  • 7

1 Answers1

0

The code you are showing is not enough in itself to get a successful transfer. Like many other operations within the security sandbox of a FP app (web) this code can only respond to a direct user interaction. So your code without any valid context cannot work of course but if called within a mouse down listener for example (a true user generated mouse event, creating a fake mouseevent would still not work) it should respond correctly:

private function handleMouseClick(event:MouseEvent):void
{
    Clipboard.generalClipboard.clear(); 
    var dataLoaded:Boolean = Clipboard.generalClipboard.setData(ClipboardFormats.RICH_TEXT_FORMAT, byteArray, false);
}
BotMaster
  • 2,233
  • 1
  • 13
  • 16