Re: [Flashcoders] Passing params via url instead of FlashVars
I can't remember where I picked this up but this is a class that handles querystrings in as3: usage: var qs:QueryString = new QueryString(); trace( qs.parameters.id ); HTH Christoffer package your.namespace.here { import flash.external.*; import flash.utils.*; /** * Access the query string of the html page this flash is embedded in. */ public class QueryString { private var _queryString:String; private var _all:String; private var _params:Object; public function get queryString():String { return _queryString; } public function get url():String { return _all; } public function get parameters():Object { return _params; } public function QueryString() { readQueryString(); } private function readQueryString():void { _params = {}; 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 { 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("Some error occured. ExternalInterface doesn't work in Standalone player."); } } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Passing params via url instead of FlashVars
You could Javascript then... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: maandag 25 augustus 2008 16:31 To: Flash Coders List Subject: RE: [Flashcoders] Passing params via url instead of FlashVars Yes, html only. :-( -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Bailey Sent: Monday, August 25, 2008 10:18 AM To: Flash Coders List Subject: Re: [Flashcoders] Passing params via url instead of FlashVars Are you restricted to using HTML? Could you use something like PHP? If you could, it'd be quite trivial. Steve -- Original message -- From: "Mendelsohn, Michael" <[EMAIL PROTECTED]> > Hi list... > > Anyone have a recommendation for passing params into a swf via the url instead > of FlashVars? > > I need to send out an email link like so: > > Clickhere.html?a=1 > Clickhere.html?a=2 > > Would it be easier to just send links to two different html pages, each with > different Flash Vars? The idea I had was to simply have one swf. > > Thanks, > - Michael M. > > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Passing params via url instead of FlashVars
Very cool Jer. I never looked into swfObject enough to realize it had functions. Thanks! - MM ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Passing params via url instead of FlashVars
If you're using swfobject, as I believe they have a getQueryParamValue("variable1") method. var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699"); so.addVariable("variable1", getQueryParamValue("variable1")); so.addVariable("variable2", getQueryParamValue("variable2")); so.write("flashcontent"); If not there is a way to get the URL from JavaScript, by parsing out the variables in window.location.href. Copying random code found in google, but here's *a* solution. function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } On Mon, Aug 25, 2008 at 9:30 AM, Mendelsohn, Michael <[EMAIL PROTECTED]> wrote: > Yes, html only. :-( > > -Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Steve > Bailey > Sent: Monday, August 25, 2008 10:18 AM > To: Flash Coders List > Subject: Re: [Flashcoders] Passing params via url instead of FlashVars > > Are you restricted to using HTML? Could you use something like PHP? If > you could, it'd be quite trivial. > > Steve > > -- Original message -- > From: "Mendelsohn, Michael" <[EMAIL PROTECTED]> >> Hi list... >> >> Anyone have a recommendation for passing params into a swf via the url > instead >> of FlashVars? >> >> I need to send out an email link like so: >> >> Clickhere.html?a=1 >> Clickhere.html?a=2 >> >> Would it be easier to just send links to two different html pages, > each with >> different Flash Vars? The idea I had was to simply have one swf. >> >> Thanks, >> - Michael M. >> >> >> >> >> ___ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Jer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Passing params via url instead of FlashVars
Yes, html only. :-( -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Bailey Sent: Monday, August 25, 2008 10:18 AM To: Flash Coders List Subject: Re: [Flashcoders] Passing params via url instead of FlashVars Are you restricted to using HTML? Could you use something like PHP? If you could, it'd be quite trivial. Steve -- Original message -- From: "Mendelsohn, Michael" <[EMAIL PROTECTED]> > Hi list... > > Anyone have a recommendation for passing params into a swf via the url instead > of FlashVars? > > I need to send out an email link like so: > > Clickhere.html?a=1 > Clickhere.html?a=2 > > Would it be easier to just send links to two different html pages, each with > different Flash Vars? The idea I had was to simply have one swf. > > Thanks, > - Michael M. > > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Passing params via url instead of FlashVars
Use a serverside script like PHP -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: maandag 25 augustus 2008 16:04 To: Flash Coders List Subject: [Flashcoders] Passing params via url instead of FlashVars Hi list... Anyone have a recommendation for passing params into a swf via the url instead of FlashVars? I need to send out an email link like so: Clickhere.html?a=1 Clickhere.html?a=2 Would it be easier to just send links to two different html pages, each with different Flash Vars? The idea I had was to simply have one swf. Thanks, - Michael M. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Passing params via url instead of FlashVars
Are you restricted to using HTML? Could you use something like PHP? If you could, it'd be quite trivial. Steve -- Original message -- From: "Mendelsohn, Michael" <[EMAIL PROTECTED]> > Hi list... > > Anyone have a recommendation for passing params into a swf via the url > instead > of FlashVars? > > I need to send out an email link like so: > > Clickhere.html?a=1 > Clickhere.html?a=2 > > Would it be easier to just send links to two different html pages, each with > different Flash Vars? The idea I had was to simply have one swf. > > Thanks, > - Michael M. > > > > > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Passing params via url instead of FlashVars
Hi list... Anyone have a recommendation for passing params into a swf via the url instead of FlashVars? I need to send out an email link like so: Clickhere.html?a=1 Clickhere.html?a=2 Would it be easier to just send links to two different html pages, each with different Flash Vars? The idea I had was to simply have one swf. Thanks, - Michael M. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders