I have flash application, which creates array and calls javascript function.
var jsParams = ["3011","3012","3013","3014","3015"];
ExternalInterface.call("doCall", jsParams);
And this is my javascript function:
function doCall(params) {
console.log(params);
console.log(params[0]);
}
The output in the firebug is:
["3011","3012","3013","3014","3015"]
[
But for the second line i was expecting 3011 and not [. Then i have tried to call same function with same params from firebug and the function outputed:
doCall(["3011","3012","3013","3014","3015"]);
["3011","3012","3013","3014","3015"]
3011
My question is how to pass params from actionscript to javascript as array and not as string value.
Thanks.
It looks like the params
variable is being passed in as a string, rather than an array.
Square bracket notation, when applied to a string, represents the character at the supplied index, which in this case would be the '[' (position 0).
You should look into JSON decoding to find a safe way to convert the string back into an array , I wouldn't recommend eval
, and JSON.decode
isn't widely supported.
have you tried encapsulating the array within another array?
ExternalInterface.call("doCall", [jsParams]);
I think a initial array is so you can pass mulitple sets of parameters
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.