Run Action Script code in Flash application

Below is an example showing how to run action script code in Flash application. By default, Flash player doesn't know which function to call. In order to let it know, you simply have to set your function name to the creationComplete attribute in the <s:Application> tag. In the example below, it is creationComplete="main()".

<?xml version="1.0" encoding="utf-8"?>
<!--
Description: Show how to run action script in Flash application.
-->
<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 mx.controls.Text;
 
      public function main():void
      {
        // Create the "Hello World!" text.
        var oText:Text = new Text();
        oText.text="Hello World!";
 
        // Add the Text element in the screen.
        this.addElement(oText);
      }
    ]]>
  </fx:Script>
</s:Application>