How can I pass parameters from a web application (JSP) to a Flex application (mxml file)
In 开发者_StackOverflowmy enterprise web application I have a menu item ( struts menu ) which calls for a Flex web application.
Here "LPort" is my flex web app and "Main" is my EAR. I can go to my flex application but hwo can I pass paramters from my JSP to the MXML file.
Assuming you have the Flex app (Flash swf) embedded in your JSP - my suggestion is to use "FlashVars" to pass parameters from the JSP to the Flex application.
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="LPort.swf" />
<param name="FlashVars" value="paramA=<%=paramA%>¶mB=<%=paramB%>" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="menu" value="false"/>
<param name="wmode" value="opaque" />
<param name="allowScriptAccess" value="always" />
<embed src="LPort.swf" quality="high" bgcolor="#869ca7" id="Logbook"
width="100%" height="100%" name="LPort" align="middle"
FlashVars="paramA=<%=paramA%>¶mB=<%=paramB%>"
menu="false"
play="true"
loop="false"
wmode="opaque"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
Then in your Flex application you can access these parameters as follows (I assume a cast of String).
if (Application.application.parameters.paramA != undefined)
{
myFlexVarA = String(Application.application.parameters.paramA);
}
if (Application.application.parameters.paramB != undefined)
{
myFlexVarB = String(Application.application.parameters.paramB);
}
精彩评论