0 Replies Latest reply on Nov 11, 2008 7:23 PM by ice9_us

    Manage your childREN! and get some GINKO

    ice9_us Level 1
      as parents you have to have a good way to manage children..
      I found one... I came across it when a guy offered to help me out with learning/playing with some flex..

      first he had an issue with filling up arrays with data.. and making coppies and housing the data..
      that caused the memory to get eaten.. Sorry but even the mighty PC runs out of food for the hungry programmer :)

      I fixed this by getting new data.. dumping the data in my array.. and feeding it the new stuff...
      Not sure how everyone does it. but i simply...
      for ( ; arraystuff.pop() ; );

      if i add data to ...
      variable = event.result.....;
      <process to new data>
      for ( ; variable.pop() ; );

      that resolved the memory leak...
      In C/C++ there is a free(); function..... anyone know of something == in ActionScript?


      After I had corrected all this.. I found small bits of data getting eaten very very slowly...
      I noticed my friend was calling states and not removing the child..
      I even got some very very strange behavior... not sure if it is normal code/pratice.. but..
      he had a function that was basically...

      trace(ticketControlPanel);
      if (this.contains(ticketControlPanel)) {
      if ( ticketControlPanel != null ) {
      this.removeChild(ticketControlPanel);
      }
      }

      it worked.. but not everytime.... not sure why.. but sometimes the child was null
      sometimes it was ... myappIndex# sometimes something else..
      which is fine.. but when it showed just somename# and not myapp# i would get errors...

      to correct the issue i changed the above to:

      public function manageControl():void {
      if ( ticketControlPanel ) { << I would check to see if i had control panell
      if ( this.contains(ticketControlPanel ) ) { << if control panel was for me...
      if ( getChildIndex(ticketControlPanel)){ // check to see if i get the index...
      // This is where everything went nuts.. adding
      // the get index.. stopped the issues but only with this.(control)
      //if you remove this.. or that :?) it broke...
      removeChildAt(getChildIndex(ticketControlPanel));
      }
      }
      }


      if anyone knows of a better way.. i would like to know..
      thanks