i would be glad if anyone can answer this.
i have an actionscript class as follows:
package
{
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.core.UIComponent;
public class GridComponent extends UIComponent
{
private var _array:ArrayCollection;
public function GridComponent()
{
}
public function get array():ArrayCollection
{
return _array;
}
public function set array(value:ArrayCollection):void
{
_array = value;
Alert.show(value.length + "");
}
}
}
i invoke this from a mxml file; array variable is a array collection which is pre-populated with some data.
private var array:ArrayCollection = new ArrayCollection();
var person1:Person = new Person();
person1.id = 1;
person1.name = "pavzie1";
var person2:Person = new Person();
person2.id = 2;
person2.name = "pavzie2";
var person3:Person = new Person();
person3.id = 3;
person3.name = "pavzie3";
array.addItem(person1);
array.addItem(person2);
array.addItem(person3);
<local:GridComponent array="{array}">
</local:GridComponent>
Person is a pojo class with 2 instance variables id and name
the result is i get a length of 0. what could be wrong?? Also if i put a number instance variable with setters and getters , it binds the value correctly, so problem is only with binding of an array collection.