事件处理程序内的 System.setClipboard()

发布于 2024-09-13 02:40:58 字数 457 浏览 13 评论 0原文

有什么好的方法可以完成类似于

var request:URLRequest = new URLRequest("http://myurl.com");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(event:Event):void {
 System.setClipboard(loader.data);
});

ActionScript 3 的事情吗?

似乎 System.setClipboard() 在事件处理程序中不可用(鉴于我对 Flash 安全性的了解,这至少有一定意义)。

有什么办法可以:

  • 让它发挥作用吗?
  • 或者阻止 URL 加载,以便我可以在主事件流中调用 setClipboard()?

Any thoughts on a good way to accomplish something along the lines of

var request:URLRequest = new URLRequest("http://myurl.com");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(event:Event):void {
 System.setClipboard(loader.data);
});

in actionscript 3?

It seems as if System.setClipboard() isn't available inside an event handler (which makes at least some sense given what I know about Flash security).

Is there any way to:

  • get it to work?
  • or block on the URL load so that I can then call setClipboard() in the main event flow?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧时模样 2024-09-20 02:40:58

唯一的解决方案是向用户显示一些警报(或其他 UI)并等待点击:

function completeHandler(event:Event):void
{
    Alert.show("Click OK to copy text to clipboard", "Alert",
        Alert.OK | Alert.CANCEL, this,
        callback, null, Alert.OK);
}

function callback(event:CloseEvent):void 
{
    // Check to see if the OK button was pressed.
    if (event.detail == Alert.OK)
        System.setClipboard(loader.data);
}

The only solution is to show some alert (or other UI) to the user and wait for a click:

function completeHandler(event:Event):void
{
    Alert.show("Click OK to copy text to clipboard", "Alert",
        Alert.OK | Alert.CANCEL, this,
        callback, null, Alert.OK);
}

function callback(event:CloseEvent):void 
{
    // Check to see if the OK button was pressed.
    if (event.detail == Alert.OK)
        System.setClipboard(loader.data);
}
半岛未凉 2024-09-20 02:40:58

对于空气使用

Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT,"some Text value to clipboard");

For AIR use

Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT,"some Text value to clipboard");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文