0 Replies Latest reply on Jan 31, 2008 11:09 AM by Ratsnackbar

    Opinions wanted on loading Dynamic Classes

    Ratsnackbar Level 2
      I am injecting Classes into Containers using something similar to this code.

      private var myComponent:*;

      public function setCurrentEditor(_classPath:String):void{
      var myClass:Class = getDefinitionByName(_classPath) as Class;
      myComponent = new myClass();

      And I close out the container with something like this.

      public function closeThisWindow():void{
      this.myComponent = null;
      //remove this child from parent

      The closeThis() method runs code in the child to have it release all listeners and null all vars.

      Unfortunately this method of loading classes has a few side effects I do not desire. Such as having to have Variable instances for each class so that they do not get scrubbed by the compiler. (Anyone know an easy solution to that I would be happy to hear it.)

      My actual question though is if you do this is the Garbage collector going to be able to collect this or am I setting myself up for Memory Leaks? (Assuming of course that the Class loaded does not already have leaks of it's own.)