六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 49|回复: 0

将Flex中的文字复制到操作系统的剪贴板

[复制链接]

升级  2%

11

主题

11

主题

11

主题

秀才

Rank: 2

积分
53
 楼主| 发表于 2013-1-15 02:57:21 | 显示全部楼层 |阅读模式
这个实例演示了怎么样使用System.setClipboard()静态方法,从一个Flex application中复制文字到操作系统的剪贴板。
随便在RichTextEditor打些字,然后点击Copy text to clipboard 按钮就复制到剪贴板了,之后就找个能打文本的地方试试吧
先看演示
<embed width="400" height="300" src="http://www.51xflash.com/uploads/media/flex/main_3.swf" document wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed> 
完整的代码见这里:
<?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>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表