天天看點

在Flex中複制文字到作業系統的剪貼闆

 這個執行個體示範了怎麼樣使用System.setClipboard()靜态方法,從一個Flex application中複制文字到作業系統的剪貼闆。

随便在RichTextEditor打些字,然後點選Copy text to clipboard 按鈕就複制到剪貼闆了,之後就找個能打文本的地方試試吧

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

 layout="vertical"

 verticalAlign="middle"

 backgroundColor="white">

 <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="The quick brown fox jumped over the lazy dog."

 width="100%"

 height="160" />

 <mx:ApplicationControlBar dock="true">

 <mx:Button id="button"

 label="Copy text to clipboard"

 toolTip="Click here to copy the contents of the RichTextEditor control to the OS clipboard."

 click="button_click();" />

 </mx:ApplicationControlBar>

</mx:Application>

    本文轉自 OldHawk  部落格園部落格,原文連結:http://www.cnblogs.com/taobataoma/archive/2008/06/13/1219494.html,如需轉載請自行聯系原作者

繼續閱讀