Skip to main content
calmchessplayer
Inspiring
June 9, 2009
Question

removeChild help

  • June 9, 2009
  • 1 reply
  • 670 views

The function with the removeChild problem is ClearMsg.


I have a custom function that doesn't function correctly the first time the function executes it removes a textFiled from the display list without a problem but the second time that it executes it won't remove a second textfield and I don't know why here is the code from the time the textField is added to the diplay list to where its deleted.....Btw the function in question is being executed by a custom event listener.....the errors i receive are TypeError: Error #1009: Cannot access a property or method of a null object reference...Also note that i can remove the textField in question from any function other thatn the one the custom event executes....the custom event function is the problem....anybody have a solution?....also keep in mind that every go around the whole class is called again so all the  msgTa = newTextFeild are called repeatedly.

Plz let me know if you need furthur clarification.

sendBtn.addEventListener(MouseEvent.CLICK, sendMsg0,false,0,true);             msgOut.addEventListener(KeyboardEvent.KEY_DOWN, sendMsg1,false,0,true);             comboBox.addEventListener(Event.CHANGE,chFontSize,false,0,true);             call4.addEventListener("TYPE_UID", onUserID,false,0,true);             reconnect1.addEventListener("TYPE_CMSGTA", ClearMsg,false,0,true);                          msgTa.addEventListener(MouseEvent.MOUSE_WHEEL,Wheel,false,0,true);             msgTa.addEventListener(Event.SCROLL, scrolls,false,0,true);             scrollBar.addEventListener(MouseEvent.MOUSE_OVER,StopScroll,false,0,true);             scrollBar.addEventListener(MouseEvent.MOUSE_OUT,StartScroll,false,0,true);             msgTa.addEventListener(MouseEvent.MOUSE_OUT,StartScroll,false,0,true);             addEventListener(MouseEvent.CLICK,clickHandler);                                                 if ( rePublishID!=1&&rePublishID1!=2) {                 addChild(msgTaCon);                 msgTaCon.addChild(msgTa);                 insID=msgTa;                                               }             if (rePublishID1 ==1) {                 addChild(msgTaCon);                 msgTaCon.addChild(msgTa1);                 insID=msgTa1;                              } else if (rePublishID1 ==2) {                 addChild(msgTaCon);                 msgTaCon.addChild(msgTa);                 insID =msgTa;                              }                      }         private function ClearMsg(e:ClearMsgTa):void {                       if (e.num10[0]==1) {                     while( msgTaCon.numChildren > 0 )msgTaCon.removeChildAt( 0 );                     while( chatCon.numChildren > 0 )chatCon.removeChildAt( 0 );                     chatCon.parent.removeChild(chatCon);                     msgTaCon.parent.removeChild(msgTaCon);                     scrollBar.parent.removeChild(scrollBar);                     chatCon=null;                     msgTaCon =null;                     scrollBar=null;                                                       }                      if (e.num10[0]==2) {             msgTaCon.removeChild(msgTa1);             msgTaCon = null;         }     }
  calmchess is offline
This topic has been closed for replies.

1 reply

June 10, 2009

Sounds like you're trying to remove a display object that isn't there. Find out where it's causing it and run a simple trace before you remove it to make sure it's not null.

calmchessplayer
Inspiring
June 10, 2009

It is null inside the ClearMsg function outside it it isn't null that is the issue

June 10, 2009

Can I at least get some helpful or correct answer credit.