# Cannot access a property or method of a null object reference

**URL:** <https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/297753>\
**Category:** Uncategorized\
**Created:** [October 8, 2009, 12:41am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/297753 "2009-10-08T00:41:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ananda](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ananda](https://forum.kirupa.com/u/ananda)\
**Post date:** [October 8, 2009, 12:41am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/297753/1 "2009-10-08T00:41:02Z")

</div>

Hi all,

Im new with AS3 and had to do some editing of others code.

I have this code

```auto
private function editNumber():Boolean {
            Console.log("editPlayer - #" + _cNumber.caption.text + ". ");
            var result:Boolean;
            var warning:String;
            var existingPlayer:PlayerData;
            if(_cName.caption.text == "")
                warning = "a name";
            if (existingPlayer.xml.name == _cName.caption.text)
                warning = "a new name";
            if (_cNumber.caption.text == "")
                warning = !warning ? "a number" : warning + " and a number";
            if (!warning) {        
                Console.log(" - has a name and number");
                if (!numberFree()) {
                    Console.log(" - is being added with number");
                    updateData();
                    result = true;
                }
            } else {
                    alert("Your player needs "+warning+" to play.", "HOLD UP!");
            }
            return result;
        }

```

After success compiling, it gave me a runtime error: [COLOR=Red]\*\*\*Cannot access a property or method of a null object reference.  
Fault, editNumber() \*\*\*[/COLOR]

which is this code:

```auto
 if (existingPlayer.xml.name == _cName.caption.text)

```

Can anyone help me please?

Thanks
