Copy link to clipboard
Copied
Does anyone know how to set flashvars when running a movie in CS4 using Control->Test Movie? Under ActionScript 2 I could just set _root.flashVar, what's the equivalent in AS3?
Copy link to clipboard
Copied
When I'm testing flashvars locally I usually just set them to something manually in my code. Then remove it once I put it on the server.
//the name of my flashvar is myVar
var myVar;
myVar = "magic";
.
Copy link to clipboard
Copied
Hi Dan,
Thanks, but I'm not quite understanding what this solution is. Is the AS2 that you're thinking in terms of when you're posting this solution?
In AS3, the flashvar parameters don't appear as top level properties, they are found under "root.loaderInfo.parameters". So I can look up a parameter like this:
trace("myVar=" + root.loaderInfo.parameters.myVar);
I'd like to be able to do something like setting this parameter in my test code like this:
root.loaderInfo.parameters.myVar="test value";
...but this doesn't seem to work. No error message when I try this (either running "Test Movie" in CS4 or running in Flash Player in FireFox). Looking at the doc page for flash.display.LoaderInfo, it says that the "parameters" property is readonly.
I wish there were some kind of dialog in CS4 to allow me to set up flash vars for testing under Control->Test Movie, but if there is such a thing, I haven't found it yet!
- Bruce
Copy link to clipboard
Copied
Here's what I do:
myVar = "test value"
//myVar = root.loaderInfo.parameters.myVar
Then I use myVar as the variable in my code. When I'm ready to go live with it I remove the top line and uncomment the 2nd line. Make sense?
Copy link to clipboard
Copied
Here's what I do to prevent having to comment out code when going live, in this case I'm building a nav of some sort where the labels and links of the buttons in the nav are provided through flash vars:
var testFlashVarObj:Object = {
labels_1 : "1,2,3,4,5",
links_1 : "http://www.1.com,http://www.2.com,http://www.3.com,http://www.4.com,http://www.5.com,",
labels_2 : "1,2,3,4,5",
links_2 : "http://www.1.com,http://www.2.com,http://www.3.com,http://www.4.com,http://www.5.com,"
};
flashVarsObj = LoaderInfo(this.root.loaderInfo).parameters.labels_1 ? LoaderInfo(this.root.loaderInfo).parameters : testFlashVarObj;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more