Hello World

We're going to create our first swf (Flash9) application : a simple "Hello World".

Firstable create this haXe file HelloWorld.hx.
                    class HelloWorld {  
                        static function main() { 
                             // create a textfield       
                             var tf = new flash.text.TextField(); 

                             // initialize its text property with the following text
                             tf.text = "Hello World !"; 
                             
                             // add your new textfield on the scene
                             flash.Lib.current.addChild(tf); 
                        }
                    }
                


Now just compile your new class "HelloWorld" like following :

Either by creating an .HXML file (eg: compile.hxml) in wichi you'll write following commands :
                    # specify your main name class
                     -main HelloWorld 
                    # specify the compilation "flag" . In this example we want to generate an swf file.
                    # and add the name of your file you want to get at the compilation ("HelloWorld.swf")
                    -swf HelloWorld.swf

                    # if we wanted to specify the swf version
                    -swf-version 9
                

Open a terminal and write this command
haxe compile.hxml
or just double click on the file if you're on windows.


Or it's possible to compile in command line in a terminal :
haxe -main HelloWorld -swf HelloWorld.swf -swf-version 9
(58 times)