Well I guess I can just check the original url String and the string 
value returned after replacing with the regular expression - if 
they're the same, then don't pass the potentially modified url to the 
URLVariables constructor....

Seems a bit messy though...is there some other way to determine if 
the url has parameters?


var url:String = this.loaderInfo.url;                           
var pattern:RegExp = /.*\?/; 
var urlStr:String = (url).replace(pattern, ""); 

if(url != urlStr){
    var urlVars:URLVariables = new URLVariables(urlStr);  
}


        

--- In [email protected], "guitarguy555" <[EMAIL PROTECTED]> 
wrote:
>
> I have a Flex app that loads various modules. 
> 
> Sometimes when I load a new module I have some parameters appended 
to 
> the URL and I don't want these parameters to display in the address 
bar.
> I extract the parameters when the module is loaded using the 
following 
> code:
> 
> 
> 
> var url:String = this.loaderInfo.url;                         
> // discard everything up to, and including, the question mark (?) 
in 
> the URL. 
> var pattern:RegExp = /.*\?/; 
> var urlStr:String = (url).replace(pattern, ""); 
> //Use the URLVariables class to parse the query-string. 
> var urlVars:URLVariables = new URLVariables(urlStr);  
> // Now the parameters are accessible as objects               
         
> label1.text = urlVars.FirstName;
> label2.text = urlVars.LastName;
> 
> 
> This works great until situations where there are no parameters.
> In some situations,  I want to load a module and not have any 
> parameters attached to the url.  Just a basic url like:  
myModule.swf
> 
> When the above code runs, it breaks at this line:
> var urlVars:URLVariables = new URLVariables(urlStr);  
> 
> This is the error message:
> Error #2101: The String passed to URLVariables.decode() must be a 
URL-
> encoded query string containing name/value pairs.
> 
> How do I test to see if the url has any parameters appended to it 
> before I make the call to UrlVariables.decode? 
> Is there some built-in Flex method that can let you know if your 
url 
> has parameters or not?
> 
> Thanks
>


Reply via email to