Flex JavaScript 交互 Flex 和JavaScript 交互(带参)
人气:0想了解Flex 和JavaScript 交互(带参)的相关内容吗,在本文为您仔细讲解Flex JavaScript 交互的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Flex,JavaScript,交互,下面大家一起来学习吧。
Flex文件:复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="200" height="150"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.external.*;
[Bindable]
private var jstime: String;
private function init(): void
{
flash.external.ExternalInterface.addCallback("jstest", jstest);
}
public function js() : void {
var m : String = ExternalInterface.call("flashtest","flash");
Alert.show(m);
}
public function jstest(str: String): String
{
jstime = str;
return "jstest::" + jstime;
}
private function ttt(): void
{
Alert.show(jstime);
}
]]>
</mx:Script>
<mx:Button label="test" click="js()" x="142" y="118"/>
<mx:Button label="jstest" click="ttt()" x="76" y="118"/>
<mx:Text x="10" y="43" text="{jstime}" width="180"/>
</mx:Application>
html:
复制代码 代码如下:
<html lang="en">
<SCRIPT language="javascript">
function now()
{
var d=new Date();
return d.getYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
}
function flashtest(sid)
{
return sid + "::" + now();
}
function testflash()
{
var x = flexjs.jstest(now());
alert(x);
}
</SCRIPT>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="flexjs" width="200" height="150"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="flexjs.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="flexjs.swf" quality="high" bgcolor="#869ca7"
width="200" height="150" name="flexjs" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
<br>
<input type="button" value="flashtest" onclick="testflash();">
</html>
加载全部内容