0 Replies Latest reply on Aug 24, 2007 12:45 PM by dgofman

    Pass arguments to class constructor

    dgofman
      Hello,
      Please who can help me to solve my problem? I dynamic creating class and I want to pass arguments.
      I know how can I do creating Function (apply), but I coulnd find constructor - apply.

      var c:Class = Class(getDefinition(className));
      var instance:Object;
      if(obj){
      var args:Array = deserialize(obj);
      if(args.length == 1)
      instance = new c(args[0]);
      else if(args.length == 2)
      instance = new c(args[0], args[1]);
      else if(args.length == 3)
      instance = new c(args[0], args[1], args[2]);
      else if(args.length == 4)
      instance = new c(args[0], args[1], args[2], args[3]);
      else if(args.length == 5)
      instance = new c(args[0], args[1], args[2], args[3], args[4]);
      else if(args.length == 6)
      instance = new c(args[0], args[1], args[2], args[3], args[4], args[5]);
      else if(args.length == 7)
      instance = new c(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
      else if(args.length == 8)
      instance = new c(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
      else
      return serialize("Unexpected number of arguments");
      }else{
      instance = new c();
      }