Flex4 flashVars 传值

 
 
[html] view plaincopy
 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <!-- saved from url=(0014)about:internet -->  
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">   
  4.     <!--   
  5.     Smart developers always View Source.   
  6.       
  7.     This application was built using Adobe Flex, an open source framework  
  8.     for building rich Internet applications that get delivered via the  
  9.     Flash Player or to desktops via Adobe AIR.   
  10.       
  11.     Learn more about Flex at http://flex.org   
  12.     // -->  
  13.     <head>  
  14.         <title>${title}</title>  
  15.         <meta name="google" value="notranslate" />           
  16.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  17.         <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and   
  18.              the body element to 100%, because Firefox, or any Gecko based browser, interprets percentage as   
  19.              the percentage of the height of its parent container, which has to be set explicitly.  Fix for  
  20.              Firefox 3.6 focus border issues.  Initially, don't display flashContent div so it won't show   
  21.              if JavaScript disabled.  
  22.         -->  
  23.         <style type="text/css" media="screen">   
  24.             html, body  { height:100%; }  
  25.             body { margin:0; padding:0; overflow:auto; text-align:center;   
  26.                    background-color: ${bgcolor}; }     
  27.             object:focus { outline:none; }  
  28.             #flashContent { display:none; }  
  29.         </style>  
  30.           
  31.         <!-- Enable Browser History by replacing useBrowserHistory tokens with two hyphens -->  
  32.         <!-- BEGIN Browser History required section ${useBrowserHistory}>  
  33.         <link rel="stylesheet" type="text/css" href="history/history.css" />  
  34.         <script type="text/javascript" src="history/history.js"></script>  
  35.         <!${useBrowserHistory} END Browser History required section -->    
  36.               
  37.         <script type="text/javascript" src="swfobject.js"></script>  
  38.         <script type="text/javascript">  
  39.             // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.   
  40.             var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";  
  41.             // To use express install, set to playerProductInstall.swf, otherwise the empty string.   
  42.             var xiSwfUrlStr = "${expressInstallSwf}";  
  43.             var flashvars = {employeeName:"中文",language:"en_US"};  
  44.             var params = {};  
  45.             params.quality = "high";  
  46.             params.bgcolor = "${bgcolor}";  
  47.             params.allowscriptaccess = "sameDomain";  
  48.             params.allowfullscreen = "true";  
  49.             var attributes = {};  
  50.             attributes.id = "${application}";  
  51.             attributes.name = "${application}";  
  52.             attributes.align = "middle";  
  53.             swfobject.embedSWF(  
  54.                 "${swf}.swf?version=1.0", "flashContent",   
  55.                 "${width}", "${height}",   
  56.                 swfVersionStr, xiSwfUrlStr,   
  57.                 flashvars, params, attributes);  
  58.             // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.  
  59.             swfobject.createCSS("#flashContent", "display:block;text-align:left;");  
  60.         </script>  
  61.     </head>  
  62.     <body>  
  63.         <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough   
  64.              JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show  
  65.              when JavaScript is disabled.  
  66.         -->  
  67.         <div id="flashContent">  
  68.             <p>  
  69.                 To view this page ensure that Adobe Flash Player version   
  70.                 ${version_major}.${version_minor}.${version_revision} or greater is installed.   
  71.             </p>  
  72.             <script type="text/javascript">   
  73.                 var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");   
  74.                 document.write("<href='http://www.adobe.com/go/getflashplayer'><img src='"   
  75.                                 + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );   
  76.             </script>   
  77.         </div>  
  78.           
  79.         <noscript>  
  80.             <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">  
  81.                 <param name="movie" value="${swf}.swf?version=1.0" />  
  82.                 <param name="quality" value="high" />  
  83.                 <param name="bgcolor" value="${bgcolor}" />  
  84.                 <param name="allowScriptAccess" value="sameDomain" />  
  85.                 <param name="allowFullScreen" value="true" />  
  86.                 <param name="FlashVars" value="employeeName=中文&language=en_US"/>  
  87.                 <!--[if !IE]>-->  
  88.                 <object type="application/x-shockwave-flash" data="${swf}.swf?version=1.0" width="${width}" height="${height}">  
  89.                     <param name="quality" value="high" />  
  90.                     <param name="bgcolor" value="${bgcolor}" />  
  91.                     <param name="allowScriptAccess" value="sameDomain" />  
  92.                     <param name="allowFullScreen" value="true" />  
  93.                     <param name="FlashVars" value="employeeName=中文&language=en_US"/>  
  94.                 <!--<![endif]-->  
  95.                 <!--[if gte IE 6]>-->  
  96.                     <p>   
  97.                         Either scripts and active content are not permitted to run or Adobe Flash Player version  
  98.                         ${version_major}.${version_minor}.${version_revision} or greater is not installed.  
  99.                     </p>  
  100.                 <!--<![endif]-->  
  101.                     <href="http://www.adobe.com/go/getflashplayer">  
  102.                         <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />  
  103.                     </a>  
  104.                 <!--[if !IE]>-->  
  105.                 </object>  
  106.                 <!--<![endif]-->  
  107.             </object>  
  108.         </noscript>       
  109.    </body>  
  110. </html>  


flashvars 传值

传递的方式一致:

<param name="FlashVars" value="myName=julabs&amp;myHometown=china" />

<embed src="demo.swf" FlashVars="myName=julabs&amp;myHometown=china" ........ />

demo.swf??u1=good&u2=bad

其中可以在FlashVars中指定,也可以通过  movie或 src中的swf url指定参数,修改所有包含flashvar的地方

获取flashVars的值

Flex4中获取flashVars值:(Flex4的取值方式与Flex3不同)

xxx = FlexGlobals.topLevelApplication.parameters.employeeName;

xxx = FlexGlobals.topLevelApplication.parameters.language;

Flex3中的取值方式为:

XXX = Application.application.parameters.employeeName;

原文地址:https://www.cnblogs.com/-yan/p/4422186.html