Reputation: 2228
var myStr:String = root.loaderInfo.parameters.benny;
//this code will recieve single value from flashVars.
I want to know how to use LoaderInfo.parameters for handle more number of data?
Upvotes: 1
Views: 22713
Reputation:
The loader variables are captured by flash either by get variables inside the URL or by flashvars. You've got it exactly right, its key/value pairs. So basically if you had a URL like this:
http://somewhere.com/movie.swf?test1=10&test2=20&benny=benny
Inside flash you access these just like you've already been doing:
var numberString:String = root.loaderInfo.parameters.test1 as String;
var number:Number = root.loaderInfo.parameters.test2 as Number;
var uName:String = root.loaderInfo.parameters.benny as String;
If you were to trace out the above values, it will show:
trace(numberString); //10
trace(number); //20
trace(uName); //benny
Heres a link that describes doing the same thing using flashvars:
http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
Note I use the statement "as String" or "as Number" because by default the values are properties of an Object called "parameters." Doing what I'm doing above explicitly casts these values as the desired type, which is prudent for both optimal VM performance and just plain good coding practice.
Upvotes: 5
Reputation: 278
maybe this way :
var o : Object = root.loaderInfo.parameters;
var flashvars : Array = ['benny','test','etc'];
for(var fv : String in flashvars){
trace(o[fv]);
}
Upvotes: 0
Reputation: 3565
Do you mean that you want to know how to load multiple flashVars and read them in your application?
In that case, take a look here
Upvotes: 1