Hey there. Im in the beginning stages of making a shopping cart, and I just have a container mc that has a dynamic text field for the name of the item (shirtname) and qty. (shirtnum). What Im trying to do is check if the container has already been made, and if so, just increase the qty by one.
Im having trouble accessing the qty text property of the container to update it…heres my code…
var itemnum:int = 0;
function cartadd (e:MouseEvent):void
{
if (itemnum >= 1)
{
con.shirtnum.text = itemnum.toString();
}
else
{
var con:itemcontainer = new itemcontainer();
con.shirttext.text = "hello";
con.name = "con" + itemnum;
itemnum += 1;
con.shirtnum.text = itemnum.toString();
addChild(con);
}
}
The problem is in the first part of the if, my reference is wrong to con.shirtnum.text and I get a
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I have also tried using getChildByName(“con0”).shirtnum.text = itemnum.toString(); in the beginning of my if statement.
Long story short, how do I access the shirtnum textfield once its been created?