#2 doesn't seem too bad to me. It solves your problem and does it without adding any extra code to SWFObject, and is pretty simple and easy to use.
2009/1/13 Elliot Mebane <[email protected]> > This new info is very helpful. I'm glad to see that SWFObject already > does what I've been looking for. > > > > It would be ideal to do all specification of *flashvars* with the flashvars > object and not have to use the params object for specifying **any** > flashvars content. > > > > Here's what I would like to be able to do when mixing query-string > flashvars with JavaScript-specified flashvars: > > var flashvars = {flashvars: swfobject.getQueryParamValue().substring(1)}; > > flashvars.addVar1 = "addVal1"; > > > > Here's what I have to do instead: > > var flashvars = {}; > > flashvars.addVar1 = "addVal1"; > > var params = {}; > > params.flashvars = swfobject.getQueryParamValue().substring(1); > > > > You can see the results of both of the above snippets in my examples below. > > > > > Notes about my experiments with flashvars and SWFObject: > > 1. Aran's sample and the SWFObject docs suggest using the params object for > adding additional flashvars. I don't think that's the way people will try > to add additional name/value pairs. People will expect to be able to add > additional flashvars to the *flashvars* object, not to be required to use > the *params* object. > > 2. When trying to use getQueryParamValue with the flashvar object, the SWF > receives the first flashvar variable with an incorrect name and value (see > sample below). I think Aran encountered this and mentioned it in an earlier > post. That may be what was resolved when Bobby switched the order Aran was > passing his flashvars and params objects to the embedSWF method. > > 3. After reviewing the SWFObject docs, I see the guidance about adding a > flashvars variable to the params object, allowing the user to work with a > query-string formatted list of flashvars. > > 4. From Bobby's code snippet I understand that although we create and > populate a flashvars object, ultimately the flashvars are passed from > JavaScript to the SWF as a single string, not as an object. > > > > Below are results from 2 experiments. Both use a URL with query-string > like this: flashVarsTest.html?qvar1=qval1&qvar2=qval2&qvar3=qval3 > > > > ----------------------------------------------- > > Test 1 --This is what I'd **like** to be able to do. It keeps all > flashvars specifications with the flashvars object. Note that in the results > that the SWF displays, the first flashvar has the prefix "flashvars" and the > value is incorrect. > > > > JavaScript -- > > > > var flashvars = {}; > > flashvars.flashvars = > swfobject.getQueryParamValue().substring(1); > > flashvars.additionalName1 = > "value1"; > > flashvars.additionalName2 = > "value2"; > > var params = {}; > > var attributes = {}; > > > swfobject.embedSWF("flashVarsDisplay.swf", "flashVarsDisplayId", "700", > "300", "9.0.0", "expressInstall.swf", flashvars, params, attributes); > > > > Resulting flashvars as seen by Flash -- > > > > additionalName2: value2 > > qvar3: qval3 > > additionalName1: value1 > > flashvars: qvar1=qval1 > > qvar2: qval2 > > > > ------------------------------------ > > Test 2 - Adding a **flashvars** variable to the params object like in the > SWFObject documentation. I'm able to use the flashvars object to add > additional variables with dot notation now, but the need to put flashvars > into the params object is a little awkward: > > > > var flashvars = {}; > > flashvars.additionalName1 = > "value1"; > > flashvars.additionalName2 = > "value2"; > > var params = {}; > > params.flashvars = > swfobject.getQueryParamValue().substring(1); > > var attributes = {}; > > > swfobject.embedSWF("flashVarsDisplay.swf", "flashVarsDisplayId", "700", > "300", "9.0.0", "expressInstall.swf", flashvars, params, attributes); > > > > Results -- > > > > qvar2: qval2 > > additionalName2: value2 > > qvar1: qval1 > > qvar3: qval3 > > additionalName1: value1 > > > > -------------------------------------------- > > > > Elliot Mebane > > Adobe Community Expert > > Principal, Zero G Games | ZeroGGames.com > > > > > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Aran Rhee > *Sent:* Tuesday, January 13, 2009 4:49 PM > *To:* [email protected] > *Subject:* RE: New Query String / FlashVars method -- gathers *all* query > string pairs with single method > > > > Sorry, yes, you are right about the formatting. > > > > In order to actually jump to an anchor on the page, you need the # at the > end, not the beginning. I was only thinking about getting it into Flash as a > variable (shows how much I am not a HTML centric dev). > > > > If you are using the anchor tag only as deep linking in your Flash file > (SWFAddress or otherwise) then it is not an issue. I guess also that most > swfaddress implementations use PHP etc to rewrite the deep links anyhow. You > end up with a URL which looks like: > > > > http://www.asual.com/swfaddress/samples/ajax/#/technologies/?param1=value1 > > > > In which case you are only dealing with the query string variables alone. > > > > > > Aran > > > > > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Geoff Stearns > *Sent:* Wednesday, 14 January 2009 11:19 AM > *To:* [email protected] > *Subject:* Re: New Query String / FlashVars method -- gathers *all* query > string pairs with single method > > > > I don't think your example is a valid url - it should actually be: > > example.com/?foo=bar#myanchor > > though I see how setting up links like that would be useful in some flash > apps. > > I'm not really sure what would be the best way to handle that - obviously > nobody cares so far that we leave the ? and # included in the return value, > or we'd have seen more complaints/requests about it :) so maybe we should > just leave it how it is? > > > > On Tue, Jan 13, 2009 at 4:08 PM, Aran Rhee <[email protected]> wrote: > > Fine by me (I think – 90% sure). > > > > > > I was just wondering if we wanted some special handling for the anchor tag. > > > > > #mydeeplink could some through to the swf as: anchor="mydeeplink" by > checking if the 1st char of the querysting is a "#" and then replacing > with a "anchor=". > > > > > > A user could also write their own js function to do this, but NOT if we > remove the # from the querystring automatically. If we change the address > of: > > > > some.html#mydeeplink?var1=foo&var2=bar > > > > To the value of "mydeeplink&var1=foo&var2=bar" from a call to > getQueryParamValue() then there is no chance to manipulate the querystring > anchor unless we somehow knew all of the anchor names we were using in the > page / app (unlikely / messy). > > > > > > Thoughts? > > > > Aran > > > > > > > > > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Geoff Stearns > *Sent:* Wednesday, 14 January 2009 10:31 AM > *To:* [email protected] > > > *Subject:* Re: New Query String / FlashVars method -- gathers *all* query > string pairs with single method > > > > Ok lets chop them off. > > As for non-name/value pairs, I'm not sure how those could be more properly > handled - If you were using a server side script to gather them, they would > show as existing, but not having a value, so I think leaving them set, but > with an undefined value is the proper thing to do, and let the user sort it > out in their swf/javascript. > > On Tue, Jan 13, 2009 at 3:15 PM, Aran Rhee <[email protected]> wrote: > > > Parsing ? and #: > > The swf does not parse out the ? or #, as can be seen in the test page: > > > http://www.misterhee.com/tests/params/params.flashvars.test2.html?var1=test& > abc=123<http://www.misterhee.com/tests/params/params.flashvars.test2.html?var1=test&abc=123> > > > http://www.misterhee.com/tests/params/params.flashvars.test2.html#adef-name- > A > > > I am unsure what you guys want to do about the anchor link. Do we really > even want that coming through? As an anchor does not have an associated > value (rather the anchor name IS the value), I am unsure as to the > usefulness of having it available. Basically you will have an undefined var > called whatever your anchor was named... > > > Combining data: > > As Bobby rightly says, you can combine the flashvars in the params object > and variables in the flashvars object AND variables from the swf > querystring > without overwriting! > > > http://www.misterhee.com/tests/params/params.flashvars.test3.html?var1=test& > abc=123<http://www.misterhee.com/tests/params/params.flashvars.test3.html?var1=test&abc=123> > > > Cheers, > > Aran > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > > Behalf Of Bobby > Sent: Wednesday, 14 January 2009 7:56 AM > To: SWFObject > Subject: Re: New Query String / FlashVars method -- gathers *all* query > string pairs with single method > > I think we should get rid of the ? and # anyway. > > Although unusual, the flashvars object and the params flashvars > notation can be mixed and matched, this is the code we currently have > in place: > > var par = {}; > if (parObj && typeof parObj > === OBJECT) { > for (var j in parObj) > { > par[j] = parObj > [j]; > } > } > if (flashvarsObj && typeof > flashvarsObj === OBJECT) { > for (var k in > flashvarsObj) { > if (typeof > par.flashvars != UNDEF) { > > par.flashvars += "&" + k + "=" + flashvarsObj[k]; > } > else { > > par.flashvars = k + "=" + flashvarsObj[k]; > } > } > } > > > > > > > > > > > > > > No virus found in this incoming message. > Checked by AVG. > Version: 7.5.552 / Virus Database: 270.10.6/1891 - Release Date: 1/13/2009 > 8:17 AM > > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.552 / Virus Database: 270.10.6/1891 - Release Date: 1/13/2009 > 8:17 AM > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/swfobject?hl=en -~----------~----~----~----~------~----~------~--~---
