Adobe Flex 3 Help

Advanced build options

Flex Builder has advanced options for customizing project builds. You can, for example, builds projects manually, change the default build order of projects in the workspace, and create custom builders using the Apache Ant utility.

Building projects manually

When you build projects manually, you can control the timing and scope of the build. For example, you can build a single project, all projects in the workspace, or create a working set of projects or selected project resources and build only those projects and resources. A working set is a collection of workspace resources (projects, files, and folders) that you can select and group together and work with as you see fit. For more information about working sets, see Creating working sets.

The build options are available in the Project menu, as shown in the following example:

Build a single project

  1. In the Flex Navigator view, select the project you want to build.
  2. Select Project > Build Project from the main menu.

    The selected project is built, and new or updated release and debug application files are added to the project output folder.

Note: If any of your project files need to be saved, you are prompted to do so before the build begins. To bypass this save prompt, you can set workspace preferences to save files automatically before a build begins.

Build all projects in the workspace

 Select Project > Build All from the main menu.

All projects in the workspace are built and application files are added to each project output folder. You are then prompted to save files if you have not already chosen to save files automatically before a build begins.

Build a working set

Do either of the following:

  • Select Project > Build Working Set > Select Working Set from the main menu. Click New to create a working set. For more information about creating a working set, see Creating working sets.
  • Choose an existing working set by selecting Project > Build Working Set > Select Working Set from the main menu.

All projects in the working set are built and the application files are added to the project output folder.

Saving project resources automatically

When you build your projects manually, you are prompted to save all resources before the build begins. To bypass this prompt, you can set workspace preferences to automatically save project resources.

  1. Open the Preferences dialog, select General > Workspace.
  2. Select the Save Automatically Before Build option.
  3. (Optional) You can modify how often resources are saved by entering a value (in minutes) in the Workspace Save Interval text box.

Performing a clean build

After a project has been built, subsequent builds affect only the resources that have been added or modified. To force the Flex Builder compiler to rebuild all resources in a project, you can perform a clean build. You might perform a clean build if, for example, you want to eliminate all potential sources of a problem you encountered when testing your application.

  1. Select Project > Clean from the main menu.
  2. Select the project (or projects) whose build files you want to discard and rebuild from scratch.
  3. Click OK.

Changing the project build order

Flex Builder lets you create relationships between projects when working with multiple projects in the workspace. For example, you can import ActionScript classes from one project into another. Creating relationships between projects affects the order in which your projects are built.

By default, the compiler builds related projects in the order required to build them all properly. For example, if a project refers to classes contained in another project, the project containing the classes is built first. In most cases, relying on the compiler to build projects in the proper order is sufficient and your applications will be generated successfully.

You can, however, change the build order. For example, you might change the build order if you created a custom Ant builder and associated it with a project in your workspace, and you need to build that project before other projects are built. For more information about creating custom builders, see Customizing builds with Apache Ant.

  1. Open the Preferences dialog and select General > Workspace > Build Order.

    The Build Order dialog box displays the following options:

    Use Default Build Order The default build order is dictated by the dependencies between projects and is handled by the compiler.

    Project Build Order You can manually set the build order for all the projects in the workspace. You can also remove a project from the build order list; it will still be built, but only after all the projects in the build order list.

    Max Iterations When Building With Cycles If your projects contain cyclic references (something you should avoid), you can set the number of build attempts so that the compiler can properly build all the projects. The default maximum number of iterations is 10.

  2. Modify the build order as needed, and click OK.

Customizing builds with Apache Ant

By creating a custom builder, you can modify and extend the standard build process. Flex Builder contains a standard build script that is used to compile your applications. If needed, you can create custom build scripts using Apache Ant, which is an open-source Java-based build tool.

While developing Ant build scripts is beyond the scope of this guide, this topic shows you how to create and apply a custom builder to your projects.

You can apply custom builders to all the Flex Builder project types.

Create a builder

  1. In the Flex Navigator view, select a project and then right-click (Control-click on Macintosh) to display the context menu and select Properties.
  2. Select the Builders properties page. If you're using other Eclipse plug-ins, there may be more than one builder listed. Flex Builder provides a builder named Flex, which you cannot modify.
  3. Select New.
  4. In the Choose Configuration Type dialog box, select the appropriate configuration type. Flex Builder supports the program type. Select it and click OK to continue. From the new builder properties page you define the builder properties and reference the Ant script (an XML file).
  5. Click OK to apply it to the project.

Detailed information about working with Ant build scripts can be found in the Eclipse documentation, which is available at http://help.eclipse.org/help31/index.jsp.

Using multiple SDKs in Flex Builder

%embedded%FlexSDKPreferencePage | Using multiple SDKs in Flex Builder

Flex Builder lets you change the version of the SDK that you use to compile your projects. You can select the SDK when you first create a project or at any time you are working on a project.

The combination of a framework and the compiler make up the SDK. If you select the Flex 2.0.1 SDK, then you are using the 2.0.1 version of the Flex framework SWC files, and the 2.0.1 version of the Flex compiler. You cannot use, for example, the Flex 3 compiler with the Flex 2.0.1 framework SWC files.

Using a different SDK can be useful if you are given a project that was developed using Flex Builder 2.0.1 (which uses the Flex 2.0.1 SDK), but you are running Flex Builder 3 (which uses the Flex 3 SDK by default). By selecting an older SDK to build with, you can maintain projects that have not been updated to be compatible with the latest version of the SDK. In addition, if you are currently working on a project for the Flex 2.0.1 SDK, but want to use the Flex Builder 3 features such as code refactoring, you can upgrade your edition of Flex Builder, but then select the older SDK as the default SDK.

If you develop a project and then change the SDK, Flex Builder performs a full rebuild, not an incremental build. As a result, Flex Builder flags any differences that would throw compiler errors as if the project had been developed under the original SDK. For example, if you use an AdvancedDataGrid component in your project (which was first introduced in the Flex 3 SDK), but then change the project to use the 2.0.1 SDK, Flex Builder will notify you that the AdvancedDataGrid class is unknown.

Flex Builder also regenerates all supporting files for the projects. These include the history management and deep linking files used by the HTML wrapper. For Flex 2.0.1 SDK projects, Flex Builder creates the Flex 2.0.1. SDK-compatible history.swf, history.html, and history.js history management files in the html-templates directory. For Flex 3 SDK projects, Flex Builder creates the Flex 3 SDK-compatible deep-linking history.htm, history.js. and historyFrame.html files in the html-templates/history directory.

In addition, the availability of Flex Builder options change depending on the selected SDK. For example, if you add a module to your project with a project that uses the Flex 2.0.1 SDK, Flex Builder does not let you select whether you want to optimize that module or not. You must do this manually.

For more information about the differences between the Flex 3 SDK and the Flex 2.0.1 SDK, see Backward compatibility in Building and Deploying Adobe Flex 3 Applications.

When you create a new Flex project, Flex Builder uses the default SDK. The default is the latest SDK that shipped with Flex Builder, but you can change it to any SDK that is visible in the list of available SDKs in Flex Builder.

When you create a new Flex library project or ActionScript project, you can select which SDK you want that project to use in the New Flex Library Project and New ActionScript Project dialog boxes.

Add a new Flex SDK to the list of available SDKs

  1. Open the Preferences dialog and select Flex > Installed Flex SDKs.

    The currently installed SDKs are listed. The default SDK has a check mark next to its name.

    Installed Flex SDKs dialog box.

  2. Click Add.

    Add Flex SDK dialog box.

  3. Enter the location of the SDK in the Flex SDK Location field.
  4. Enter a name for the SDK in the Flex SDK Name field. You should not use the name of an existing SDK for this field.
  5. Click OK to save your changes.
  6. Click OK again to add the new SDK to the list of available SDKs. This list is maintained in the Flex Builder workspace, across Flex projects. The next time you create a new project, the list of available SDKs includes this new SDK.

Change the SDK version for the current project

  1. Select Project > Properties.
  2. Select Flex Compiler.
  3. Click Use a Specific SDK.
  4. Select the SDK you want to use from the drop-down list. If the SDK you want to use is not in the drop-down list, click the Configure Flex SDKs link.
  5. Click OK.

    Flex Builder applies the new SDK to the current project. This can cause errors and warnings to appear if the project uses code that is not compatible with the new SDK.

Select a new default SDK

  1. Open the Preferences dialog, select Flex > Installed Flex SDKs.

    The default SDK has a check mark next to its name.

  2. Select the check box next to an SDK. This SDK becomes the default SDK. It is also applied to any project that has the Use Default SDK option selected in the Flex Compiler dialog box, including the current project. If the current project is set to use a specific SDK, then it will continue to use that specific SDK, even if you change the workspace's default SDK to a different one.
  3. Click OK to save your changes.
  4. Click OK again.

Using multiple SDKs in a server-based project

You can also change the SDK when compiling in a server-based environment. When you create a new server-based project, you are prompted either to compile the application locally or to compile the application on the server. If you choose the first option, to compile the application locally, Flex Builder uses the server's SDK. You can later change the SDK to a different one. If you choose the second option, to compile the application on the server, Flex Builder offloads the compilation to the server and uses the web-tier compiler to compile the project. In this case, you cannot change the SDK.