Flex doesn’t support native function to get query parameters from the url and you will have to develop one yourself. I needed this function for one of the tasks I have to complete at work, so I wrote one myself. The code as follows:
import flash.external.ExternalInterface;

public static function getHtmlParameters(queryString:String):String {
var param:String = ExternalInterface.call("window.location.search.toString");
if(!param) return '';

param=param.replace("\?", "&");
var paramArray:Array = param.split('&');
for(var x:int = 0; x<paramArray.length; x++) {
var splitArray:Array = paramArray[x].split('=');

var name:String = splitArray[0];
var value:String = splitArray[1];

if(queryString == name) return value;
}

return '';
}
I think the code is straightforward enough and don’t need more explanations. I hope it can help someone who needed and save your time. Happy blogging.

Leave a Reply

Your email address will not be published. Required fields are marked *