开发者

System.setClipboard in event initiated by user click

I'm new to flash so my question may be stupid.

I unserstand security restrictions about working with clipboard. The user must do an action then clipboard may be written.

But what if on mouseclick i have to load some text from server using URLRequest and copy obtained data to clipboard?

Like this:

    protected function clickHandler(e:MouseEvent):void
    {
       this.fileReference = new FileReference();
       this.fileReference.addEventListener(Event.SELECT, this.fileSelectHandler);       
       this.fileReference.browse();
    }       

    protected function fileSelectHandler(e:Event):void
    {
       var request:URLRequest = new URLRequest(this.url);
       this.urlLoader = new URLLoader();
       urlLoader.addEventListener(Event.COMPLETE, this.completeHandler);
       urlLoader.load(request);
    }

    protected function generateLinkCompleteHandler(e:Event):void
    {
       System.setClipboard(this.urlloader.data);            

}

Maybe somehow it is possible to "pass" the "safe context" to further events? or it's another way t开发者_运维问答o do this?

thanks!


What's wrong with two clicks: one to fetch the data and when that's loaded, show a button that will copy to clipboard when clicked?


Thanks to sydd who answered my question in comments. I'll copy the link provided by him here System.setClipboard() inside event handler if he consider to write it as an answer i'll reaccept.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜