ignitionMX
01-27-2009, 06:49 PM
The problem I am currently having right now is the inability to send variables loaded from the LoaderSWF to the SWF that has been loaded.
Concretely speaking, I have an embed script on an HTML page that contains several variables in the FlashVars line. The embed script loads a file called loader.swf. Loader.swf's main responsibility is basically take those variables from the flashvar, load the game URL and pass along the rest of the necessary parameters to the game that the loader is loading. However, I've been working out several solutions and none of them worked the way I wanted to.
The embed script is as follows:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="450" id="game-player">
<param name="movie" value="/shockwaves/loader.swf" />
<param name="play" value="true" />
<param name="menu" value="false" />
<param name="quality" value="best" />
<param name="flashvars" value="game_url=<%= game.shockwave.url %>&score_url=<%= scores_url(:game_id => game.id) %>&authenticity_token=<%= form_authenticity_token() %>" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/shockwaves/loader.swf" width="550" height="450">
<param name="play" value="true" />
<param name="menu" value="false" />
<param name="quality" value="best" />
<param name="flashvars" value="game_url=<%= game.shockwave.url %>&score_url=<%= scores_url(:game_id => game.id) %>&authenticity_token=<%= form_authenticity_token() %>" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
The code for loader.swf is as follows:
stop();
var myLoader:Loader = new Loader();
addChild(myLoader);
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var gameUrl:String = String(paramObj["game_url"]) + "?" + Math.random()*10000;
var scoreUrl:String = String(paramObj["score_url"]);
var authToken:String = String(paramObj["authenticity_token"]);
//var gameUrlWithParams:String = gameUrl + "?score_url=" + scoreUrl + "&" + "authenticity_token=" + authToken;
var url:URLRequest = new URLRequest(gameUrl);
var variables:URLVariables = new URLVariables();
variables.score_url = scoreUrl;
variables.authenticity_token = authToken;
url.data = variables;
myLoader.load(url);
The question is, how can I load the game SWF file and send along additional parameters with that request? Is there someway I can punch in variables into the myLoader object?
The code I came up with sends along the authenticity token just fine, however, it is not sending score_url correctly. I'm not sure if that is the correct behavior, but please enlighten me with any insights you may have.
I have also considered trying LocalConnection, but the problem is that I do not have the necessary source code for the games to set up LocalConnection on the receiving end.
Also, the game files are using AS2, while the loader is using AS3. The game files read variables by utilizing _root.score_url, etc.
Any help will be greatly appreciated!
Thanks! -- Leon
Concretely speaking, I have an embed script on an HTML page that contains several variables in the FlashVars line. The embed script loads a file called loader.swf. Loader.swf's main responsibility is basically take those variables from the flashvar, load the game URL and pass along the rest of the necessary parameters to the game that the loader is loading. However, I've been working out several solutions and none of them worked the way I wanted to.
The embed script is as follows:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="450" id="game-player">
<param name="movie" value="/shockwaves/loader.swf" />
<param name="play" value="true" />
<param name="menu" value="false" />
<param name="quality" value="best" />
<param name="flashvars" value="game_url=<%= game.shockwave.url %>&score_url=<%= scores_url(:game_id => game.id) %>&authenticity_token=<%= form_authenticity_token() %>" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/shockwaves/loader.swf" width="550" height="450">
<param name="play" value="true" />
<param name="menu" value="false" />
<param name="quality" value="best" />
<param name="flashvars" value="game_url=<%= game.shockwave.url %>&score_url=<%= scores_url(:game_id => game.id) %>&authenticity_token=<%= form_authenticity_token() %>" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
The code for loader.swf is as follows:
stop();
var myLoader:Loader = new Loader();
addChild(myLoader);
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var gameUrl:String = String(paramObj["game_url"]) + "?" + Math.random()*10000;
var scoreUrl:String = String(paramObj["score_url"]);
var authToken:String = String(paramObj["authenticity_token"]);
//var gameUrlWithParams:String = gameUrl + "?score_url=" + scoreUrl + "&" + "authenticity_token=" + authToken;
var url:URLRequest = new URLRequest(gameUrl);
var variables:URLVariables = new URLVariables();
variables.score_url = scoreUrl;
variables.authenticity_token = authToken;
url.data = variables;
myLoader.load(url);
The question is, how can I load the game SWF file and send along additional parameters with that request? Is there someway I can punch in variables into the myLoader object?
The code I came up with sends along the authenticity token just fine, however, it is not sending score_url correctly. I'm not sure if that is the correct behavior, but please enlighten me with any insights you may have.
I have also considered trying LocalConnection, but the problem is that I do not have the necessary source code for the games to set up LocalConnection on the receiving end.
Also, the game files are using AS2, while the loader is using AS3. The game files read variables by utilizing _root.score_url, etc.
Any help will be greatly appreciated!
Thanks! -- Leon