Flex接收flashvars参数

 

Flex代码

<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2007/08/07/grabbing-flashvars-from-the-embedding-html-template/ --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()" viewSourceURL="srcview/index.html"> <mx:Script> <!--[CDATA[ private function init():void { // The FlashVars var obj:Object = Application.application.parameters; var item:String; arrColl = new ArrayCollection(); /* Populate the ArrayCollection object with the FlashVars. */ for (item in obj) { arrColl.addItem({key:item, value:obj[item]}); } dataGrid.dataProvider = arrColl; } ]]--> </mx:Script> <mx:ArrayCollection id="arrColl" /> <mx:DataGrid id="dataGrid" /> </mx:Application>

 

Html代码

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>loaderInfoExample</title> </head> <body bgcolor="#ffffff"> <div/> flashvars <div> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="250" id="loaderInfoExample" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <PARAM NAME="flashvars" VALUE="userName=permadi"> <param name="movie" value="loaderInfoExample.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <embed src="FlashVar_Test.swf" mce_src="FlashVar_Test.swf" flashvars="userName=permadi" quality="high" bgcolor="#ffffff" width="400" height="250" name="loaderInfoExample" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </body> </html>

 

 

使用javascript,如swfobject.js嵌入时

<script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. --> var swfVersionStr = "10.0.0"; <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. --> var xiSwfUrlStr = "playerProductInstall.swf"; var FlashVars = {bridgeName:"flash"}; var params = {}; params.quality = "high"; params.bgcolor = "#869ca7"; params.allowscriptaccess = "sameDomain"; params.allowfullscreen = "true"; var attributes = {}; attributes.id = "IFrameCommTest"; attributes.name = "IFrameCommTest"; attributes.align = "middle"; swfobject.embedSWF( "IFrameCommTest.swf", "flashContent", "100%", "100%", swfVersionStr, xiSwfUrlStr, FlashVars, params, attributes); <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. --> swfobject.createCSS("#flashContent", "display:block;text-align:left;"); </script>

 

 

参考

http://blog.flexexamples.com/2007/08/07/grabbing-flashvars-from-the-embedding-html-template/

 

http://blog.flexexamples.com/2009/03/04/grabbing-flashvars-from-the-embedding-html-template-in-flex-gumbo-swfobject-edition/

 

你可能感兴趣的:(Flex接收flashvars参数)