# Hard: dynamic sendAndLoad to work from within a class?

**URL:** https://forum.kirupa.com/t/hard-dynamic-sendandload-to-work-from-within-a-class/213991
**Category:** flash
**Created:** [January 24, 2007, 8:13pm UTC](https://forum.kirupa.com/t/hard-dynamic-sendandload-to-work-from-within-a-class/213991 "2007-01-24T20:13:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DavidOrtiz](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@DavidOrtiz](https://forum.kirupa.com/u/DavidOrtiz)
#### Post date: [January 24, 2007, 8:13pm UTC](https://forum.kirupa.com/t/hard-dynamic-sendandload-to-work-from-within-a-class/213991/1 "2007-01-24T20:13:57Z")

</div>

my class has this function:

the thing is, the variables i want to send with my loadVars are dynamic. I want to be able to send any variable i want to the PHP script o my sendForm has to be able to set a variable and then a value to the variable.

however, when i trace sendForm.myName i get undefined and obviously the variables arent getting sent to the script. any ideas?

```auto

public function setScript(path:String, variables:Array){
      formBTN.onRelease=function(){
          var sendForm: LoadVars = new LoadVars();
 
          for(var i=0;i<variables.length;i++){
              sendForm.variable = variables*.getVariableName();
              set(sendForm.variable, variables*.getVariableValue());
          }
 
          sendForm.onLoad=function(success){
             if(success){
                variables[0].clearField();
                _root.temp.text=sendForm.phoneVar;
             }  
          };
 
 
          sendForm.sendAndLoad(path,sendForm,"POST");
    };
}

```
