Jump to content

I cannot get query string to work


music_lp90

Recommended Posts

Hi, I've tried many times to pass variables to flash from an html document, but I can't seem to get it. I think I'm following the Adobe tutorial step by step, but it doesn't work. Here's the actionscript:

this.createTextField("myTxt", 100, 0, 0, 100, 20);myTxt.autoSize = "left";if (_level0.myURL == undefined) {    myTxt.text = "myURL is not defined";} else {    myTxt.text = _level0.myURL;}

And here's the html where I try to pass the variable via querystring:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="urlvariables" align="middle">	<param name="allowScriptAccess" value="sameDomain" />	<param name="allowFullScreen" value="false" />	<param name="movie" value="urlvariables.swf?myURL=Hi" />    <param name="quality" value="high" />    <param name="bgcolor" value="#ffffff" />	    <embed src="urlvariables.swf?myURL=Hi" quality="high" bgcolor="#ffffff" width="550" height="400" name="urlvariables" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>

Any help would be GREATLY appreciated. Thanks!

Link to comment
Share on other sites

There might be a better way now, but we use this:

	var url = _url.split('?');	var parameters = url[1].split('&');	for(var i=0; i<parameters.length; i++)	{		var parameter = parameters[i].split('=');		if(parameter[0].toLowerCase() == "myURL") _root.myURL = unescape(parameter[1]);	}

Now _root.myURL will contain the value.

Link to comment
Share on other sites

I'm not too good in ActionScript, at all, but I would guess that it's not liking taking in PHP. You mean have to escape it, like you'd have to in PHP, or something like that. I don't know if I'm right or not, but it's an idea to provoke your thoughts.

Link to comment
Share on other sites

Hi justsomeguy, I have looked in the help files and the first example I showed was from the help file, but it's not working for me. I'll keep looking. Thanks for all of your help, though. I've learned so much from you. This seems like it should be a relatively simple thing to do, I don't know why I'm having such a hard time with it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...