2 Replies Latest reply on Aug 24, 2009 7:18 AM by Augusto Esteves

    Adding an object to an ArrayCollection

    Augusto Esteves

      I've defined a simply user class as follows:


      ============ User.as ================

      package valueObjects


           import mx.collections.ArrayCollection;


           public class User




                public var devices:ArrayCollection;



                public function User(){







      Every user has a number of devices (another class I defined).


      [Bindable] private var mainUser:User = new User();


      var tempDevice:Device = new Device();


      I'm getting an error when I try to add a new device to the mainUser object. (Error #1009: Cannot access a property or method of a null)




      Is there a better way of doing this? What am I doing wrong?