Preview mode: Common | Row form

How to copy texts to clipboard in Flex application

The following example demonstrate how to use System.setClipboard() method,  copy texts to the OS clipboard from Flex application.
 
// mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
 layout="vertical">

 <mx:Script>
 <![CDATA[
 import mx.controls.Alert;

 private function button_click():void {
 System.setClipboard(richTextEditor.text);
 Alert.show("Done");
 }
 ]]>
 </mx:Script>
 <mx:RichTextEditor id="richTextEditor"
 text="Your Text."
 width="100%"
 height="200" />

 <mx:ApplicationControlBar dock="true">
 <mx:Button id="button"
 label="Copy to clipboard"
 toolTip="Click here to copy the contents to the OS clipboard."
 click="button_click();" />
 </mx:ApplicationControlBar>

</mx:Application>
 

Tags: Flex clipboard texts

Categorize:Flex | Link | Comment: 0 | Read times: 40