R – change the ‘Default Application’ class of AS3 projects in Flex Builder 3

actionscript-3apache-flexflex3flexbuilder

When creating an Actionscript Project in Flex builder 3 an application class is automatically created and dropped in the root of your source folder. In my case my source folder is called src/.

Is it possible to change the default application class to a class which is not directly in the root of the src folder? It seems when right-clicking on class files which are in sub packages the 'Set as Default Application' option is not selectable.

Is this done on purpose by Adobe to enforce all pure AS projects to have their application class residing in the top-most package?

Best Answer

You're going to have to make changes to the compiler's "source" directories. Doing this has worked for me in the past...

I'm assuming you're using a structure like this

> MyApp
  > html-template
  > main
    > MyApp.as
  > src

Where main is going to be the location of your default application?

  1. If you do this, right click on your top-level (in my example -- MyApp) or go to the FlexBuilder Menu and click on File and then Properties menu item.
  2. Go to the ActionScript Build Path property

    a. Change your main source folder to 'main'

    b. Then, click on the Add Folder...

    c. Add src, then click Ok

  3. Go to ActionScript Application -- here your runnable applications, and since you changed your main source folder, you might not see anything there.

    a. Add a link to your main/MyApp.as file

That should do it.