Compiling

From MegaZine3
Jump to: navigation, search


There are multiple components of the engine that are compiled separately:

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


Contents

How to compile

It is recommended components are compiled using the mxmlc compiler which is part of the free Adobe Flex 3 SDK. An Apache Ant build file (build.xml) 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 C:/Program Files (x86)/Adobe/Flex 3 SDK. If your name of the folder is different, you must adjust the path in the ant/build.properties file (property flex3dir) in the megazine SVN download package accordingly: in ant/build.properties you'll see one line beginning with FLEX_HOME, 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 bin folder of Java to the PATH 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 bin folder to your PATH environment variable. Also create a environment variable named ANT_HOME and point it to the main folder (the one containing the bin 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 build.xml.

Enter ant, then press return to build everything.

Alternatively you can build specific parts only. Have a look at the ant/build.elements.xml and ant/build.plugins.xml files to find out the names of the targets. They follow a common pattern though:

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

Use the publish 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 assets folder) together into the publish folder. To do this, enter ant publish to also compile beforehand, ant publish.nocompile to skip compilation if you already did that anyway.

The resulting SWFs are put into the build folder.

OutOfMemoryError: PermGen space

When building everything in one go (which you'll do when just running ant 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.

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

Personal tools
Namespaces
Variants
Actions
Navigation
documentation
miscellaneous
Toolbox