Adobe Flex 3 Help

Formatting and editing code

The Flex Builder editors provide shortcuts for writing and formatting your code. These include quickly adding comment blocks, indenting code blocks, finding, and replacing text.

Organizing import statements

When you use Content Assist in the MXML and ActionScript editors, the packages in which classes are located are automatically imported into the document. They are added in the order in which they were entered into code. Imports that are unused or unneeded are automatically removed.

To help organize the code in your ActionScript documents, you can alphabetically sort import statements. To do this, open the Preferences dialog, select Flex > Editors > ActionScript Code, and then select "Keep Imports Organized."

Sort import statements

 With an ActionScript document that contains import statements open in the editor, press Control+Shift+O (Windows) or Command+Shift+O (Mac OS).

Adding comments and comment blocks

You can quickly add or remove comments using keyboard shortcuts. You can add comments (//) and comment blocks (/* */) to ActionScript code. You can add XML comments (<!-- -->) and CDATA blocks to MXML code. Comments in ActionScript code can be toggled on or off.

Toggle comments in ActionScript code

  1. In the editor, select one or more lines of ActionScript code.
  2. Press Control+Shift+C (Windows) or Command+Shift+C (Mac OS) to add, or remove, C-style comments.
  3. Press Control+/ (Windows) or Command+/ (Mac OS) to add, or remove, C++ style comments.

Add XML comments in MXML code

  1. In the editor, select one or more lines of MXML code.
  2. Press Control+Shift+C (Windows) or Command+Shift+C (Mac OS) to add a comment.

Add CDATA blocks in MXML code

  1. In the editor, select one or more lines of MXML code.
  2. Press Control+Shift+D (Windows) or Command+Shift+D (Mac OS) to add a comment.

Manually indenting code blocks

The editor automatically formats the lines of your code as you enter it, improving readability and streamlining code writing. You can also use the Tab key to manually indent individual lines of code. If, however, you want to indent a block of code in a single action, you can use the Shift Right and Shift Left editor commands.

Shift a code block to the left or right

  1. In the editor, select a block of code.
  2. Select Source > Shift Right or Source > Shift Left.
  3. Press Tab or Shift Tab to indent or unindent blocks of code.

Set indent preferences

  1. Open the Preferences dialog and select Flex > Editors.
  2. Select the indent type (Tabs or Spaces) and specify the IndentSize and Tab Size. (For more information, see Setting editor preferences.)

Finding and replacing text in the editor

To find and optionally replace text strings in your code, there are two options. You can search the document that is currently open in the editor, or you can search all resources in the projects in the workspace. For more information about searching the entire workspace, see Finding references and refactoring code.

  1. Open the document to search.
  2. Do either of the following:
    • Press Control+F(Windows) or Command+F (Mac OS)
    • Select Edit > Find/Replace.
  3. Enter the text string to locate.
  4. (Optional) Enter the replacement text string.
  5. (Optional) Set the advanced search criteria.
  6. Click Find, Replace, Replace All, or Replace/Find.

    If the text string is located in the document, it is highlighted and, optionally, replaced.

Note: To do an incremental find, press Control+J (Windows) or Command+J (Mac OS).