使用按钮从剪贴板粘贴文本 [英] Paste text from Clipboard using button

查看:302
本文介绍了使用按钮从剪贴板粘贴文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有控制栏按钮复制,剪切和粘贴,他们假设复制/粘贴一些文本/对象到剪贴板。



复制/剪切工作正常。
粘贴使用CTRL + V和上下文菜单工作正常。

但是当我试图通过控制栏按钮访问剪贴板点击处理程序它会引发错误

  SecurityError:错误#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()
... 2 more

我知道这是安全问题。
$ b


方法
Clipboard.generalClipboard.getData()
可用于读取
的内容系统剪贴板,但只有当它的
从事件处理程序
中处理一个flash.events.Event.PASTE
事件。




但是我必须执行粘贴控制栏按钮。为了克服Flash Player的这个安全限制,你可以模拟系统剪贴板的功能,用Flash这样的本地共享对象首先在这里建议 http ://joeberkovitz.com/blog/2008/12/12/clipboard-using-local-shared-objects/ 或通过ExternalInterface使用JavaScript API从剪贴板中检索数据。


I have control bar buttons Copy, Cut, and Paste and they suppose to copy/paste some text/objects from and to clipboard.

Copy/Cut works fine. Paste using CTRL+V and context menu works fine as well.

But when I'm trying to access Clipboard via control bar button click handler it throws error

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()
... 2 more

I know that this is security issue.

Method Clipboard.generalClipboard.getData() may be used to read the contents of the system Clipboard, but only when it is called from within an event handler processing a flash.events.Event.PASTE event.

But I have to implement paste control bar button. Had do I do that?

解决方案

To overcome this security limitation imposed by Flash Player you can either simulate the functionality of system clipboard with Flash Local shared objects like it was first suggested here http://joeberkovitz.com/blog/2008/12/12/clipboard-using-local-shared-objects/ or use Javascript API via ExternalInterface to retrieve the data from the Clipboard.

这篇关于使用按钮从剪贴板粘贴文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆