Having issues passing a Javascript Array()
to Flash via FlashVars
. Can you assist in identifying the error in my setup?
javascript code
// custom array of user-defined cities
var usercities = new Array(
{'name':"London", 'latitude':51.5002, 'longitude':-0.1262 },
{'name':"NYC", 'latitude':51.5002, 'longitude':-0.1262 }
);
flashvars.newcities = usercities;
flash code
// pre-populated city array shown when no user data entered
var cities:Array = new Array(
{ name:"London", latitude:51.5002, longitude:-0.1262 },
{ name:"NYC", latitude:40.7144, longitude:-74.0060 }
);
// retrieve FlashVars
var newcities:Object = LoaderInfo(this.root.loaderInfo).parameters.newcities;
if(newcities != null) {
cities = newcities;
};
The current setup is not working as intended. It's crucial to keep the structure of the cities
array on the Flash end unchanged. Modifications can be made to the Javascript side.
Your assistance in resolving this matter is greatly appreciated.