Air

Important: there have been some major compatibility improvements for Air in version 2.1.0 - which, at the time of writing (2011/8/6) is still under development. This tutorial is meant to be followed using MegaZine3 version 2.1.0 or later. There will likely be issues with earlier versions.

This page will give very rudimentary step-by-step guide of how to get MegaZine3 running in an Air application.

= Step 1: create project = If you already have your Air project you can skip directly to step 2.

In Flash Builder, select "New->Flex Project". You will see a screen like this (sorry for the German):



Fill in the desired project name, mark it as an Air app ("Desktop" type) and click "Finish", unless you need to set more nuanced settings.

= Step 2: reference library = To work with MegaZine3 you'll need to reference the library in your project. The easiest way to do this is to simply place the megazine3-fat.swc file into you libs folder:



= Step 3: the code = In the versions after the release of version 2.1 there is now a wrapper component available. So when using the nightlies or 2.1.1+ you can do the following when using the fat SWC: And you're done! If you're not using the fat SWC you can even skip the script block and the addedToStage event.

The old way to add an instance to your App is to create an  in which you add an instance of MegaZine3. Assuming you have a blank application (new project), you'll modify it to something like this:

The important points are:
 * the script block, obviously. It creates a new instance, adds it to the container when the whole app becomes visible and takes care of resizing.
 * the container ( at the bottom), which will contain the book instance.

This will create a book with eight empty pages and the navigationbar plugin loaded.

= Step 4: using .mz3 files = You can still use .mz3 files. To do that, change the  to   and place the file plus your data files in the "src" folder of the project.

When using the wrapper component, you can simply supply it as a property:

= Known issues =
 * SWFs can be a pain in Air, because they are a potentially huge security issue. The current, hopefully relatively sensible default of MegaZine3 is to allow loading local SWFs via the built-in caching loader -- which puts them in the same "Domain" the engine is running in, and loading remote SWFs using the normal Flash Loader.
 * SWFTools' pdf2swf can generate pages that cause problems. This occurs, e.g., for pages with links. pdf2swf then embeds code that causes an error when executed in Air. As to my knowledge there is no way for the engine to catch that error, so it utterly breaks stuff. There is no workaround for this, yet.
 * See this and this entry in the swftools mailing list.