# Accessing property of previously created MC?

**URL:** <https://forum.kirupa.com/t/accessing-property-of-previously-created-mc/275299>\
**Category:** flash\
**Created:** [November 12, 2008, 7:05am UTC](https://forum.kirupa.com/t/accessing-property-of-previously-created-mc/275299 "2008-11-12T07:05:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aeroshock](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@aeroshock](https://forum.kirupa.com/u/aeroshock)\
**Post date:** [November 12, 2008, 7:05am UTC](https://forum.kirupa.com/t/accessing-property-of-previously-created-mc/275299/1 "2008-11-12T07:05:30Z")

</div>

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…

```auto
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?
