/ Published in: ActionScript 3
This function will take the querystring from the URL and return it as a property:value paired object.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * _getQuerystringAsObject * returns the URL querystring as an object */ private function _getQuerystringAsObject():Object { var _params:Object = {}; var _queryString:String; var _all:String; try { _all = ExternalInterface.call("window.location.href.toString"); _queryString = ExternalInterface.call("window.location.search.substring", 1); if(_queryString) { var params:Array = _queryString.split('&'); var length:uint = params.length; for (var i:uint=0,index:int=-1; i<length; i++) { var kvPair:String = params[i]; if((index = kvPair.indexOf("=")) > 0) { var key:String = kvPair.substring(0,index); var value:String = kvPair.substring(index+1); _params[key] = value; } } } }catch(e:Error) { trace("ERROR"); } return _params; }