2 Replies Latest reply on Mar 12, 2010 8:52 AM by jimmyoneshot

    Click Function Which Utilises AddItem Producing "Null Object Reference" Error

    jimmyoneshot Level 1

      In my app I have a bindable empty array collection and a click function I'd made which once activated I hoped would take values from several text boxes put them in variables I've made and then assign these variables to an item in an array collection using the addItem method. Instead once I assign this click function to a button and run the app when I click the button I get the error "Cannot access a property or method of a null object reference" and the item is not added to the array collection. The error is pointing to the line that contains the additem code but I can't see where I'm going wrong:-






      private var shoppingCartAC:ArrayCollection;



      public function addProduct():void



      var cartItemTitle:String = productName.text;


      var cartItemQuantity:Number = new Number(productQuantityEntry.value);


      var cartItemPrice:Number = new Number(productPrice.text);


      shoppingCartAC.addItem({itemName:cartItemTitle, itemQuantity:cartItemQuantity, itemPrice:cartItemPrice});