music_lp90 Posted September 19, 2008 Share Posted September 19, 2008 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 More sharing options...
justsomeguy Posted September 19, 2008 Share Posted September 19, 2008 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 More sharing options...
music_lp90 Posted September 19, 2008 Author Share Posted September 19, 2008 Thanks Justsomeguy, but it still doesn't seem to work. I tried checking what happens if I just go: var url = _url; and print that out in a textbox, but it just prints out "http://www.webtests.info/urlvariables.swf". It doesn't get the '?' or anything after it. Link to comment Share on other sites More sharing options...
shadowayex Posted September 20, 2008 Share Posted September 20, 2008 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 More sharing options...
music_lp90 Posted September 22, 2008 Author Share Posted September 22, 2008 Hey ragae, thanks, but I'm not actually using any php here right now. I do plan on using php once I get it to work, though. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 22, 2008 Share Posted September 22, 2008 Check the Flash help files to see how to get the URL or querystring variables. I'm sure there's a better way to do it now, most of the code I have is around the time of Flash 5 or 6. Link to comment Share on other sites More sharing options...
music_lp90 Posted September 22, 2008 Author Share Posted September 22, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.