--FELX TRANSFER METHOD OF JAVASCRIPT
 1,页面中包含swf文件

 2,FLEX中使用ExternalInterface.call("myFun","参数1","参数2");


--JAVASCRIPT TRANSFER METHOD OF FLEX
 FLEX FILE

  1,ExternalInterface.addCallback("myFlexFunction",myFun); myFun为FLEX中的函数名,这是一个key-value结构

 JAVASCRIPT FILE

  1,页面中包含swf文件,OBJECT中指定swf文件的id

  2,使用OBJECT中指定的ID.key来调用FLEX中的方法,FLEX专属的一些特性不能被使用,例如Alert.show();

EXAMPLE
--FLEX

<?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="initApp();"

      >

 <fx:Declarations>

  <!-- 将非可视元素(例如服务、值对象)放在此处 -->

 </fx:Declarations>

 <fx:Script>

  <![CDATA[

   import mx.controls.Alert;

   private function myFun():int{

    Alert.show("20 from flex","MEssage");

    return 20;

   }

   private function initApp():void{

    ExternalInterface.call("myFun",1,2); //传入参数

    ExternalInterface.addCallback("myFlexFunction",myFun);

   }

  ]]>

 </fx:Script>

</s:Application>

--HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "​​http://www.w3.org/TR/html4/loose.dtd​​​">

<html>

 <head>

  <title> New Document </title>

  <meta name="Generator" content="EditPlus">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

 <SCRIPT LANGUAGE="JAVASCRIPT">

  function callMyFun(){

   //调用FLEX FUNCTION

   var num = FLEX_DATA_1.myFlexFunction();//FLEX_DATA_1为页面说包含的swf文件的id
   alert(num);

  }

  function myFun(content1,content2){

   alert(content1+content2);

  }

 </SCRIPT>


 </head>

 <body>

 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="FLEX_DATA_1">

  <param name="movie" value="FLEX_DATA_1.swf"/> //网络上的资源路径

  <param name="scale" value="noborder"/> //规模,没有边框

  <param name="WMODE" value="Transparent"/> //模式,透明

  <param name=bgcolor value=#FFFFFF/> //背景颜色

  <param name="quality" value="high" />  //质量,high高

  <param name="menu" value="false" />  //菜单,无

  <param name="allowScriptAccess" value="sameDomain" />  //允许script接入,同样的范围


  <embed src="FLEX_DATA_1.swf"

   quality="hight" align="middle" width="100%" height="450"

   scale=noborder bgcolor=#000000 name="TH2"

   type="application/x-shockwave-flash"  //资源类型

   allowScriptAccess="sameDomain"

   pluginspage="http://www.macromedia.com/go/getflashplayer"/> //插件页面

 </object>

 <BUTTON ONCLICK="callMyFun();">CLICK ME</BUTTON>

 </body>

</html>