So the code that I have working is something like this:
var name:String = "Cashier";
var data:String = "Pay";
arr.push({name:tmpName, data:tmpData});
name, tmpName, data and tmpData are all variables. However this shows up as "name" and "data" being the key instead of "Cashier" and "Pay"
tmpName & tmpData are setting correctly, however.
Any help would be greatly appreciated.
You'll need to use square bracket notation for dynamically named keys:
var object:Object = {};
object[name] = tmpName;
object[data] = tmpData;
arr.push(object);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With