ILya
ILya

Reputation: 2778

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 to do this?

thanks!

Upvotes: 1

Views: 389

Answers (2)

ILya
ILya

Reputation: 2778

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.

Upvotes: 0

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?

Upvotes: 1

Related Questions