Skip to main content
Participant
March 2, 2009
Question

getClipboardContents

  • March 2, 2009
  • 3 replies
  • 933 views
I use next code:
public function doPaste():void
{
var ts:TextScrap = SelectionManager(_textFlow.interactionManager).getClipboardContents();
SelectionManager(_textFlow.interactionManager).pasteTextScrap(ts);
}

and i got security error:
SecurityError: Error #2179: Объект Clipboard.generalClipboard может считываться только при обработке события flash.events.Event.PASTE.
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/get textScrap()
at flashx.textLayout.edit::SelectionManager/getClipboardContents()
Sorry, it is russian

any ideas?
This topic has been closed for replies.

3 replies

AcidlexAuthor
Participant
March 3, 2009
ok.
So I can set clipboard, but cant read. Becouse next code works.
public function doCopy():void
{
var sm:SelectionManager= new SelectionManager();
var ts:TextScrap = SelectionManager(_textFlow.interactionManager).createTextScrap();
SelectionManager(_textFlow.interactionManager).setClipboardContents(ts);
}

My task is a buttons with copy, cut, paste fucntions. Everything works except paste. :(

I used this resource as example http://livedocs.adobe.com/flex/gumbo/langref/flashx/textLayout/edit/SelectionManager.html
there is an example of copy and paste operations.
brian_thomas2
Adobe Employee
Adobe Employee
March 2, 2009
For security reasons clipboard interaction must be performed within a user initiated copy/paste event, otherwise you will see this error.

See User-initiated action requirements in Flash Player 10 for an explanations of the security requirements.
March 2, 2009
I'm fairly certain that this is because you can only read the system clipboard while handling an Event.PASTE event, which is an event that is built into the flash player. This is a fairly basic security restriction with Flash Player 10.

There is some more info on it here: http://www.adobe.com/devnet/flashplayer/articles/fplayer10_uia_requirements.html