title: How to set TextField width according to stage width? Actionscript 3, as3
body: <p>Can anyone tell me how to dynamically adjust the <em>width</em> of a <em>TextField</em> so that it's always a little less than the width of the stage? For example, this is what I've tried, but it raises an error:</p>
  
  <pre><code>var myText:TextField = new TextField();
      myText.x = 20; 
      myText.width = stage.stageWidth - 40; //does not work, what
  
  stage.addEventListener(Event.RESIZE, adjustTextField);
  
  function adjustTextField():void
  {
      myText.x = 20; 
      myText.width = stage.stageWidth - 40;
  }
  </code></pre>
  
  <p>In theory this code should ensure that <em>myText</em> is always adjusting to the full width of the stage with a 20 pixel border on both sides. But, this raises an error.</p>
  
  <p>Does anyone know a way to get fluid widths on TextFields in <strong>Actionscript 3</strong>?</p>