This content has been marked as final. Show 6 replies
You can still use flashvars:
In your MXML <mx:Application> file declare a public variable of type string:
public var TestVar:String;
then modify the HTML wrapper to pass this as a flashvar:
<param name="flashvars" value="TestVar=TestValue" />
Make the adjustments for the object and embed tags, of course.
You can also pass the variables in as a query parameter to the MXML file:
Thanks for your reply.
But i still have trouble working it out. I wonder if it only works when it is a mxml file or I had written the wrong code.
Here is my test code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="Init()">
public var TestVar:String;
public function Init():void
I compiled it to "Test.swf", And in the object and embed tags:
width="100%" height="100%" id="Test">
<param name="flashvars" value="TestVar=TestValue">
<param name="src" value="Test.swf">
<embed pluginspage=" http://www.macromedia.com/go/getflashplayer" width="500" height="300" src="Test.swf" name="Test"/>
Thanks for taking time and trouble to help me.
Two apologies: one for taking so long to get back to you, and another for giving you bad advice. I didn't realize we changed how request parameters are fed into Flex 2 applications.
First, you need to pass your values using FlashVars. It does not matter where the HTML or JSP comes from. But if you look at the HTML generated code from either the web-tier compiler or Flex Builder 2, you'll see there are at least 2 places where flashvars are mentioned. You will need to code them all.
<param name="FlashVars" value="TestValue=TestString" />
or something more like "flashvars",' TestValue=test2&historyUrl=history.htm%3F&lconid=' + lc_id + '',
Inside your Application you do: (this is what changed):
private var testVar:String;
then when you want to get to the value in the FlashVars, do this:
where TestValue is the name in the FlashVars.
For more details, look up "Using the Application.application.parameters object" in the Adobe Flex 2 documentation.
I greatly appreciate your help.I test it, and it really works.Thanks again.
could someone please post a working example, the example in the docs doesnt compile and whats here is still a little vague..
say about the preceding test codes i gave. You do not need to modify the object and embed tags. But you do modify the Test.mxml file like the following:
private var TestVar:String;
private function Init():void
TestVar = Application.application.parameters.TestVar;
pay attention to the statement "import mx.core.Application", if you omit it, you would not compile successfully.
Hope that could help.