Flex中如何利用System.setClipboard()函数复制Flex应用程序中的文本到系统粘贴版上的例子

By Minidxer | March 13, 2009

接下来的例子演示了Flex中如何利用System.setClipboard()函数,复制Flex应用程序中的文本到系统粘贴版上。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:Script>
  8.         <![CDATA[
  9.             import mx.controls.Alert;
  10.  
  11.             private function button_click():void {
  12.                 System.setClipboard(richTextEditor.text);
  13.                 Alert.show("Done");
  14.             }
  15.         ]]>
  16.     </mx:Script>
  17.  
  18.     <mx:ApplicationControlBar dock="true">
  19.         <mx:Button id="button"
  20.                 label="Copy text to clipboard"
  21.                 toolTip="Click here to copy the contents of the RichTextEditor control to the OS clipboard."
  22.                 click="button_click();" />
  23.     </mx:ApplicationControlBar>
  24.  
  25.     <mx:RichTextEditor id="richTextEditor"
  26.             text="The quick brown fox jumped over the lazy dog."
  27.             width="100%"
  28.             height="100%" /> 
  29.  
  30. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Other | 3 Comments » | Tags: ,

你可能还对下列文章感兴趣:

3 comments | Add One

  1. 刚 - 03/13/2009 at 10:33 am

    例子贴错了~~

  2. Minidxer - 03/13/2009 at 11:02 am

    呃,果然。。。贴错目录了
    谢谢哈

  3. 雪深 - 03/13/2009 at 11:42 pm

    路过 观望一下强人

Leave a Comment

Name(*):

E-Mail(*) :

Website :

Comments :

Search Posts