Skip to main content
Participating Frequently
October 29, 2009
Question

TextClipboard.getContents only works on AIR

  • October 29, 2009
  • 1 reply
  • 471 views

I have got two projects based on one library project, one is an AIR application, the other one is a Web application,  when I tried to access System Clipboard using TextClipboard.getContents(),  AIR version works fine, but web version got:

SecurityError: Error #2179: The Clipboard.generalClipboard object may only be read while processing a flash.events.Event.PASTE event.
     at flash.desktop::Clipboard/getObjectReference()
     at flash.desktop::Clipboard/convertNativeFormat()
     at flash.desktop::Clipboard/getOriginal()
     at flash.desktop::Clipboard/getData()
     at flashx.textLayout.edit::TextClipboard$/http://ns.adobe.com/textLayout/internal/2008::getTextOnClipboardForFormat()
     at flashx.textLayout.edit::TextClipboard$/getContents()
     ...

I have used TextClipboard.setContents()  to write the System Clipboard, works perfectly fine on both versions.  Just wondering if this is how TextClipboard suppose to work? any suggested work around for this?  Thanks in advance.

This topic has been closed for replies.

1 reply

Adobe Employee
October 29, 2009

The browser-based Flash Player has security issues to contend with to prevent unauthorized access of the clipboard. Clipboard access does work, but must be initiated by the user, for instance by choosing Paste from the browser menu, or from the context menu. Unauthorized access results in an exception being thrown; I'm not sure of wording of the exception, but I believe it references a security violation.

On AIR, since AIR applications are trusted, they have complete access to the clipboard whenever they want it. So in AIR its not an issue.

- robin