Code-behind gotcha in Flex Builder for AIR apps

If you're using code-behind in your AIR apps, there's a little gotcha you should watch out for: Flex Builder doesn't like it if you include your code behind class in the root package.

For example, if your main MXML file is Main.mxml and your code-behind class is MainClass.as, Flex Builder gets confused and thinks that there should be two application configuration files (one for the MXML file and one for the AS file.) If your app.xml file is named Main-app.xml, you'll get an error along the lines of Adobe AIR application is missing the corresponding MainClass-app.xml.

The workaround is simple, just move your code-behind class off of the root package. e.g., put it in com.mydomain.myapp.view.

Comments