System.setClipboard()事件处理中事件、System、setClipboard

2023-09-08 14:02:29 作者:心事痕迹

在完成沿线的东西的好方法有什么想法

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);
});

在ActionScript 3?

in actionscript 3?

看起来好像System.setClipboard()不可用在事件处理中(这使得至少有一些道理给我所知道的关于Flash的安全性)。

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).

有没有什么办法:

在得到它的工作? 或块的URL负载,这样我就可以调用setClipboard()中的主要事件流?

推荐答案

唯一的办法是表现出一定的警示(或其他UI)给用户并等待点击:

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);
}