Skip to main content
Inspiring
January 23, 2009
Answered

Pasting Text from Clipboard

  • January 23, 2009
  • 3 replies
  • 2402 views
I know there is a simple answer to this, but I cannot find it. The code I attached to this post yields a security error of the following nature:

SecurityError: Error #2179: The Clipboard.generalClipboard object may only be read while processing a flash.events.Event.PASTE event.

Thoughts anyone?
This topic has been closed for replies.
Correct answer brian_thomas2
Here is an explanation of how these restrictions work: User-initiated action requirements in Flash Player 10

3 replies

brian_thomas2
Adobe Employee
brian_thomas2Correct answer
Adobe Employee
January 26, 2009
Here is an explanation of how these restrictions work: User-initiated action requirements in Flash Player 10
Inspiring
January 26, 2009
Makes a whole lot of sense, especially from the security angle. I'm going to log a request for this to be officially evaluated. It should be expected, and certainly feasible without violating the security model, that when dealing with a text API that we should be able to work with clipboard contents. Perhaps consider restrictions that only allow text data into the component and rejecting binary data?

Expecting users to rely on keyboard shortcuts or context menus with my user base is kind of a mistake. It's simple enough for engineers but not so much for teachers. Yes, an oxymoron at its finest.

Adobe Employee
January 26, 2009
No. I do believe that clipboard access has to be specifically initiated via a user action.
Participating Frequently
January 24, 2009
Hi -

You don't say how your function is being called, but if it is being called independent of a flash.events.Event.PASTE event, you will get this error.

-Chris
Inspiring
January 26, 2009
It's being called as the event handler for button 'click' event. I understand that it will only execute within a paste event. My question is can I manually trigger a paste event? Does dispatchEvent("paste") work?

The objective is to have a paste toolbar icon. I've found in the past that much of our usage base doesn't have a strong grasp on the Ctrl+V / Cmd+V shortcut. Providing a visual button makes a lot of sense.