Compiling

There are multiple components of the engine that are compiled separately:
 * the engine core:
 * external elements:  and
 * plugins: e.g.  or
 * the preloader:

To compile a projector file (.exe / .app), see the tutorial "Building a projector".

= How to compile =

It is recommended components are compiled using the  compiler which is part of the free Adobe Flex 3 SDK. An Apache Ant build file can be found at the root level of each tag and the trunk itself. Once you have Ant up and running, you can just run it and it will compile everything in one go (except for the preloader, which has to be compiled using the Flash IDE, as it's a FLA file - reason is that vector graphics are used and it's much easier like this).

= Setting up =

Adobe Flex SDK
First get the Adobe Flex SDK containing mxmlc. It must be version 3, version 4 does not work (yet).

Unpack where you like. Unpack to. If your name of the folder is different, you must adjust the path in the  file (property flex3dir) in the megazine SVN download package accordingly: in   you'll see one line beginning with , adjust the Flex SDK path right to the   sign accordingly to where you extracted the SDK.

Apache Ant
Then get Apache Ant.

You'll also need Java to run Ant, so if you don't have it, get it now.

Windows users: you might have to add the  folder of Java to the   environment variable. Have a google at how to set environment variables in Windows if you need help for that.

Extract Ant wherever you like and add Ant's  folder to your   environment variable. Also create a environment variable named  and point it to the main folder (the one containing the   folder and the other stuff).

= Compiling =

Now, open a command prompt, and change the directory to where you checked out the SVN tag or trunk. It contains a file named.

Enter, then press return to build everything.

Alternatively you can build specific parts only. Have a look at the  and   files to find out the names of the targets. They follow a common pattern though:
 * engine:
 * elements:, e.g.
 * plugins:, e.g.

To just build the NavigationBar plugin, for example, enter  and press enter.

Use the  target, to wrap things up, i.e. copy the compiled SWFs together with the other files necessary, such as localization and GUI file (from the   folder) together into the   folder. To do this, enter  to also compile beforehand,   to skip compilation if you already did that anyway.

The resulting SWFs are put into the  folder.

OutOfMemoryError: PermGen space
When building everything in one go (which you'll do when just running  or using the build or publish targets), you'll most likely run into this error. To work around it you'll have to increase the maximum allowed memory used by ant and it's tasks.
 * Setting this in Eclipse
 * When using the ANT_OPTS environment variable, use
 * on Windows, you also can add  as first line into the apache_ant/bin/ant.bat file.
 * Note: Not sure what the minimum required memory is, but this works, so I didn't bother testing anything lower.

If increasing memory falls short, you can always instruct mxmlc to fork into a new VM during compilation. Please see the Apache Ant Java Task documentation for an explanation of the fork attribute (the mxmlc task extends the Java task). Basically, fork causes a new VM to be created for each mxmlc invocation. Without fork, they all run in the same VM.

= Compiling in Adobe FlashBuilder 4 =
 * Create a new "ActionScript project" and choose the folder with the existing MegaZine3 source code files
 * Choose  as Main application file in the creation dialog
 * After the project has been created open the project properties. Select "ActionScript Build Path", then the tab "Library path" and click the "ADD SWC Folder" button. Choose the folder  and click OK.
 * Only necessary, when you still have external files to be loaded: Still in the project property window select "ActionScript Compiler" on the left panel. On "Additional compiler arguments" add the compiler option . Otherwise the swf won't be able to load external files after it has been compiled.
 * If you don't want to generate the HTML code (just the plain swf), uncheck "Generate HTML wrapper file".
 * Close the project property window.
 * Place your  and assets in
 * Now you have to generate the  file which is responsible for including all external files within one swf later. This can easily be done by calling   from command line (you may have to install Python first and add Python to your path variable). Be sure to navigate to the tools-subdirectory first. Otherwise the Python-script won't find the assets-folder.
 * Before running the make_assets.py open it in an editor and make some adjustments. Around line 20 in the exclude array you can add or remove the subdirectories you want to have included in your compiled swf. For example, I have my pages as swf-files in a folder  and didn't want them to be included, so I added "pages" and removed "megazine.mz3" which I wanted to be included in the swf.
 * If you want to include the  file you have to tell flash what kind of mime type it is. To do so, look for the statement   around line 44 and add "mz3":  . Run   from the shell. If everything went ok it should exit without any further message.
 * Go back to Flash Builder and hit "Export Release build" in the toolbar or from the "project" menu item.
 * Hit "Finish" in the upcoming dialog and you're ready. The fat swf is now in the directory.
 * If you want to go further into debugging you can of course also hit the debug-button. The compiled client should start automatically and is located in /bin-debug.
 * If you have external files don't forget they have to be in the /bin-release resp. /bin-debug folders as well.