title: preloading a dynamically updated textfield?
body: <p>I'm making an ad that pulls the geolocation data from a viewer.  After the data is pulled, a textfeild is created and is filled with the city and state of the viewer. Everything works fine, but when the swf is loaded the geolocation data appears a tiny bit after the swf appears.  Is there any way to somehow pre-load the pulling of the data and creation of the geolocation filled textfield so that everything is displayed at the same time?  Here is the code:</p>
  
  <pre><code>import flash.filters.DropShadowFilter;
  // Sets text size to fit the largest it can in a specified textfield w/h
  TextField.prototype.shrinkToFit = function(iMinFontSize){
  
      var oFormat = this.getTextFormat();
      var iSize = oFormat.size;
  
      /* add an extra few pixels to text height to be sure (there seem to be some inherent margins)*/
      while(this.textHeight &gt; this._height || this.textWidth + oFormat.leftMargin + oFormat.rightMargin + 4 &gt; this._width){
  
          //Decrease fontsize on TextFormat and apply it to TextField again
          oFormat.size = --iSize;
          this.setTextFormat(oFormat);
  
          // break the loop if we've reached a specified minimum font size
          if(iMinFontSize != null &amp;&amp; iSize == iMinFontSize) {
              break;
          }
      }
  return iSize;
  };
  
  // Geolocation
  var info_xml = new XML();
  info_xml.ignoreWhite = true;
  info_xml.onData = function(raw:String)
     {
        if (raw == undefined)
           {
              this.onLoad(false);
           }
        else
           {
              // Normally onData would just do this:
              // this.parseXML(raw);
              // But we need to replace that with our own parsing:
  
              // This is the start of the fake XML string we are going to be making up.
              var parsed:String = "&lt;maxmind&gt;\n";        
  
              // Split each of the "function" lines into it's own string.  
              var lines:Array = raw.split("\n");
  
              // Remove the last one because that is a blank line.
              lines.pop();
  
              // Replace all the Regex functions from the external class since the Regex class does not exist in AS2.
              // All we're doing is chopping out two parts of each string and creating a fake XML node.
              // We cut the function name and make that into the XML node name, then we cut the returned value and set that to be the nodes "value".
              for(var i:Number = 0; i &lt; lines.length; i++)
                 {
                    parsed += "   &lt;" + lines[i].slice(9, lines[i].indexOf("()")) + " value=\"" + lines[i].slice(lines[i].indexOf("'") + 1, lines[i].lastIndexOf("'")) + "\" /&gt;\n";
                 }
  
              // Now parse the string into a true XML object.
              this.parseXML(parsed + "&lt;/maxmind&gt;");
  
              // Back to normal loading.
              this.loaded = true;
              this.onLoad(true);
           }
     }
  //If Geolocation is successful, fill the textfield with the city/state
  info_xml.onLoad = function(success:Boolean)
  {
      //Create textfield for geolocation data
      _root.createTextField("tf",1,105,225,141,15);
      _root.tf.border = false;
      //Expand on several lines if needed (set to true)
      _root.tf.multiline = false;
      _root.tf.wordWrap = false;
      _root.tf.autoSize = false;
      //Format text
      _root.tf.setNewTextFormat(new TextFormat("Arial", 40, 0xFFFFFF));
      _root.tf.embedFonts = true;
      _root.tf.selectable = false;
      var myShadow = new DropShadowFilter(1 , 45 , 0x000000 , 100 , 0 ,0 , .8 , 10 , false , false , false);
      _root.tf.filters = [myShadow];
  
      if (success) {
          //convert Geolocation xml data into an array
          var props:Array = this.firstChild.childNodes;
          _root.tf.text += props[2].attributes.value + ", " + props[3].attributes.value;
          trace("Font size shrinked to: " + tf.shrinkToFit());
      } else {
          tf.text += "There was a problem loading the remote file.\n";         
      }
  };
  
  info_xml.load('http://www.maxmind.com/app/geoip.js');
  
  
  
  var loop:Number = 0;
  </code></pre>
  
  <p>Then on the last frame, to loop the movie once with a 5 second pause inbetween:</p>
  
  <pre><code>stop();
  function myfunction() {
  clearInterval(myInterval);
  if (loop&gt;0) {
     stop();
  } else {
     loop++;
     gotoAndPlay(2);
  }
  }
  myInterval = setInterval(myfunction, 5000); 
  </code></pre>