加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用ExternalInterface调用Flex方法-无参数、无返回值!

发布时间:2020-12-15 04:30:08 所属栏目:百科 来源:网络整理
导读:生成flash的mxml文件源码如下: ? ?xml version="1.0" encoding="utf-8"? s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" ????? xmlns:s="library://ns.adobe.com/flex/spark" ????? xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" mi

生成flash的mxml文件源码如下:
?
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
????? xmlns:s="library://ns.adobe.com/flex/spark"
????? xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="app(event)" >
?<fx:Declarations>
? <!-- 将非可视元素(例如服务、值对象)放在此处 -->
?</fx:Declarations>
?<fx:Script>
? <![CDATA[
?? import mx.events.FlexEvent;
?? import mx.controls.Alert;
??
?? private function app(event:FlexEvent):void{
??? ExternalInterface.addCallback("flex_hello_world",hello_world);
?? }
?? private function hello_world():void{
??? Alert.show("使用ExternalInterface调用Flex方法-无参数、无返回值!");
?? }
? ]]>??
?</fx:Script>??
</s:Application>?
?
?
?
插入flash的html文件:
?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>使用ExternalInterface调用Flex方法-无参数、无返回值!</title>
<script type="text/javascript" src='#'" /script>
<script type="text/javascript">
function js_hello_world(){
?var obj=document.getElementById('flash');
?var msg=obj.flex_hello_world();
}
function js_hello_world2(){
?var obj=document.getElementById('flash2');
?var msg=obj.flex_hello_world();
}
function js_hello_world3(){
?var obj=document.getElementById('flash3');
?var msg=obj.flex_hello_world();
}
</script>
</head>

<body>
<input type="button"value="swfobject" width="100"
<div id="flash"></div>
<script type="text/javascript">
swfobject.embedSWF("js3.swf","flash","400","325","11.1.0","playerProductInstall.swf",{});
</script>

<input type="button"value="swfobject" width="100"
<embed src='#'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="325" id="flash2"></embed>

<input type="button"value="swfobject" width="100"
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0" width="400" height="325" id="flash3">
? <param name="movie" value="js3.swf" />
? <param name="quality" value="high" />
</object>
</body>
</html>
?
注:object方式ie以外无法调用Flex方法,embed方式ie无法调用Flex方法
?
参考:http://blog.csdn.net/xuhuanchao/article/details/4900859

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读