0
navigateToURL(new URLRequest("other.html"), "_self");

other.html has a swf embedded in it. Is there a way I can pass on variables to the swf embedded in other.html.

The reason is that I need to tell the swf if the user has logged in or not, and if he has logged in, pass it the user details. Feel free to suggest alternative methods that might me more efficient.

My entire website is made in flash.

Thanks

Joe Slater
  • 2,483
  • 6
  • 32
  • 49
  • really not trying to be condescending, but why are you making an entire website in flash? flash won't exist in a couple more years, everything it was used for has been replaced by HTML5/SVG/Canvas. you are only making your future-life more difficult writing a website in flash now. the other big problem is the biggest emerging internet market (Mobile), iPads/iPhones don't do flash, for all the reasons i already stated. you shouldn't be using it to build a site. at the most flash should only be used for a small non-essential widget, but even that should be javascript/HTML5 – G. Shearer Feb 22 '13 at 20:59
  • @G.Shearer I understand that, but I am doing a school project and not really a website that would be useful in any other way except for to get me good grades. And I felt comfortable with flash so I just used it. – Joe Slater Feb 22 '13 at 21:02
  • Flash still has a bright future in 3 areas: gaming, video and enterprise applications. Flash websites are dead though, i'll give you that ;) –  Feb 22 '13 at 21:10
  • A better solution would be to load the second swf into the first, rather than going to a new page - assuming thats an option for your project. –  Feb 22 '13 at 21:13
  • @LeeBurrows This is what I had initally thought but - http://stackoverflow.com/questions/14988407/loading-an-external-swf-dimensions-not-correct – Joe Slater Feb 22 '13 at 21:14
  • @AnkurSharma understood, well that is a valid reason, just don't use it in the real world (the web). Lee, not really, flash IS dead. FLEX is still very much alive. But that is about AS3 on a desktop and not Flash. Flash was meant for RIA, a need which has been filled more completely by HTML5 technologies. Javascript game engines (even on a wimpy mobile device) run as well or better than flash did at this point. And SMIL (HTML5 api for REAL timing, i.e. trigger something in EXACTLY 1.34542 secs from now) is more accurate and useful for things like gaming than flash ever was – G. Shearer Feb 22 '13 at 21:18
  • @Ankur I have posted a possible solution to your other question –  Feb 22 '13 at 21:26
  • @G.Shearer I have said my piece and stand by it. –  Feb 22 '13 at 21:28

1 Answers1

2

haven't written flash in a long time, but assuming that '+' is the string concatenation method...

for GET variables i would just do:

var url:String = "other.html";
url += "?someParam=someValue";
url += "&someOtherParam=someOtherValue";
navigateToURL(new URLRequest(url), "_self");

which is effectively making your url:

"other.html?someParam=someValue&someOtherParam=someOtherValue"

Edit:

something like this to actually grab the query vars...

function loaderComplete(myEvent:Event)
{
  var myQueryStrings=this.loaderInfo.parameters;
  var someParamValue:String=myQueryStrings.someParam;
}

this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
G. Shearer
  • 2,175
  • 17
  • 19
  • uhmm, and how would the swf access those values. sry i am a newb. – Joe Slater Feb 22 '13 at 20:57
  • appendText() is the method for concatenation btw – Joe Slater Feb 22 '13 at 21:03
  • appendText() is for text components. For Strings, use += to concatenate. –  Feb 22 '13 at 21:09
  • Not sure if I am missing something very obvious but I don't seem to recognize any way in which flash would be able to detect these variables. Do the variables have to go through php or xml or something of that sort or can I access them directly? Any tutorial links or examples would be appreciated. – Joe Slater Feb 22 '13 at 21:25
  • that code i just added would allow you to catch the variables after the swf finishes loading – G. Shearer Feb 22 '13 at 21:27
  • Value of someParam is null. I am putting `this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);` in the document class constructor method. Should I put it somewhere else? – Joe Slater Feb 22 '13 at 21:46
  • do you actually have a query param in your url called "someParam", i.e., did you use my example code exactly? I would just hand you some actual production code I have if I were still writing AS3 lol. Gotta go digging for that though – G. Shearer Feb 22 '13 at 22:01
  • what happens when you trace(this.loaderInfo.parameters) – G. Shearer Feb 22 '13 at 22:03
  • trace(this.loaderInfo.parameters) gives `[object Object]` – Joe Slater Feb 22 '13 at 22:08
  • Got it. This does not work with .html url, only with .swf. I just got it working by loading other.swf, instead of other.html. Do you know of any way to make it work in html url? – Joe Slater Feb 22 '13 at 22:33