Q:

use instance names in array, #1010 error, as3

I want to use instances in an array, but get an error. How do I use instances in an array? Thanks.
Error 1010 'A term is undefined and has no properties'
//I'm trying to make two array objects disappear
var pink:Array = ["boxInstance1","boxInstance2"];
/*
THIS WORKS
boxInstance1.visible = false;
boxInstance2.visible = false;
*/
//THIS DON'T 'or with one instance in the array it works'
this[pink].visible = false;

A:

With one instance in array, flash converts the array into string and you get boxInstance1 as the value; with multiple values array gets converted as boxInstance1,boxInstance2 (possibly) and hence the error. Use the value at correct index using []
this[pink[0]].visible = false;
//equivalent to
boxInstance1.visible = false; 

this[pink[1]].visible = false;
//equivalent to
boxInstance2.visible = false; 

for(var i:Number = 0; i < pink.length; i++)
  this[pink[i]].visible = false;

