# Shared Object issue in chat program

**URL:** <https://forum.kirupa.com/t/shared-object-issue-in-chat-program/314734>\
**Category:** flash\
**Created:** [October 7, 2010, 8:44am UTC](https://forum.kirupa.com/t/shared-object-issue-in-chat-program/314734 "2010-10-07T08:44:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glisando](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@glisando](https://forum.kirupa.com/u/glisando)\
**Post date:** [October 7, 2010, 8:44am UTC](https://forum.kirupa.com/t/shared-object-issue-in-chat-program/314734/1 "2010-10-07T08:44:57Z")

</div>

Hi Folks…

Posted this in another forum too. I have this set of codes for a simple chat program using SharedObjects. When I run the program, I type my name into the ‘chatName’ box and my message in the 'textInput’box. However when click on the ‘Send’ button or press the Enter key, I am getting the following error:

```auto
 
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TextChat/sendMsg()

```

As mentioned in the error message I looked at the ‘sendMsg()’ function. I realised the problem was comming from the line :

```auto
 
text_so.setProperty ("msg",chatName.text +": "+ textInput.text);

```

I am wondering how ‘text\_so’ can be a null object reference. It was already instantantiated and setup earlier in the code. I hope someone can shed light on this. The relevant lines of code are below. Thanks guys.

**Setting up of the shared object function**

```auto
 
private function doSO (e:NetStatusEvent):void
{
   good=e.info.code == "NetConnection.Connect.Success";
   if (good)
   {
    //Set up shared object
    text_so=SharedObject.getRemote("test",nc.uri,false);
    text_so.connect (nc);
    text_so.addEventListener (SyncEvent.SYNC,checkSO);
   }
}

```

**The ‘sendMsg’ function**

```auto
private function sendMsg (e:MouseEvent):void
{
   noName=(chatName.text=="<Enter Name>" || chatName.text=="");
   if (noName)
   {
    textArea.appendText ("You must enter your name 
");
   }
   else
   {
    text_so.setProperty ("msg",chatName.text +": "+ textInput.text);
    textArea.appendText (chatName.text +": "+textInput.text + "
");
    textInput.text="";
   }
}

```
