tags:

views:

32

answers:

3

What is the preferred way of passing parameters to a Flex application deployed as a .swf and how do I read the parameters from Flex?

I'm looking for the equivalent of passing and reading URL parameters in Flex land.

A: 

embed the swf object in an html page and then use external interface. These articles should help you:

http://www.adobe.com/livedocs/flex/2/langref/flash/external/ExternalInterface.html

Flex Examples

asawilliams
+1  A: 

I like to use FlashVars.

var paramObj:Object = Application.application.parameters;
trace(paramObj['foo']);
Abhinav
+1  A: 
public function getQuerystringProperty(property:String):String {
  var bm:IBrowserManager = BrowserManager.getInstance();
  var oArgs:Object = {};
  bm.init("", "");
  oArgs = mx.utils.URLUtil.stringToObject(bm.fragment, “&”);
  if (oArgs[property])
    return oArgs[property].toString();
  return "";
}

Gets the QueryString from within Flex (no ExternalInterface).

adamcodes
Actually, BrowserManager does use ExternalInterface.
joshtynjala
I meant explicitly :)
adamcodes