1 Reply Latest reply on May 17, 2007 11:29 PM by JViz

    Feature Requests

    JViz
      I apologize if i am double posting.

      My first request is a modifier keyword for import that will cause all of the classes in a package to be loaded into the SWF on compile whether or not they are actually used in the code. Since the existing method of weeding out imported classes is called "dynamic" you could probably use the static keyword. i.e.:
      import my.pack;
      static import my.pack2;
      Where "static" will force the classes to be compiled in.

      I don't know if there is already a way to do this, but I need a way to load an anonymous constructor properly. The biggest problem seems to be that I don't know how many arguments there are ahead of time because many classes don't use the ...(rest) notation and give an error:
      var cls:Class = flash.utils.getDefinitionByName(arguments[0]) as Class;
      var myObj:* = new cls( ???);
      If I could figure out the number of args, I could atleast build a small table with a reasonable number of args, like 5 to 10.
      ...
      if(cls.numConstructorArgs == 1){var myObj:* = new cls(args[0]);}
      if(cls.numConstructorArgs == 2){var myObj:* = new cls(args[0],args[1])}
      ...
      This seems a bit long winded for a very specific task though, perhaps there could be a function attached to the special var arguments that would take an array and do this task for me:
      var myObj:* = new cls(arguments.fromArray(args));
      or the ...(rest) notation could be used in the constructor call, perhaps only on untyped objects?:
      var myObj:* = new cls(...args);

      Thank you.
        • 1. Re: Feature Requests
          JViz Level 1
          I just realized I could use args.length to figure out how many args I'm supposed to pass:
          if(args.length == 3){var myObj:* = new cls(args[0],args[1],args[2])}
          It would still be nice to have a convenience method though.