To work with Flex and ActionScript projects, you need IntelliJ IDEA Ultimate with the Flash/Flex Support bundled plugin enabled.
Additionally, an Apache Flex SDK (previously known as Adobe Flex SDK) or a standalone Adobe AIR SDK must be installed on your computer. Note that a standalone AIR SDK can be used only for pure ActionScript projects while a Flex SDK is suitable for both Flex and pure AS projects because a Flex SDK installation includes an AIR SDK.
1. Create a new project
Click Create New Project on the IntelliJ IDEA welcome screen or select File | New Project.
On the first page of the New Project wizard:
- Specify the project name and location.
- Select Flash Module in the list in the left-hand pane.
- Expand the More Settings section and check the module name and content root:
- For a single-module project it is ok to keep the defaults: the module name the same as the project name, and the module content root coinciding with the project location.
- If you are going to add more modules to the project later, it would be a good idea to place the first of the modules in a subfolder (see the screenshot).
- Keep the module file location the same as that of the module content root.
- Keep the default project format: .idea (directory based).
2. Complete the New Project wizard
On the next (and last) page of the wizard, you are asked for initial settings for a Flash build configuration that belongs to the module you are creating. (All these settings can be changed later in the Project Structure dialog.)
The build configuration type is defined by 3 settings: Target platform (Web, Desktop or Mobile), Flex-dependent or pure ActionScript, and Output type (Application, Library or Runtime-loaded module).
If you don't have any Flex/AIR SDK configured in IntelliJ IDEA yet, click the ellipsis button [...] next to the Flex/AIR SDK combo.
In the Configure SDK dialog, click [+], select Flex/AIR SDK, and then select the location of the necessary Flex or AIR SDK.
IntelliJ IDEA will automatically pick all SWCs and source files included in the SDK.
Every time you configure a Flex or AIR SDK in the IDE, it is recommended that you set the online documentation URL for the SDK:
- Open the Documentation Paths tab.
- Click the Specify URL icon.
- Click OK to confirm the suggested URL.
To complete the wizard, click Finish.
3. Explore the project structure
The project has been created and is ready for use. Let's check its structure. Use File | Project Structure or the corresponding icon on the main toolbar to open the Project Structure dialog.
To see the modules of your project, select Modules in the leftmost pane. The project 'FlexProject1' includes one Flash module 'AppModule1'. This module contains one Flash build configuration which is also called 'AppModule1'.
Note that at the module level, you can configure only the content roots and source folders.
All Flash-specific settings are configured at the build configuration level. (Flash build configurations are shown as subnodes of a Flash module).
A Flash module can contain more than one build configuration. So you can build different apps using the same source base.
Each build configuration has its own type (target platform, Flex/pure AS, output type), main class, output folder, Flex/AIR SDK, compiler options, etc. For example, the build configuration shown on the screenshot can be used to generate a Flex application AppModule1.swf file that can be launched via an HTML wrapper.
Take a look at all the tabs to get an idea of the available options. The SDK used by the build configuration, for example, is configured on the Dependencies tab.
4. Add a build configuration
A Flash module can contain more than one build configuration so that you can build different apps from the same source base. For example, a module can contain 3 separate build configurations to compile a web-, desktop- and mobile-targeted app from the same sources.
Let's create another build configuration for the 'AppModule1' module. There are 2 ways of adding a build configuration to the module:
- Select the module in the Project Structure dialog, click [+], and select Flash build configuration.
- Select the existing Flash build configuration in the Project Structure dialog, and click the Copy icon.
The first of the ways is normally used to create a new build configuration from scratch. The second way clones an existing build configuration, so it is more convenient when you need to change only a few settings (e.g. the main class and the output file name).
In any case, at the next step, you need to give the new build configuration a name, and to specify its type: Target platform (Web, Desktop or Mobile), Flex-dependent or pure ActionScript, and Output type (Application, Library or Runtime-loaded module).
As a result, the build configuration is created, and you need to finish its configuration going through the tabs and tuning the required settings. In the following example, the new build configuration differs from the first one only in the main class and the output file name. The error highlighting for the main class name will disappear as soon as you close the Project Structure dialog and create a class with the corresponding name.
5. Add a new Flash module
To add a new Flash module to the existing project, click [+] in the Project Structure dialog and select New Module.
Then, you'll need to pass through the New Module wizard in the way similar to that described in the very beginning of this tutorial.