Advanced code editing

Code templates

Code templates speed-up your coding efforts by letting you auto-insert frequently used coding patterns.

Flash Builder includes a number of predefined code templates. You can also define additional code templates for commonly used code patterns. To see all the available code templates, open the Preferences dialog box, and select Flash Builder > Editors > Code Templates.

MXML, ActionScript, and CSS code templates

The ActionScript, CSS, and MXML code templates are context-based and can be called on pressing Control+Space. You can use the pre-defined templates that are shipped with Flash Builder or you can create your own.

Insert code templates

To insert a code template in the code editor, type the name of the template in the code editor, and press Control+Space.

For example, when writing ActionScript code, say, you use the for loop repeatedly. You can then define a code template for the for loop as follows:
for (var i:int = 0; i < array.length; i++) { }
When you use a code template, you don’t have to type the complete code for the for loop. Instead, in the ActionScript class, type 'for' and press Control+Space. A template option to create the for loop appears. On selecting the code template, the code that you defined in the template is inserted.

Templates can also contain template variables. A template variable is defined within ${}. The variable is resolved based on the corresponding variable definition in the editor.

For example, if you define a code template for the for loop as follows:
for (var ${index}:int = 0; ${index} < ${array}.length; ${index}++) { ${cursor} }

And you invoke the code template after defining a variable myArr as follows:

{ 
    var myArr:ArrayCollection = null; 
}
Then, ${array} in the code template resolves to myArr, and the resulting code looks like:
{ 
    var myArr:ArrayCollection = null; 
    for (var ${index}:int = 0; ${index} < myArr.length; ${index}++) { ${cursor} } 
}

Create and edit code templates

  1. Open the Preferences dialog box, and select Flash Builder > Editors > Code Templates.

  2. Code templates are categorized as ActionScript, MXML, and CSS code templates. Under each category, you find a set of predefined code templates. You can edit an existing template or add a new one.

  3. To add a new template, select the code template category, and click Add. In the New Template dialog box, enter a name and brief description for the code template. Then, specify a context in which the code template must be called.

    You can specify contexts for ActionScript and MXML code templates.

    You can select from the following ActionScript contexts:

    • ActionScript: Inserts the code template anywhere in the ActionScript document

    • ActionScript statement: Inserts the code template within functions and within elements of a class

    • ActionScript members: Inserts the code template only within elements of a class

    • ActionScript Package Scope: Inserts the code template within a package, as follows:

      Package 
          { 
          /* insert code template*/ 
          }

    You can select from the following MXML contexts:

    • MXML: Inserts the code template anywhere in the MXML document

    • MX Component: Inserts the code template within MX components available for Flex 3 SDK

    • Spark Components: Inserts the code template within Spark components available for Flex 4 SDK or a higher SDK version

    • MXML attributes: Inserts the code template for MXML attributes within MX and Spark components.

  4. Enter the code for the template in the Pattern section. To insert variables in the code, click Insert Variable, and select from a list of predefined variables. The variables are contextual to the template category.

    ActionScript templates contain predefined variables that include array, enclosing_method, enclosing_package, enclosing_type, field, local_var, and var. MXML templates contain predefined variables that include fx, mx, s, and tag.

  5. If you don’t want Flash Builder to automatically insert the code template into your code, deselect the Automatically Insert Into Code option.

  6. To customize an existing code template, select the template, and click Edit. After editing the template, click OK.

    For more information about customizing file templates and template variables, see Customize file templates and Template variables.

    At any point, you can remove the custom template and restore the predefined code template by clicking Revert To Default.

By default, you can call all the predefined templates using Content Assist. If you, however, don’t want a specific template to appear in the Content Assist options, deselect that template in the Existing Templates section.

You can also import and export code templates. You can select one or more templates and export them. The templates are exported as an XML file.

Flash Builder code templates

Flash Builder can automatically generate predefined code in the following scenarios:

You can customize the predefined code template that Flash Builder generates.

Customize the code template

  1. Open the Preferences dialog box, and select Flash Builder > Editors > Code Templates > Flash Builder.

  2. Select the name of the code template that you want to customize, and click Edit. For example, to customize the code that is generated when you generate an event handler, select the event handler template, and click Edit.

  3. You can customize the name of the template, the description, and the code pattern.

  4. To insert a variable within the code, click Insert Variable, and select the variable. For more information about the available code variables, see Use code variables.

  5. At any point, you can discard the changes by clicking Revert To Default.

  6. You can also import and export the code template. You can select one or more templates and export them. The templates are exported as an XML file.

Use code variables

Code variables for event handlers

Variable

Description

Example

${component_id}

Resolves to the unique ID of the component.

If the ID of the button component is test, the event handler that is generated is test_clickHandler.

If you have not specified an ID value, the auto-generated values are component1, component2, and so on.

${component_name}

Resolves to the name of the tag.

${namespace} ${modifiers}function ${:method_name('${component_id}_${event_name}Handler')}(${event}:${event_type}):${return_type} 
{ 
    // TODO Auto-generated method stub 
    ${cursor} 
}

${event_name}

Specifies the name of the event.

clickEvent, onHover

${event_type}

Resolves to the event handler type.

Flash Builder designates a default event type for each user interface component.

On generating a click event for a button component, an event handler of type MouseEvent is generated as follows:

button1_clickHandler(event:MouseEvent)

${modifiers}

Specifies the modifiers for the generated function.

static

${method_name}

Resolves to the event handler name.

For a click event for the Button component, the event handler name can be button1_clickHandler

${namespace}

Defines the namespace value for the generated function.

The namespace value can be any of the following:
  • protected

  • public

  • private

The default value is protected.

Example using code variables for event handler functions:

${namespace} ${modifiers}function 
${:method_name('${component_id}_${event_name}Handler')} 
${event}:${event_type}):${return_type} 
    { 
        // TODO Auto-generated method stub 
    ${cursor} 
    }
Code variables for get and set accessor functions

Variable

Description

Example

${metadata}

Specifies the metadata tags that are generated

Generating get and set accessor functions for a Bindable variable

${asdoc}

Specifies the ASDoc that are generated for get and set accessor functions

${metadata} 
${asdoc}${namespace} ${modifiers}function get ${method_name}()${return_type} 
{ 
    return ${property}; 
}

${return_type}

Resolves to the variable type.

If the variable type is not specified, the generated get accessor function does not have a return type.

${metadata} 
${asdoc}${namespace} ${modifiers}function get ${method_name}()${return_type} 
{ 
    return ${property}; 
}

${property}}

Resolves to the property name in the getter/setter dialog.

For a variable var i:int, i resolves to _i

${argument_type}

Resolves to the data type of the generated set function.

 

Example using code variables for get and set accessor functions:

${asdoc} 
${namespace} ${modifiers}function set ${method_name}(value${argument_type}):void 
{ 
    if( ${property} !== value) 
        { 
            ${property} = value; 
            dispatchEvent(new Event("${event_name}")); 
        } 
}
Code variables for functions in an undefined class

Variable

Description

Example

${params}

For an undefined function that accepts a specified number of arguments, the generated function has the same number of arguments with the type.

 

Override or implement methods

Flash Builder provides you with an option to select and override parent class methods or implement interface methods.

  1. Open the Override/Implement Methods dialog box by selecting Override/Implement Methods from the Source menu. You can also select Source > Override/Implement Methods from the context menu of the MXML or ActionScript editor.

  2. The methods for each parent class are displayed in a tree structure format. For each class, you can select the methods that you want to override and the methods that you want to implement.

  3. You can select the insertion point to insert the selected methods. The default insertion point option depends on where you place your cursor in the editor while opening the Override/Implement Methods dialog box. The variable or method closest to the cursor location appears as an insertion point option.

    Flash Builder generates the stub code for the selected methods.

To customize the predefined stub code that Flash Builder generates, see Code templates.

Metadata code completion

Flash Builder displays code completion hints for metadata that you use in your MXML and ActionScript documents.

In an MXML document, metadata code hints are displayed within embedded <fx:Metadata> and <fx:Script> tags. In an ActionScript document, metadata code hints are also displayed for ActionScript language elements like class names, variables, getters, and setters.

The code hints are contextual to the MXML and ActionScript document, and the code in which the metadata is used. For example, when you invoke Content Assist within two blank lines of an ActionScript statement, code hints applicable to only that ActionScript statement appear. To see all the valid code hints applicable to the ActionScript or MXML document, press Control+Space multiple times to cycle through the available code hints.

Use metadata code completion in MXML documents

In an MXML document or class, you can use metadata code completion in the following ways:

  • Enter ’[’ within <fx:Metadata> tags, as follows:

    <fx:Metadata> 
        [ 
    </fx:Metadata>
  • Enter ’[’ within <fx:Script> tags, as follows:

    <fx:Script> 
        <![CDATA[ 
            [ 
        ]]> 
    </fx:Script>

Use metadata code completion in ActionScript documents

In an ActionScript document, you can use metadata code completion when you enter ’[’ before a class name, variable, getter, or setter, as follows:

[ 
    class GetSet 
    { 
        [ 
            private var privateProperty:String; 
            [ 
            public function get publicAccess():String 
            { 
                return privateProperty; 
            } 
            [ 
            public function set publicAccess(setValue:String):void 
            { 
                privateProperty = setValue; 
            } 
}

Code completion for custom metadata tags

Flash Builder supports code completion for custom metadata tags that are introduced on using third-party Flex frameworks.

To enable code hints for custom metadata tags in your project, you generate a SWC file containing a metadata.xml file, as follows:

  1. Create a library project. The New Flex Library Project wizard guides you through the steps, prompting you for the project name, location, and build path information. For more information, see Create Flex library projects.

  2. Add the metadata.xml file in the src folder under the root folder of your library project. Include all the metadata tags that you want in the metadata.xml file.

    Add the metadata.properties file (if any) in the appropriate locale folder. For example, locale/en_US or locale/ja_JP.

    For more information about metadata tags, see About metadata tags in the Flex documentation.

  3. Include the metadata.xml file in the library SWC file, as follows:

    1. Select Project > Properties > Flex Library Build Path.

      The metadata.xml file that you added appears in the Assets tab.

    2. Select the metadata.xml file to include in the SWC file, and click OK.

      The SWC file is compiled and generated in the output (bin) folder of the library project.

  4. Select the locale folder to which you added the metadata.properties file (if any).

  5. After generating the SWC file, add it to the build path of your project, as follows:

    1. Select Project > Properties > Flex Build Path.

    2. Click Add SWC.

    3. Enter or browse to the location of the SWC file, and click OK.

Once you add the SWC file to your build path, metadata code completion hints appear for the metadata tags defined in the metadata.xml file. You can share the SWC file between your applications or distribute to other developers.

Customize file templates

Flash Builder allows you to customize the default information contained in new MXML, ActionScript, and CSS files. Examples of information you can specify include variables for specifying author and date, variables for opening and closing tags and attributes, variables for various ActionScript declarations, namespace prefixes, and just about any content you want to include in a template file. File templates are especially useful for specifying introductory comments and copyright information.

The content of a new file is specified in a file template available from Preferences > Flash Builder > File Templates. Templates are available for the following types of files:

ActionScript

ActionScript file

ActionScript class

ActionScript interface

ActionScript skinnable component

MXML

MXML web application

MXML desktop application

MXML component

MXML module

MXML skin

ItemRenderer for Spark components

ItemRenderer for MX components

ItemRenderer for MX DataGrid

ItemRenderer for Advanced DataGrid

ItemRenderer for MX Tree

FlexUnit

FlexUnit TestCase class

FlexUnit TestSuite class

FlexUnit4 TestCase class

FlexUnit4 TestSuite class

CSS

CSS file

After modifying a template, you can export the template so it can be shared with other members of your team.

Modify a file template

  1. Select Preferences > Flash Builder > File Templates

  2. Expand the file categories and select a file template to modify.

  3. Select Edit and modify the template.

    You can type directly in the Template editor or select Variables to insert pre-defined data into the template.

  4. Click OK to save the changes.

    Changes apply to new files.

Export and Import File Templates

  1. Select Preferences > Flash Builder > File Templates

  2. Expand the file categories and select a file template.

  3. Select Export to export a template to the file system, or Import to import a previously exported template.

    Templates are exported as XML files.

Restore defaults

Note: Restoring defaults restores all file templates to the default values. You cannot restore a single template to the default value.

 To restore the default templates, open Preferences > Flash Builder > File Templates and select Restore Defaults

Template variables

Template variables for all file types

Variable

Description

Example

${date}

Current date

Feb 15, 2009

${year}

Current year

2009

${time}

Current time

3:15 PM

${file_name}

Name of the newly created file

HelloWorld.mxml

${project_name}

Name of the Flex or ActionScript project

Hello_World_Project

${user}

User name of the author

jdoe

$$

${dollar}

Dollar symbol

$

Template variables for MXML files

Variable

Description

Example

${application}

${component}

${module}

Specifies the application, component, or module MXML tag names.

For a web application, ${application} expands to “Application.”

For a desktop application, ${application} expands to “WindowedApplication.”

${component} expands to “Component.”

${module} expands to “Module.”

These tags are typically used to position the starting and closing tags of a file.

The following:

<${application} ${xmlns}${wizard_attributes}${min_size}> 
${wizard_tags} 
 
</${application}>

expands to:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"> 
<s:layout> 
    <s:BasicLayout/> 
</s:layout> 
 
</s:Application>

${xml_tag}

XML version

<?xml version="1.0" encoding="utf-8"?>

${xmlns}

Resolves to the namespace definition, based on the project's Flex SDK type and the namespace prefix defined in Preferences.

For a Flex 4 SDK project:

xmlns="http://ns.adobe.com/mxml/2009"

${min_size}

Minimum size of an MXML web application.

minWidth="1024" minHeight="768"

${ns_prefix}

Namespace prefix for the project’s Flex SDK.

You cannot change the default values for this variable.

For Flex 3: mx:

For Flex 4: fx:

${wizard_attributes}

Specifies the position of the attributes defined by the New File wizard.

For a new web application:

${application} ${xmlns}${wizard_attributes}>

expands to:

<Application xmlns="http://ns.adobe.com/mxml/2009" layout="vertical">

${wizard_tags}

Specifies the layout property for containers defined by the New File wizard

For a new application using Flex 4 SDK:

<s:layout>

<s:BasicLayout/>

</s:layout>

${fx}

Prefix for the MXML 2009 language document namespace. The perfix is as specified in the MXML document.

When you use the following Library tag template in an MXML document:

<${fx}Library> 
  <${fx}Definition id="${def}"> 
    ${cursor} 
  </${fx}Definition> 
</${fx}Library>

A library tag is created as follows:

<fxLibrary> <fxDefinition id="def"> </fxDefinition> </fxLibrary>

${mx}

Prefix for the MX document namespace. The prefix is as specified in the MXML document.

When you use the following Combobox template in the MX Components context:
<${mx}ComboBox id="${comboBox}" 
rowCount="${rowCount:values(5)}" 
dataProvider="${dataProvider}"/> 
${cursor}

A combobox is created as follows:

<mx:ComboBox id="comboBox" rowCount="5" dataProvider="dataProvider"/>

${s}

Prefix for the Spark document namespace

When you use the Spark Button template in the Spark Components context:
<${s}Button id="${btn}" 
label="${myButton}" 
click="${onClick}(${event})"/> 
${cursor}

A Spark button is created as follows:

<s:Button id="btn" 
label="myButton" 
click="onClick(event)"/>

${tag}

Fully-qualified tag name for the project’s MX components.

When you use the List template in the MXML context:

<${list:tag(mx.controls.List)} id="${myList}"> 
    <${dp:tag(dataProvider)}> 
        <${arraycollection:tag(mx.collections.ArrayCollection)}> 
            ${cursor} 
        </${arraycollection}> 
    </${dp}> 
</${list}>

A list is created as follows:

<s:List id="myList"> 
<s:dataProvider> 
<s:ArrayCollection> 
</s:ArrayCollection> 
</s:dataProvider> 
</s:List>
Template variables for ActionScript files

Variable

Description

Example

${package_declaration}

Generates the package declaration.

For a file in the com/samples package, generates:

package com.samples

${import_declaration}

For a new ActionScript class or ActionScript Interface, generates required import declarations .

For a subclass of TextBox, generates:

import flex.graphics.TextBox;

${interface_declaration}

For a new ActionScript interface, generates the interface declaration.

For a new Interface that extends IButton interface, generates:

public interface IMyButton extends IButton

${class_declaration}

For a new ActionScript class, generates the class declaration.

For a new subclass of CheckBox, generates:

public class MyCheckBox extends CheckBox

${class_body}

Generates all the required statements for a new class.

For a new subclass of Button that implements the IBorder interface, generates the following for the class body:

public function MyButton() {    super(); } public function get borderMetrics():EdgeMetrics {    return null; }

${interface_name}

${class_name}

${package_name}

Specifies the interface, class, or package name.

Typically used when generating comments.

For example, the following template specification:

/*  * ${class_name} implements. . .  */

generates the following code:

/*  * MyButton implements. . .  */

${array}

Specifies the value of an array

The following Fore template
for each (var ${index}:${type} in ${array}) { 
    ${line_selection} 
    ${cursor} 
}

iterates over the value of an array using enumeration as follows:

for each (var i:type in array) 
{ 
}

${enclosing_method}

Specifies the enclosing method's name

The traceMethod template traces the method as follows:
trace("${enclosing_type}.${enclosing_method} 
${enclosing_method_arguments})");

${enclosing_package}

Specifies the package name such as 'xx.yy' of 'xx.yy.class'

The package template creates a package as follows:
package ${enclosing_package} 
{ 
/** 
* @author ${user} 
*/ 
class ${enclosing_type} 
{ 
${cursor} 
}     
}

${enclosing_type}

Specifies the type name such as "class" of "xx.yy.class"

The package template creates a package specifying the class name as follows:
package ${enclosing_package} 
{ 
/** 
* @author ${user} 
*/ 
class ${enclosing_type} 
{ 
${cursor} 
}     
}

${field}

Specifies the class variables

The do template creates the do-while loop as follows:

 do 
    { 
    ${line_selection} 
    ${cursor} 
    } while (${condition:local_var(Boolean)});

${local_var}

Specifies the local variable visible within the block scope

if template creates an if statement as follows:

if (${condition:local_var(Boolean)}) 
{ 
    ${cursor} 
}

${var}

Specifies all the visible variables

fori template iterates over the value of an array as follows

for (var ${index}:int = 0; ${index} < ${array}.length; ${index}++) 
{ 
${cursor} 
}
Template variables for CSS files

Variable

Description

Example

${css_namespaces}

Defines namespaces for Spark and Halo style selectors.

Default values for Flex 3:

""

(In Flex 3, namespace declarations are not required in CSS files)

Default values for Flex 4:

@namespace s "library://ns.adobe.com/flex/spark"; 
@namespace mx "library://ns.adobe.com/flex/halo"; 

Template file examples

The following shows an example of an MXML Component file template, followed by a new MXML Component file generated from the template.

Example File Template for an MXML Component file

${xml_tag} 
<!-- 
* ADOBE SYSTEMS Confidential 
* 
* Copyright ${year}. All rights reserved. 
* 
* ${user} 
* ${project_name} 
* Created ${date} 
* 
--> 
<${component} ${xmlns}${wizard_attributes}> 
    ${wizard_tags} 
 
    <${ns_prefix}Script> 
    <![CDATA[ 
 
    ]]> 
    </${ns_prefix}Script> 
</${component}>

New MXML Component file generated from the example template

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
* ADOBE SYSTEMS Confidential 
* 
* Copyright 2009. All rights reserved. 
* 
* jdoe 
* FileTemplates 
* Created Jul 13, 2009 
* 
--> 
 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300"> 
    <s:layout> 
        <s:BasicLayout/> 
    </s:layout> 
     
    <fx:Script> 
        <![CDATA[ 
         
        ]]> 
    </fx:Script> 
</s:Group>

Generate from usage

Use Quick Assist to generate stub code for an undefined method, variable, or class in your code. The generated stub code can be used as a placeholder for the code that you want to implement later without rendering your code incompatible. To customize the predefined stub code that Flash Builder generates, see Code templates.

To invoke Quick Assist, you can use the keyboard shortcut Control+1(Windows) or Command+1 (Mac OS).

Use Quick Assist to generate stub code in the relevant class or MXML script block by selecting any of the following actions:

Generate Method
Creates a method

For example, if you have code as follows:

private function genFunc():void 
{  
bar(); 
}
Place your cursor anywhere in the line of code containing bar(); and press Control+1. An option to create a function appears. On selecting this option, a new function is generated as follows:
private function bar():void{}

You can also generate a function for an undefined function in a referenced class. For example, if you have an undefined function "setValue()" in the referenced class "MyClass", as follows:

MyClass cls = new MyClass(); 
cls.setValue(5);

Place your cursor anywhere in the line of code containing "setValue" and press Control+1. An option to create a function appears. On selecting this option, a new function setValue(int) is generated in the referenced "MyClass" as follows:

 private function setValue(param0:int):void 
{ 
    // TODO Auto Generated method stub 
}

Generate Variable
Creates a property
For example, if you have code, where, i is an undefined variable, as follows:
public function MyClass 
{ 
        i; 
}
Place your cursor anywhere in the line of code containing i; and press Control+1. You get options to create a local variable or a field.
Selecting the option to create a local variable, creates the variable as follows:
var i:Object;

Selecting the option to create a field, creates a class-level variable as follows:

private var i:Object;

You can also generate a property for an undefined variable in a referenced class. For example, if you have an undefined variable "aValue" in the referenced class "MyClass", as follows:

MyClass cls = new MyClass(); 
cls.aValue = "str"; 

Place your cursor anywhere in the line of code containing aValue, press Control+1, and select Create Field Variable. A property aValue of type string is generated in the referenced "MyClass" as follows:

private var aValue:String;

Generate Class/Interface
Creates a class or interface
For example, if you have code, where Foo is undefined, as follows:
public function myFunction():Foo; 
    { 
    }
Place your cursor anywhere in the line of code containing Foo; and press Control+1. Options to create a class or interface named Foo appear. Select one of these options to open either the New ActionScript Class wizard or New ActionScript Interface wizard. Enter the necessary details and click Finish. After clicking Finish, a class or interface with the name Foo is created.

When you generate a new class, you can create an ActionScript class with a parametrized constructor.

For example, if you have code like the following:

Private function func(): void { 
    New NewClass("str1"); 
}

Place your cursor anywhere in the line of code containing NewClass("str1"), press Control+1, and select Create Class. An ActionScript class with a parametrized constructor is created. If you, however, specify a superclass for the ActionScript class, then a parameterized constructor is not generated.

Adobe Community Professional, Paul Robertson, blogged about using Quick Assist for external classes and interfaces.

Generate Event Handler
Generates event handler functions

For example, if you have code like the following:

public function MyClass 
    { 
        Var button:Button = new Button(); 
        button.addEventListener(DragEvent.DRAG,dragHandlerFunction); 
    }

Place your cursor anywhere in the line of code containing dragHandlerFunction, and press Control+1. Then, select the Quick Assist option to create the event handler. The event handler function is created as follows:

protected function dragHandlerFunction (event:DragEvent):void 
{ 
}

Generate Import Statement From Usage
Creates an import statement

For example, if you have code where the variable type Button is undefined, as follows:

<fx:Script> 
    <![CDATA[ 
        var btn:Button; 
    ]]> 
</fx:Script>

Place your cursor anywhere in the line of code containing var btn:Button, and press Control+1. You get an option to import Button if a class named Button is available in the project. The import statement is created as follows:

import spark.components.Button;

You can generate import statements for function arguments, function return types, and such.

Generate get and set accessor functions

Get and set accessor functions (getters and setters) let you keep class properties private to the class. They allow users of the class to access those properties as if they were accessing a class variable (rather than calling a class method).

Flash Builder can generate ActionScript get and set accessor functions for class variables. You can select a bindable property and generate get and set accessor functions for that property. You can also specify a custom event name at the time of generating code.

How to generate get or set accessor functions

  1. With an ActionScript file open in the Source Editor, place the cursor on a class variable.

  2. Select Source > Generate Getter/Setter from either the Flash Builder menu or the context menu.

  3. In the Generate Getter/Setter dialog, specify details for the accessor functions and click OK.

    Note: To view the code that is generated, select Preview before clicking OK.

To customize the predefined code that Flash Builder generates, see Code templates.

When you generate getters and setters, Flash Builder provides the following options:

  • Make the class variable private.

    Typically, class variables have private access.

  • Rename the class variable, suggesting a leading underscore for the variable name.

    By convention, private class variables have a leading underscore.

  • Rename the accessor functions.

  • Specify a bindable property and a custom event name.

    When you specify a bindable property, a [Bindable] tag is defined above the generated accessor function in the generated code.

  • Specify whether to generate both getter and setter accessor functions.

  • Specify the namespace value for the accessor function.

  • Specify the placement of the accessor function in any of the following locations:

    • Before the first method

    • After the last method

    • Before variable declarations

  • Preview the code that is generated.

For more information about get and set accessor functions, see Get and set accessor methods in the ActionScript 3.0 Reference for the Adobe Flash Platform.