Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-06-2008, 08:51 AM   PM User | #1
Lambneck
New Coder

 
Join Date: Apr 2008
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Lambneck is an unknown quantity at this point
flash media server - text chat

So I get this error when I test the following code:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TextChat/checkKey()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::TextInput/handleKeyDown()

Code:
package {
     import fl.controls.TextArea;
     import fl.controls.Button;
     import fl.controls.TextInput;
     import flash.display.Sprite;
     import flash.events.SyncEvent;
     import flash.events.NetStatusEvent;
     import flash.events.MouseEvent;
     import flash.events.FocusEvent;
     import flash.net.SharedObject;
     import flash.net.NetConnection;
     import fl.events.ComponentEvent;
     public class TextChat extends Sprite {
           private var button:Button;
           private var text_so:SharedObject;
           private var nc:NetConnection;
           private var textArea:TextArea;
           private var textInput:TextInput;
           private var chatName:TextInput;
           private var rtmpGo:String;
           private var good:Boolean;
           private var catchKey:Boolean;
           private var noName:Boolean;
           public function TextChat() {
                //Set up UIs
                textArea=new TextArea();
                textArea.setSize(500,280);
                textArea.move(20,54);
                addChild(textArea);
                textInput=new TextInput();
                textInput.setSize(500,24);
                textInput.move(20,340);
                textInput.addEventListener(Com ponentEvent.ENTER,checkKey);
                addChild(textInput);
                button=new Button();
                button.width=50;
                button.label="Send";
                button.move(20,370);
                button.addEventListener(MouseE vent.CLICK,sendMsg);
                addChild(button);
                chatName=new TextInput;
                chatName.setSize(100,24);
                chatName.move(80, 370);
                chatName.text="<Enter Name>";
                chatName.addEventListener(Focu sEvent.FOCUS_IN,cleanName);
                addChild(chatName);
                rtmpGo = "rtmp://192.168.0.11/basicSO";
                nc = new NetConnection( );
                nc .connect(rtmpGo);
                nc .addEventListener(NetStatusEvent.NET_STATUS,doSO);
           }
           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);
                 }
           }
           private function checkSO(e:SyncEvent):void {
                for (var chng:uint; chng<e.changeList.length; chng++) {
                      switch (e.changeList[chng].code) {
                           case "clear" :
                                 break;
                           case "success" :
                                 break;
                           case "change" :
                                 textArea.appendText(text_so.data.msg + "\n");
                                 break;
                      }
                 }
           }
           private function cleanName(e:FocusEvent):void {
                chatName.text="";
           }
           private function sendMsg(e:MouseEvent):void {
                noName=(chatName.text=="<En ter Name>" || chatName.text=="");
                if (noName) {
                      textArea.appendText("You must enter your name \n");
                } else {
                      text_so.setProperty("msg",chatName.text +": "+ textInput.text);
                      textArea.appendText(chatName.text +": "+textInput.text + "\n");
                      textInput.text="";
                 }
           }
           private function checkKey(e:ComponentEvent):void {
                noName=(chatName.text=="<En ter Name>" || chatName.text=="");
                if (noName) {
                      textArea.appendText("You must enter your name \n");
                } else {
                      text_so.setProperty("msg",chatName.text +": "+ textInput.text);
                      textArea.appendText(chatName.text +": "+textInput.text + "\n");
                      textInput.text="";
                 }
           }
     }
}
Lambneck is offline   Reply With Quote
Old 10-13-2008, 05:21 PM   PM User | #2
-Fabez-
New Coder

 
Join Date: Oct 2008
Location: Earth
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
-Fabez- is an unknown quantity at this point
Which line is the error in as the error code alone is not very helpfull.
-Fabez- is offline   Reply With Quote
Old 10-13-2008, 08:24 PM   PM User | #3
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Did you write this or buy it? Is there more to this besides this little snippet? Could you just zip the original FLA and post it so we can better test?

Also this is AS3...
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 04-27-2009, 03:02 PM   PM User | #4
fuji0000
New to the CF scene

 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
fuji0000 is an unknown quantity at this point
Influxis is a specialist hosting and support provider for applications using the Adobe Flash Media Server.

_________________
IP PBX
fuji0000 is offline   Reply With Quote
Reply

Bookmarks

Tags
chat, flash, media, server

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:23 PM.


Advertisement
Log in to turn off these ads.