I was trying something out, and came across a little error. I wrote the following code to create an array and, using each value of that array, create an associative array for the values of xVelocity and yVelocity. Check it out:
var shrap:Array;
for (var i:uint = 0; i < 9; i++){ shrap* = "shrap" + i; var (shrap*):Object = new Object(); shrap*.yVelocity = Math.random() * 10 - 5; shrap*.xVelocity = Math.random() * 10 - 5;}
Once I got a conversion to string error, I also tried:
var shrap:Array;var iName:Array;
for (var i:uint = 0; i < 9; i++){ iName* = i.toString(); shrap* = "shrap" + iName; var (shrap*):Object = new Object(); shrap*.yVelocity = Math.random() * 10 - 5; shrap*.xVelocity = Math.random() * 10 - 5;}
But I get an error from that as well. I think I understand basically why this doesn’t work, but I’m wondering if, given the spirit of what I’m trying to do, you can think of a working alternative.
Thanks!