Can someone take a look at this sample code for me? It’s not working as expected so I think I’m missing out on some quirk:
class Sample {
public var property:Array
public function Sample():Void {
this.property = new Array();
}
public function addItem(item:Object):Void {
this.property.push(item);
}
}
var objArray = new Array();
// Where someArray is an array of objects
for (var i = 0;i<someArray.length;i++) {
var c = new Sample();
c.addItem(someArray*);
objArray.push(c);
}
The problem is that when I create the new classes, and add an object to it’s array property, it’s not storing them uniquely… in fact, in the example above, the objArray would hold 2 new Sample objects, storing only the last object in the array ‘someArray’… go figure?
My background is php/rails, and I like actionscript - but it’s a little confusing to me why the method addItem is showing me it is receiving unique objects, each object in objArray is unique, but the property for each object holds the same value, and not the unique objects it was passed in addItem???
Any help would be grand