1 Reply Latest reply on May 5, 2006 5:52 AM by Newsgroup_User

    Dynamic creation of class at runtime

    steveanson
      I need to be able to dynamically create an instance of a class that isn't known until runtime - actually based on the filename

      so in my fla:
      var className:String="Test"; /* code to get a class name derived from the filename */
      var obj = new [className]();
      trace(obj);

      the code above only works if i put the literal directly in [ ]
      like so:
      var obj = new ["Test"]();

      is there a way to do this???
      Any help much appreciated
      cheers Steve

        • 1. Re: Dynamic creation of class at runtime
          Level 7
          This might help you out:

          http://dynamicflash.com/2005/03/class-finder/


          "steveanson" <webforumsuser@macromedia.com> wrote in message
          news:e3fcnv$6c7$1@forums.macromedia.com...
          > I need to be able to dynamically create an instance of a class that isn't
          known
          > until runtime - actually based on the filename
          >
          > so in my fla:
          > var className:String="Test"; /* code to get a class name derived from
          the
          > filename */
          > var obj = new ();
          > trace(obj);
          >
          > the code above only works if i put the literal directly in
          > like so:
          > var obj = new ();
          >
          > is there a way to do this???
          > Any help much appreciated
          > cheers Steve
          >
          >
          >