try { var key:String; // This will contain the name of the parameter var val:String; // This will contain the value of the parameter var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters; for (key in flashvars) { val = String(flashvars[key]); mytextField.text = key+": "+val; } } catch (error:Error) { // what to do if an error occurs }
// Sending parameters function sendVariables(e:MouseEvent):void { // First we grab the URL of the HTML document and split it into an array var htmlUrl:String = ExternalInterface.call("window.location.href.toString"); // split the string at the questionmark var splitUrl:Array = htmlUrl.split("?"); // use only the first part (ditch existing parameters) var trimmedUrl:String = splitUrl[0]; // get the parameters we want to append to the URL var parameters:String = variablesToSend.text; // combine url and parameters with a new questionmark var requester:URLRequest = new URLRequest(trimmedUrl+"?"+parameters); // reload the page navigateToURL(requester, '_self'); }
// grab variables try { var key:String; var val:String; var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters; for (key in flashvars) { val = String(flashvars[key]); if(key == "item"){ // If the parameter is called 'item'... if(val.substr(0,4) == "item"){ // ... and the name of the button starts with the characters 'item'... // ... we can extract the number-part of the item-name and go to the correct frame var frameToGoTo:Number = Number( val.substr(4,1) ); gotoAndStop( frameToGoTo+1 ); } } } } catch (error:Error) { // what to do if an error occurs }
// Get the new page function gotoURL(e:MouseEvent):void { // First we grab the URL of the HTML document and split it into an array var htmlUrl:String = ExternalInterface.call("window.location.href.toString"); // split the string at the questionmark var splitUrl:Array = htmlUrl.split("?"); // use only the first part (ditch existing parameters) var trimmedUrl:String = splitUrl[0]; // get the name of the button clicked and set it as a parameter var parameters:String = "item="+e.currentTarget.name; // combine url and parameters with a new questionmark var requester:URLRequest = new URLRequest(trimmedUrl+"?"+parameters); // reload the page navigateToURL(requester, '_self'); }