Synchronicity: I was working on the exact same problem and stopped by
flexbuilders while waiting for a build/deploy. This is, needless to say,
much easier than the approach I was going down (which involved
ExternalInterface, etc).
On the Flex side, I wrote the following to parse and store the query
params in my main application:
public var queryParams : Object = new Object();
public function loadQueryParams() : void {
var queryString : String =
Application.application.parameters["queryParams"];
if (queryString && queryString != "") {
var params : Array = queryString.split("&");
for (var i : Number = 0; i < params.length; i++) {
var param : Array = String(params[i]).split("=");
queryParams[param[0]] = param[1];
}
}
// Verify
for (var s : String in queryParams) {
trace("Parameter: " + s + "=" + queryParams[s]);
}
}
Seems to work like a charm. It's bit verbose, but hey, that's me. Thanks
for the tip, Doug, et al!
- Chris
--- In [EMAIL PROTECTED], "Doug Lowder" <[EMAIL PROTECTED]> wrote:
>
> You can also use a bit of JavaScript code to simply pass whatever URL
> parameters have been specified for the HTML on to your SWF, if that's
> what you're after. I usually edit the HTML template and include the
> following:
>
> // In the Globals area near the top
> var myvars = new String(document.location).split('?')[1];
>
> // the line in AC_FL_RunContent that specifies flashvars
> "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '&' +
> myvars,
>
>
> --- In [EMAIL PROTECTED], "Tracy Spratt" tspratt@ wrote:
> >
> > Nate, sorry it is not quite that easy. You are passing a parameter
> to
> > an html file. The html file has no way to see that arg and pass it
> to
> > the Player instance.
> >
> >
> >
> > This will work if you call the .swf directly, with the querystring
> > parameter. Use Application.application.parameters.test.
> >
> >
> >
> > To do this in a production environment (if the parameters are
> dynamic)
> > you will need to have a server platform generate the html file.
> >
> >
> >
> > The easiest way to do this is to look at the generated html file
> that
> > FlexBuilder creates. In the javascript call, you will need to add
> your
> > parameters to the "flashvars" line in AC_FL_RunContent(... like:
> >
> > "flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id
> + "&test=system"
> > + '',
> >
> >
> >
> > Of course you will have the server (asp, jsp...) output the actual
> value
> > you want for "system".
> >
> >
> >
> > Tracy
> >
> >
> >
> > ________________________________
> >
> > From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> > Behalf Of Nate Pearson
> > Sent: Friday, April 13, 2007 6:19 PM
> > To: [EMAIL PROTECTED]
> > Subject: [flexcoders] Noob Querystring questions
> >
> >
> >
> > I'm trying to pass in variable via the URL.
> >
> > I have:
> > var QueryString:String = this.parameters.test
> >
> > http://myserver.com/myapp.html?test=systems
> > <http://myserver.com/myapp.html?test=systems>
> >
> > I always get null....Where is my problem?
> >
> > (I have also tried Application.application.parameters.test)
> >
>