zoukankan      html  css  js  c++  java
  • Flex 和JavaScript 交互(带参)

    flash文件与面页交互:

     

    Flex文件:

    Flex代码 
    1. <?xml version="1.0" encoding="utf-8"?>     
    2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   
    3.     width="200" height="150"  
    4.     creationComplete="init()">     
    5.     <mx:Script>     
    6.         <![CDATA[  
    7.             import mx.controls.Alert;     
    8.             import flash.external.*;     
    9.               
    10.             [Bindable]  
    11.             private var jstime: String;  
    12.                  
    13.             private function init(): void  
    14.             {  
    15.                 flash.external.ExternalInterface.addCallback("jstest", jstest);  
    16.             }  
    17.                  
    18.             public function js() : void {   
    19.                 var m : String = ExternalInterface.call("flashtest","flash");  
    20.                 Alert.show(m);  
    21.             }     
    22.                  
    23.   
    24.             public function jstest(str: String): String  
    25.             {  
    26.                 jstime = str;  
    27.                 return "jstest::" + jstime;  
    28.             }  
    29.               
    30.             private function ttt(): void  
    31.             {  
    32.                 Alert.show(jstime);  
    33.             }  
    34.         ]]>     
    35.     </mx:Script>     
    36.     <mx:Button label="test" click="js()" x="142" y="118"/>     
    37.     <mx:Button label="jstest" click="ttt()" x="76" y="118"/>    
    38.     <mx:Text x="10" y="43" text="{jstime}" width="180"/>  
    39. </mx:Application>    

     

     

    html:

    Html代码 
    1. <html lang="en">   
    2.     <SCRIPT language="javascript">    
    3.         function now()  
    4.         {  
    5.             var d=new Date();   
    6.             return d.getYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();  
    7.         }  
    8.           
    9.         function flashtest(sid)     
    10.         {    
    11.             return sid + "::" + now();  
    12.         }     
    13.         
    14.   
    15.         function testflash()  
    16.         {  
    17.             var x = flexjs.jstest(now());  
    18.           alert(x);  
    19.           
    20.         }  
    21.       
    22.     </SCRIPT>     
    23.   
    24.     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  
    25.             id="flexjs" width="200" height="150"  
    26.             codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">  
    27.             <param name="movie" value="flexjs.swf" />  
    28.             <param name="quality" value="high" />  
    29.             <param name="bgcolor" value="#869ca7" />  
    30.             <param name="allowScriptAccess" value="sameDomain" />  
    31.             <embed src="flexjs.swf" quality="high" bgcolor="#869ca7"  
    32.                 width="200" height="150" name="flexjs" align="middle"  
    33.                 play="true"  
    34.                 loop="false"  
    35.                 quality="high"  
    36.                 allowScriptAccess="sameDomain"  
    37.                 type="application/x-shockwave-flash"  
    38.                 pluginspage="http://www.adobe.com/go/getflashplayer">  
    39.             </embed>  
    40.     </object>  
    41. <br>  
    42. <input type="button" value="flashtest" onclick="testflash();">  
    43. </html>  

     

  • 相关阅读:
    week4
    week3
    2017福州大学面向对象程序设计寒假作业二
    Week2
    10个android开发必备的开源项目
    Day Ten
    Day Nine
    Day Eight
    Day Seven
    Day Six
  • 原文地址:https://www.cnblogs.com/whisht/p/2251810.html
Copyright © 2011-2022 走看看