1 Reply Latest reply on Oct 12, 2008 2:31 PM by g-s-b

    Passing args to a class

    SiHoop Level 1
      I want to create a class that will send any number of variables to a php file via an httpservice. As I don't know the number of arguments that I will pass, I will use ...args instead of naming the arguments. In addition to sending the values of the arguments, I would like to be able to send the names of the arguments to the php file. For example, instead of sending

      var params:Object = new Object();
      params.studentsClassListID = args[0];

      I'd like to be able to use something like:

      var params:Object = new Object();
      params.argumentName= args[0];

      Can I do this without also passing the argument name to the class?
        • 1. Passing args to a class
          g-s-b Level 1
          I would think that you'd be better off sending the "params" object as your argument. That way the caller will set what ever data is appropriate for that call. Like:

          HttpServiceExtender( resultsFunc, someUrl,
          { studentsClassListID:String( id_number), params_2:"some string", another:101.99 } );

          ...and change the signature to:

          public function HttpServiceExtender( resultEventHandler:Function, url:String, params:Object ){

          and delete this: var params:Object = new Object();