The following code randomizes the array "doors". It works fine if the array is strings. However,
if I remove the quotation marks, it traces "[object Symbol1_1]" instead.
var doors:Array = [red_button, blue_button,yellow_button];
var randomDoors:Array = new Array(doors.length);
var randomPos:Number = 0;
for (var i:int = 0; i < randomDoors.length; i++)
{
randomPos = int(Math.random() * doors.length);
randomDoors[i] = doors.splice(randomPos, 1)[0];
}
trace (randomDoors);
Tracing (randomDoors.name) returns the statement "undefined". How can I trace "doors" without converting the elements to strings?
Thanks for the reply, but I'm not sure what you mean by that.
I have tried tracing one element at a time with the ".name" appendix and that returns an element of the array without it being in strings.And as I said, if I just put quotation marks around the elements in the "doors" array, then the array works fine.
I'm just a little confused by which array you're talking about and how I should trace it?
the array class doesn't have a name property. when you use trace(randomDoors.name), you're asking flash to find the name property of that array.
so, either use:
for (var i:int = 0; i < randomDoors.length; i++)
{
trace(doors[i].name);
}
or create your own function or class to do what you want so you don't have to repeatedly create a for-loop to trace what you want.
North America
Europe, Middle East and Africa
Asia Pacific