六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 179|回复: 0

Flex 2和JavaScript交互

[复制链接]

升级  34.35%

547

主题

547

主题

547

主题

探花

Rank: 6Rank: 6

积分
1687
 楼主| 发表于 2013-2-7 22:41:49 | 显示全部楼层 |阅读模式
在Flex开发的时候,经常遇到一些问题处理起来比较麻烦.这个时候调用html页面里的js代码就成了最快的解决方案.flex主要是通过ExternalI­nterface.call来调用页面的代码,下面的例子是不需要返回值的调用. joinmeet.mxml
代码 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="200" height="150">   <mx:Script>     <![CDATA[       import flash.external.*;
      public function Joinmeet() : void {         var f : String = "showsubmenu";         var m : String = ExternalInterface.call(f,"0");         trace(m);       }
      public function callWrapper():void {         var f:String = "changeDocumentTitle";         var m:String = ExternalInterface.call(f,"New Title");         trace(m);       }     ]]>   </mx:Script>   <mx:Button label="提交" click="Joinmeet()" x="123" y="118"/> </mx:Application>
代码 <!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>无标题文档</title> </head> <style type="text/css"> <!-- .Layer1 {   position:absolute;   left:0px;   top:50px;   width:80%;   height:205px;   z-index:1;   background:#ffe;   border:1px #999 solid;   background:#000;
<div style="display: block;" class="qt">}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

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