Tuesday, November 4, 2008

FlashVars in Flex 3

To pass values from the host to swf file, follow the following steps


1) Open the html or aspx file where you have flex swf file embedded.
2) You will see 2 AC_FL_RunContent sections
3) Look at the line in Red, I am passing the value Hello World to the swf file

AC_FL_RunContent(
"src", "FlashV",
"FlashVars", "MMredirectURL=Hello World",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "FlashV",
"quality", "high",
"bgcolor", "#869ca7",
"name", "FlashV",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);

-------------------
Now in mxml file, on ApplicationComplete, call a function
applicationComplete="Init()"

private function Init():void
{
var o:Object = this.loaderInfo.parameters;
Alert.show(o.MMredirectURL.toString());
}



















2 comments:

  1. Few more ways to pass variable to flex

    http://yasob.blogspot.com/2009/05/accessing-http-request-parameter-in.html

    ReplyDelete
  2. http://yasob.blogspot.com/2009/05/accessing-http-request-parameter-in.html

    ReplyDelete