Hi all,

I have a problem where I am creating objects in a loop. I have the problem
that when setting instance properties, the properties of the previous object
assigned to the variable are also affected! Is the following valid syntax?

Cheers,
Pea

// Define objects and variables
var aObjectLibrary : myObjectLibrary = new myObjectLibrary();
var aObject : myObjectType;
var maxi, i;

// Assign some values to put in custom objects
var values = new Array();
values[0] = new Array(2,3,4);
values[1] = new Array(5,6,7);

for (i=0; i<2; i++){
// Create new myObjectType
aObject = new myObjectType;
// Assign values to object
aObject.valueArray = values[i];
// Add object to object library
aObjectLibrary.addObject( aObject );
}
// My object library should now contain 2 objects. Each object
// contains an array calles valueArray which has been set by
// the values stored in the 'values' array.
// When I attempt to trace the contents of the arrays stored
// in each array (valueArray) I only get the array put in to the
// object that was created last:
trace(aObjectLibrary.objects[0].valueArray); // returns 5,6,7
trace(aObjectLibrary.objects[1].valueArray); // returns 5,6,7