ActionScript 3 - Hello World Application
The following is a simple "Hello World" application written in ActionScript 3, and compiled into a .swf using mxmlc complier.
Files required...
Greeter.as
HelloWorld.mxml
Compile these two files into...
HelloWorld.swf
Code for Greeter.as
package
{
public class Greeter
{
public function sayHello():String
{
var greeting:String;
greeting = "Hello World!";
return greeting;
}
}
}
Code for HelloWorld.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
layout="vertical"
creationComplete = "initApp()" >
<mx:Script>
<![CDATA[
private var myGreeter:Greeter = new Greeter();
public function initApp():void
{
// says hello
mainTxt.text = myGreeter.sayHello();
}
]]>
</mx:Script>
<mx:TextArea id = "mainTxt" width="400" />
</mx:Application>