as3代码

package  {
	import flash.display.Sprite;
	import fl.controls.Button;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.system.System;

	[SWF(backgroundColor='0xffffff',width='120',height='30',frameRate='29')]
	public class main extends Sprite {

		public function main() {
			var btn:Button = new Button();
			btn.x = 0 ;
			btn.y = 0;
			btn.width  = 120;
			btn.height = 30;
			btn.label = '复制';
			btn.addEventListener(MouseEvent.CLICK,doCopyJSInFo);
			this.addChild(btn);
		}
		private function doCopyJSInFo(event:MouseEvent):void{
			var info:String = ExternalInterface.call('jsCopyInfoFun','copyeleId');
			System.setClipboard(info);
		}
	}
	
}

说明:上面代码实现的是调用js函数jsCopyInfoFun来获取该js函数的返回值。并把这个返回值放到粘贴板中。




下面则是html页面运行上面falsh功能的一个实例(text.swf是上面运行的flash结果文件)

<html>
    <head>
        <meta charset="utf-8"/>
        <title>test</title>
        <script type="text/javascript" src="swfobject.js"></script>
    </head>
    <body>
        <div style="position: absolute; left: 50%; width: 800px; height: 400px; margin-left: -400px; top: 50%; margin-top: -200px;text-align: center;">
            <textarea id="copyeleId" style="height: 300px; width: 800px;"></textarea>
            <div id="flashContainer" ></div>      
        </div>
    </body>
</html>
<script type="text/javascript">
    function jsCopyInfoFun(objId) {
        alert('复制成功');
        return document.getElementById(objId).value;
    }
    function todoTest() {
        alert('执行回调函数');
    }
    window.onload = function () {
        /*
         *  embedSWF: function (swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) 
         *  swfUrlStr swf的URL
         *  replaceElemIdStr  被swf替换的html元素的id
         *  widthStr   swf的宽
         *  heightStr   swf的高
         *  swfVersionStr  swf执行的最低版本
         *  xiSwfUrlStr  当版本低于要求时,引导到官方下载最新版本的flash插件
         *  flashvarsObj  swf 文件的入口参数
         *  parObj  通过json对象指定object的参数 play loop menu quality scale  salign  wmode bgcolor base swliveconnect
         *  attObj  通过json对象指定object的属性
         *  callbackFn  回调函数,这个回调函数无论加载 swf 文件成功或失败都会调用;
         */
        swfobject.embedSWF("test.swf", "flashContainer", "120", "60", "8", "expressInstall.swf", {}, {menu: false, quality: 'high'}, {id: "testflash", name: "dynamicContent2"}, todoTest);

    }
</script>

说明:swfobject是一个js插件,专用于swf文件。