Flex学习之(JS中调用Flex的方法)
flex端
public function initApp():void
{
ExternalInterface.addCallback("function1",callback1);
}
public function callback1():void
{
Alert.show("hello word");
}
js端
function JavaScript()
{
document.getElementById("Dome1").function1();
}
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" //html-template里面有这个id号
id="Dome1" width="100%" height="500"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
<param name="movie" value="swf/bin-debug/index.swf" /> //在asp.NET项目文件夹中创建swf文件夹,并将bindebug里面的所有文件拷进去
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="menu" value="false" />
<param name="allowScriptAccess" value="sameDomain" />
</object>
<button id = "testSwf" name ="ceshiSwf" onclick = "javaScript()" />
注意:如果flex程序里面调用了外部的图片或者视频等文件时,一定要把路径跟flex中调用的路径统一起来