Flash The Ripper

Life Around Technology

haXe: installation and creation of your first Flash application with haXe compiler

haXe is universal high level programming language and its free compiler. haXe lets you create applications fir such platforms as JavaScript, Flash Player 6-8, Flash Player 9 (ActionScript 3) and Neko. Author of this technology is Nicolas Cannasse, the creator of the fastest flash compiler MTASC (now you’ve got a feeling about quality of haXe). Learn more about haXe.

To install haXe compiler (for Windows users):

  1. Go to haXe download page and download installation file.
  2. Unpack. Start haxesetup.exe. Installation goes on in best guerrilla tradition, without unnecessary buzz. One second — and you see the message about succesful installation.
  3. Reboot your machine (to enable PATH variables, added at the previous step).

To create your first Flash application using haXe compiler:

  1. Create test class file ‘Text.hx’ containing the following code (haXe source files have ‘*.hx’ extension):
    class Test {
        static function main() {
            trace("Hello World !");
        }
    }
  2. Create compile.hxml file (‘*.hxml’ files are used to tell compilation directives to haXe compiler) with the following code:
    -swf test.swf
    -main Test
  3. Double-click compile.hxml file to open it.
  4. Compiled ‘test.swf’ file will appear in the same folder. You can open it to see the result!

???? embed compiled swf file into web page, use standard html code for embedding flash files (test.html file):

<html>
<head><title>haXe Flash</title></head>
<body bgcolor=”#dddddd”>
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″
width=”400″
height=”300″
id=”haxe”
align=”middle”>
<param name=”movie” value=”test.swf”/>
<param name=”allowScriptAccess” value=”always” />
<param name=”quality” value=”high” />
<param name=”scale” value=”noscale” />
<param name=”salign” value=”lt” />
<param name=”bgcolor” value=”#ffffff”/>
<embed src=”test.swf”
bgcolor=”#ffffff”
width=”400″
height=”300″
name=”haxe”
quality=”high”
align=”middle”
allowScriptAccess=”always”
type=”application/x-shockwave-flash”
pluginspage=”http://www.macromedia.com/go/getflashplayer”
/>
</object>
</body>
</html>

Have good day with haXe!

These instructions is the compilation of the haXe Usage, haXe downloads and Getting Started with haXe/Flash pages.

For further studying and using haXe visit the last link and other haXe tutorials, for example, haXe for Flash9 as replacement of ActionScrpt 3.

Something is not clear? Don’t hesitate to ask here or in the haXe mailing list.