Wait for a certain time before doing something

<?xml version="1.0" encoding="utf-8"?>
<!-- Description: Use setTimeout() to wait for a certain time before doing something.
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
         creationComplete="main()"
         >
  <fx:Script>
    <![CDATA[
      import flash.utils.setTimeout;
      import mx.controls.Text;
 
      public function main():void
      {
        var iWaitTime:int = 15000; // Wait time  in milliseconds
 
        // Create the "Hello World!" text.
        var oText:Text = new Text();
        oText.text="The 'Hello World' will be displayed in "+iWaitTime/1000+" seconds.";
 
        // Add the Text element in the screen.
        this.addElement(oText);
 
        // Call doSomething() after waiting for 15 seconds.
        setTimeout(doSomething, iWaitTime);
 
      }
 
      public function doSomething():void
      {
        // Display the following text.
        var oText:Text = new Text();
        oText.text="After waiting for 15 seconds, I'm displaying this. Done!";
        oText.setStyle("color", "red");
        oText.y = 15;
 
        // Add the Text element in the screen.
        this.addElement(oText);               
      }
    ]]>
  </fx:Script>
</s:Application>