knorv
knorv

Reputation: 50117

Correct way of passing and reading parameters to a .swf in Flex?

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.

Upvotes: 1

Views: 317

Answers (3)

Abhinav
Abhinav

Reputation: 39884

I like to use FlashVars.

var paramObj:Object = Application.application.parameters;
trace(paramObj['foo']);

Upvotes: 1

adamcodes
adamcodes

Reputation: 1606

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).

Upvotes: 1

asawilliams
asawilliams

Reputation: 2938

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

Upvotes: 0

Related Questions