title: Access to elements defined in MXML from External AS
body: <p>I have a MXML with a form, and inside it, two TextInputs. I hate having any piece of code inside the MXML file (I come from a JavaScript formation) so I use a </p>
  
  <pre><code>mx:Script source="external.as"
  </code></pre>
  
  <p>tag to include any code used in any MXML file. The problem is that if I have this code on the <code>external.as</code> file: </p>
  
  <pre><code>private function populateFromForm():void{
     var vo:ValidObject= new ValidObject();
     vo.market = marketInput.text;
     vo.segment = segmentInput.text;
     vo.priceLow = priceLowInput.text;
     vo.priceHigh = priceHighInput.text;
  }
  </code></pre>
  
  <p>Where marketInput, segmentInput, priceLowInput and priceHighInput are TextInputs defined in the MXML file. When I try to complile I get a <strong>1120: Access to undefined property XXXXX</strong></p>
  
  <p>I have tried adding this lines prior to the function:</p>
  
  <pre><code>public var marketInput:TextInput;
  public var segmentInput:TextInput;
  public var priceLowInput:TextInput;
  public var priceHighInput:TextInput;
  </code></pre>
  
  <p>But instead I get a <strong>1151:A conflict exists with definition XXXX in namespace internal</strong> which makes perfect sense.</p>
  
  <p>Is there a way to do this without having to pass all the input references to the function as parameters of it?</p>