If you are accessing the swf directly, that is, without an html (or
jsp, asp, cfx) wrapper, then within your ActionScript, you can query
whether the query string is empty using:
Application.application.parameters.length == 0

If you are using a wrapper, you would first need some javascript or
server pages code to pass the query string into the swf being loaded.
For example, I use a jsp wrapper template, which is very much like the
default html template except for something like this:
AC_FL_RunContent(  
"src", "${swf}?<%= request.getQueryString() %>", . . .

--- In flexcoders@yahoogroups.com, "guitarguy555" <[EMAIL PROTECTED]> wrote:
>
> 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 flexcoders@yahoogroups.com, "guitarguy555" <djohnson29@> 
> 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