Ant tasks

The Flex Ant tasks provide a convenient way to build your Flex projects using an industry-standard build management tool. If you are already using Ant projects to build Flex applications, you can use the Flex Ant tasks to replace your exec or java commands that invoke the mxmlc and compc compilers. If you are not yet using Ant to build your Flex applications, you can take advantage of these custom tasks to quickly and easily set up complex build processes for your Flex applications.

The Ant tasks for Flex include two compiler tasks, mxmlc and compc. You can use these to compile Flex applications, modules, and component libraries. In addition, the Ant tasks include the html-wrapper task that lets you generate custom HTML wrappers and the supporting files for those wrappers, and an asdoc Ant task to generate ASDoc documentation.

Tip: The mxmlc and compc Ant tasks extend the java Ant task. As a result, you can use all the available attributes of the java Ant task in those Ant tasks. This includes fork, maxmemory, and classpath .
Related information
The Apache Ant Project

Setting up Flex Ant tasks

Installing the Flex Ant tasks is a simple process. You copy the flexTasks.jar file from sdk_install/ant/lib. to Ant's lib directory.

Copy the flexTasks.jar file to Ant's lib directory (ant_root/lib). If you do not copy this file to Ant's lib directory, you must specify it by using Ant's -lib option on the command line when you make a project.

Using Flex Ant tasks

You can use the Flex Ant tasks in your existing projects or create new Ant projects that use them. There are three tasks that you can use in your Ant projects:

  • mxmlc — Invokes the application compiler. You use this compiler to compile applications, modules, resource modules, and CSS SWF files.

  • compc — Invokes the component compiler. You use this compiler to compile SWC files and Runtime Shared Libraries (RSLs).

  • html-wrapper — Generates the HTML wrapper and supporting files for your application. By using this task, you can select the type of wrapper (with and without deep linking support, with and without Express Install, and with and without Player detection), as well as specify application settings such as the height, width, and background color.

  • asdoc — Generates ASDoc output for the specified classes in your project.

To use the custom Flex Ant tasks in your Ant projects, you must add the flexTasks.jar file to your project's lib directory, and then point to that JAR file in the taskdef task. A taskdef task adds a new set of task definitions to your current project. You use it to add task definitions that are not part of the default Ant installation. In this case, you use the taskdef task to add the mxmlc, compc, and html-wrapper task definitions to your Ant installation. In addition, for most projects you set the value of the FLEX_HOME variable so that Ant can find your flex-config.xml file and so that you can add the frameworks directory to your source path.

Use the Flex tasks in Ant:

  1. Add a new taskdef task to your project. In this task, specify the flexTasks.tasks file as the resource, and point to the flexTasks.jar file for the classpath. For example:

     <taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar"/>
  2. Define the FLEX_HOME and APP_ROOT properties. Use these properties to point to your Flex SDK's root directory and application's root directory. Although not required, creating properties for these directories is a common practice because you will probably use them several times in your Ant tasks. For example:

     <property name="FLEX_HOME" value="C:/flex/sdk"/> 
     <property name="APP_ROOT" value="myApps"/>
  3. Write a target that uses the Flex Ant tasks. The following example defines the main target that uses the mxmlc task to compile the Main.mxml file:

     <target name="main"> 
     	<mxmlc file="${APP_ROOT}/Main.mxml" keep-generated-actionscript="true"> 
     		<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> 
     		<source-path path-element="${FLEX_HOME}/frameworks"/> 
     	</mxmlc> 
     </target>

    The following shows the complete example:

     <?xml version="1.0" encoding="utf-8"?> 
     <!-- mySimpleBuild.xml --> 
     <project name="My App Builder" basedir="."> 
     	<taskdef resource="flexTasks.tasks" 
    		classpath="${basedir}/flexTasks/lib/flexTasks.jar"/> 
     	<property name="FLEX_HOME" value="C:/flex/sdk"/> 
     	<property name="APP_ROOT" value="myApp"/> 
     	<target name="main"> 
     		<mxmlc file="${APP_ROOT}/Main.mxml" keep-generated-actionscript="true"> 
     			<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> 
     			<source-path path-element="${FLEX_HOME}/frameworks"/> 
     		</mxmlc> 
     	</target> 
     </project>

    This example shows how to use different types of options for the mxmlc task. You can specify the value of the keep-generated-actionscript option as an attribute of the mxmlc task's tag because it does not take any child tags. To specify the values of the load-config and source-path options, you create child tags of the mxmlc task's tag. For more information on using options, see Working with compiler options.

  4. Execute the Ant project, as shown in the following example:

     > ant -buildfile mySimpleBuild.xml main

    If you did not copy the flexTasks.jar file to Ant's lib directory as described in Installation, you must include the JAR file by using Ant's -lib option. For example:

     > ant -lib c:/ant/lib/flexTasks.jar -buildfile mySimpleBuild.xml main

The output of these commands should be similar to the following:

 Buildfile: mySimpleBuild.xml 
 main: 
 	[mxmlc] Loading configuration file C:\flex\sdk\frameworks\flex-config.xml 
 	[mxmlc] C:\myfiles\flex4\ant_tests\apps\Main.swf (150035 bytes) 
 BUILD SUCCESSFUL 
 Total time: 10 seconds 
 >

To embed fonts in your Flex ant tasks, you must be sure to include the font manager in your build file.

Working with compiler options

The compc and mxmlc compilers share a very similar set of options. As a result, the behavior of the mxmlc and compc Ant tasks are similar as well.

You can specify options for the mxmlc and compc Flex tasks in a number of ways:

  • Task attributes

  • Single argument options

  • Multiple argument options

  • Nested elements

  • Implicit FileSets

Task attributes

The simplest method of specifying options for the Flex Ant tasks is to specify the name and value of command-line options as a task attribute. In the following example, the file and keep-generated-actionscript options are specified as attributes of the mxmlc task:

 <mxmlc file="${APP_ROOT}/Main.mxml" keep-generated-actionscript="true">

Many mxmlc and compc options have aliases (alternative shorter names). The Flex Ant tasks support all documented aliases for these options.

Single argument options

Many compiler options must specify the value of one or more parameters. For example, the load-config option takes a parameter named filename.

To specify the option in an Ant task, you add a child tag with that option as the tag name. You set the values of the arguments by including an attribute in the tag whose name is the option name and whose value is the value of the argument.

The following example sets the values of the load-config and source-path options, which have arguments named filename and path-element respectively:

 <mxmlc ... > 
 	<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> 
 	<source-path path-element="${FLEX_HOME}/frameworks"/> 
 </mxmlc>

The source-path option can take more than one path-element parameter. For more information, see Repeatable options.

You can see which options take parameters by looking at the mxmlc command-line syntax. In the Flex bin directory, enter the following command:

 mxmlc -help list advanced

The output includes all options for the mxmlc compiler. The syntax for the load-config option appears like the following:

 -load-config <filename>

This indicates that the load-config option takes a single argument called filename.

Multiple argument options

Some compiler options, such as the default-size option, take more than one argument. The default-size option takes a height and a width argument. You set the values of options that take multiple arguments by using a nested element of the same name, with the attributes of the element corresponding to the arguments of the option as shown in the command-line compiler's online help.

For example, the online help for mxmlc shows the following syntax for the default-size option:

 -default-size <width> <height>

To pass the option -default-size 800 600 to the mxmlc task, use the following syntax:

 <mxmlc ...> 
 	<default-size width="800" height="600"/> 
 </mxmlc>

Repeatable options

Some compiler options are repeatable. The online help shows their arguments in square brackets, followed by a bracketed ellipses, like this:

 -compiler.source-path [path-element] [...]

You set the value of repeatable options by using multiple nested elements of the same name as the option, along with attributes of the same name as they appear in the online help.

The following example sets two values for the compiler.source-path option:

 <mxmlc ...> 
 	<compiler.source-path path-element="src"/> 
 	<compiler.source-path path-element="../bar/src"/> 
 </mxmlc>

Nested elements

In some situations, options that are closely related are grouped together in a nested element of the main task element. For example, the command-line compiler options with the compiler.fonts and metadata prefixes can be grouped into nested elements. The compiler.fonts options use the element name fonts and the metadata options use the element name metadata.

The following example shows how to use the metadata nested element:

 <mxmlc ...> 
 	<metadata description="foo app"> 
 		<contributor name="Joe" /> 
 		<contributor name="Nick" /> 
 	</metadata> 
 </mxmlc>

In this example, you drop the metadata prefix when setting the description and contributor options as a nested element.

This is a uniformly applied rule with one exception: the compiler.fonts.languages.language-range option is set using a nested element with the name language-range, rather than languages.language-range.

Implicit FileSets

There are many examples in the Apache Ant project where tasks behave as implicit FileSets. For example, the delete task, while supporting additional attributes, supports all of the attributes (such as dir and includes) and nested elements (such as include and exclude) of a FileSet to specific the files to be deleted.

Some Flex Ant tasks allow nested attributes that are implicit FileSets. These nested attributes support all the attributes and nested elements of an Ant FileSet while adding additional functionality. These elements are usually used to specify repeatable arguments that take a filename as an argument.

The following example uses the implicit FileSet syntax with the include-sources nested element:

 <include-sources dir="player/avmplus/core" 
	includes="builtin.as, Date.as, Error.as, Math.as, RegExp.as, XML.as"/>

When a nested element in a Flex Ant task is an implicit FileSet, it supports one additional attribute: append. The reason for this is that some repeatable options for the Flex compilers have default values. When setting these options in a command line, you can append new values to the default value of the option, or replace the default value with the specified values. Setting the append value to true adds the new option to the list of existing options. Setting the append value to false replaces the existing options with the new option. By default, the value of the append attribute is false in implicit FileSets.

The following example sets the value of the append attribute to true and uses the Ant include element of an implicit FileSet to add multiple SWC files to the include-libraries option:

 <compiler.include-libraries dir="${swf.output}" append="true"> 
 	<include name="MyComponents.swc" /> 
 	<include name="AcmeComponents.swc" /> 
 	<include name="DharmaComponents.swc" /> 
 </compiler.include-libraries>

The following options are implemented as implicit FileSets:

 compiler.external-library-path  
 compiler.include-libraries  
 compiler.library-path  
 compiler.theme  
 compiler.include-sources (compc only)

The Flex Ant task's implicit FileSets are also different from the Ant project's implicit FileSets in that they support being empty, as in the following example:

 <external-library-path/>

This is equivalent to using external-library-path= on the command line.

Using the mxmlc task

You use the mxmlc Flex Ant task to compile applications, modules, resource modules, and Cascading Style Sheets (CSS) SWF files. This task supports most mxmlc command-line compiler options, including aliases.

For more information on using the mxmlc command-line compiler, see Using mxmlc, the application compiler.

Required attributes

The mxmlc task requires the file attribute. The file attribute specifies the MXML file to compile. This attribute does not have a command-line equivalent because it is the default option on the command line.

Unsupported options

The following mxmlc command-line compiler options are not supported by the mxmlc task:

  • help

  • version

Example

The following example mxmlc task explicitly defines the source-path and library-path options, in addition to other properties such as incremental and keep-generated-actionscript. This example also specifies an output location for the resulting SWF file. This example defines two targets: main and clean. The main target compiles the Main.mxml file into a SWF file. The clean target deletes the output of the main target.

 <?xml version="1.0" encoding="utf-8"?> 
 <!-- myMXMLCBuild.xml --> 
 <project name="My App Builder" basedir="."> 
 	<taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" /> 
 	<property name="FLEX_HOME" value="C:/flex/sdk"/> 
 	<property name="APP_ROOT" value="apps"/> 
 	<property name="DEPLOY_DIR" value="c:/jrun4/servers/default/default-war"/> 
 	<target name="main"> 
 		<mxmlc  
 			file="${APP_ROOT}/Main.mxml"  
 			output="${DEPLOY_DIR}/Main.swf" 
 			actionscript-file-encoding="UTF-8" 
 			keep-generated-actionscript="true" 
 			incremental="true"> 
 			<!-- Get default compiler options. --> 
 			<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> 
  
 			<!-- List of path elements that form the roots of ActionScript 
			class hierarchies. --> 
 			<source-path path-element="${FLEX_HOME}/frameworks"/> 
  
 			<!-- List of SWC files or directories that contain SWC files. --> 
 			<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true"> 
 				<include name="libs" /> 
 				<include name="../bundles/{locale}" /> 
 			</compiler.library-path> 
  
 			<!-- Set size of output SWF file. --> 
 			<default-size width="500" height="600" /> 
 		</mxmlc> 
 	</target> 
 	<target name="clean"> 
 		<delete dir="${APP_ROOT}/generated"/> 
 		<delete> 
 			<fileset dir="${DEPLOY_DIR}" includes="Main.swf"/> 
 		</delete> 
 	</target> 
 </project>

Using the compc task

You use the compc Flex Ant task to compile component SWC files. This task supports most compc command-line compiler options, including aliases. For more information on using the compc command-line compiler, see Using compc, the component compiler.

Required attributes

The only required attribute for the compc task is the output attribute, which specifies the name of the SWC file that the compc task creates.

Special attributes

The include-classes attribute takes a space-delimited list of class names. For example:

 <compc include-classes="custom.MyPanel custom.MyButton" ... > 
 	... 
 </compc>

When using the include-resource-bundles attribute, you should not specify them as a comma or space-delimited list in a single entry. Instead, add a separate child tag for each resource bundle that you want to include, as the following example shows:

 <compc output="${swf.output}/compc_rb.swc" locale="en_US"> 
 	<include-resource-bundles bundle="ErrorLog"/> 
 	<include-resource-bundles bundle="LabelResource"/> 
 	<sp path-element="locale/{locale}"/>  
 </compc>

Unsupported options

The following compc command-line compiler options are not supported by the compc task:

  • help

  • version

Example

The following example compc task builds a new SWC file that contains two custom components and other assets. The components are added to the SWC file by using the include-classes attribute. The source files for the components are in a subdirectory called components. The other assets, including four images and a CSS file, are added to the SWC file by using the include-file element.

This example defines two targets: main and clean. The main target compiles the MyComps.swc file. The clean target deletes the output of the main target.

 <?xml version="1.0" encoding="utf-8"?> 
 <project name="My Component Builder" basedir="."> 
 	<taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" /> 
 	<property name="FLEX_HOME" value="C:/flex/sdk"/> 
 	<property name="DEPLOY_DIR" value="c:/jrun4/servers/default/default-war"/> 
 	<property name="COMPONENT_ROOT" value="components"/> 
 	<target name="main"> 
 		<compc  
 			output="${DEPLOY_DIR}/MyComps.swc" 
 			include-classes="custom.MyButton custom.MyLabel"> 
 			<source-path path-element="${basedir}/components"/> 
 			<include-file name="f1-1.jpg" path="assets/images/f1-1.jpg"/> 
 			<include-file name="f1-2.jpg" path="assets/images/f1-2.jpg"/> 
 			<include-file name="f1-3.jpg" path="assets/images/f1-3.jpg"/> 
 			<include-file name="f1-4.jpg" path="assets/images/f1-4.jpg"/> 
 			<include-file name="main.css" path="assets/css/main.css"/> 
 		</compc> 
 	</target> 
 	<target name="clean"> 
 		<delete> 
 			<fileset dir="${DEPLOY_DIR}" includes="MyComps.swc"/> 
 		</delete> 
 	</target> 
 </project>

Using the html-wrapper task

The html-wrapper Ant task generates files that you deploy with your applications. An HTML wrapper consists of a generated HTML page and a JavaScript file that defines embed logic. The output can also include files that support features such as deep linking and Express Install.

The html-wrapper task outputs the index.html and swfobject.js files for your application. The swfobject.js file defines the SWFObject 2 logic that embeds SWF files in HTML.

If you enable deep linking support, the html-wrapper task also outputs the deep linking files such as historyFrame.html, history.css, and history.js. If you enable express installation, the html-wrapper task also outputs the playerProductInstall.swf file.

You typically deploy these files, along with your application's SWF file, to a web server. Users request the HTML wrapper, which embeds the SWF file. You can customize the output of the wrapper and its supporting files after it is generated by Ant.

For more information on the HTML wrapper, see Creating a wrapper.

Supported attributes

The attributes of the html-wrapper task correspond to some of the arguments in the swfobject.embedSWF() method of the default HTML wrapper.

The following table describes the supported attributes of the html-wrapper task:

Attribute

Description

application

The name of the SWF object in the HTML wrapper. You use this name to refer to the SWF object in JavaScript or when using the ExternalInterface API. This value should not contain any spaces or special characters.

This attribute sets the value of the <embed> tag's name attribute and the <object> tag's id attribute.

bgcolor

Specifies the background color of the application. Use this property to override the background color setting specified in the SWF file. This property does not affect the background color of the HTML page.

This attribute sets the value of the params.bgcolor argument in the embedSWF() method.

The default value is white.

express-install =false|true

Determines whether to include Express Install logic in the HTML wrapper. When set to true, the Ant task copies the playerProductInstall.swf file to the output directory and referenced in the wrapper file.

If you set this option to true, the version-detection option is also assumed to be true.

For more information, see Using Express Install in the wrapper.

The default value is false.

file

Sets the file name of the HTML output file. The default value is "index.html".

height

Defines the height, in pixels, of the SWF file. Adobe® Flash® Player makes a best guess to determine the height of the application if none is provided.

This attribute sets the value of the third argument in the embedSWF() method.

The default value is 400.

history

Set to true to include deep linking support (also referred to as history management) in the HTML wrapper. Set to false to exclude deep linking from the wrapper. When you set this attribute to true, Ant creates a history directory and stores the historyFrame.html, history.css, and history.js files in it.

The default value is false.

For more information on deep linking, see Deep linking.

output

Sets the directory that Ant writes the generated files to. If you do not set the value of this option, Ant creates the wrapper files in the same directory as the build file.

swf

Sets the name of the SWF file that the HTML wrapper embeds (for example, Main). Do not include the *.swf extension; the extension is appended to the name for you.

This attribute sets the value of the attributes.name and attributes.id arguments in the embedSWF() method. It also sets the value of the first argument in that method call.

This SWF file does not have to exist when you generate the HTML wrapper. It is used by SWFObject 2 to point to the location of the SWF file at deployment time.

title

Sets the value of the <title> tag in the head of the HTML page.

The default value is Flex Application.

version-detection =true|false

Determines whether to include version detection logic in the wrapper. Set this value to false to disable all Player version logic in the HTML wrapper.

The default value is true.

version-major

Sets the value of the swfVersionStr variable in the HTML wrapper.

The default value is 10.

The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection.

version-minor

Sets the value of the swfVersionStr variable in the HTML wrapper.

The default value is 0.

The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection.

version-revision

Sets the value of the swfVersionStr variable in the HTML wrapper.

The default value is 0.

The value of this attribute only matters if you include version detection in your wrapper by setting the template attribute to express-installation or client-side-detection.

width

Defines the width, in pixels, of the SWF file. Flash Player makes a best guess to determine the width of the application if none is provided.

This attribute sets the value of the fourth argument in the embedSWF() method.

The default value is 400.

Required attributes

The html-wrapper task requires the swf attribute. If you specify only the swf attribute, the default wrapper will have the following settings:

 title="Flex Application" 
swfVersionStr = "10.0.0"; 
params.quality = "high"; 
params.bgcolor = "white"; 
params.allowscriptaccess = "sameDomain"; 
params.allowfullscreen = "true"; 
attributes.align = "middle"; 
 height="400" 
 width="400" 

Be sure to use the filename only and not the filename plus extension when specifying the value of the swf attribute. The html-wrapper task appends .swf to the end of its value before passing it to the embedSWF() method.

For example, do this:

 swf="Main"

Do not do this:

 swf="Main.swf"

Unsupported options

The html-wrapper task does not support all properties used by SWFObject 2 to embed a SWF file in an HTML wrapper. Parameters you cannot set include quality, allowScriptAccess, classid, pluginspage, and type.

Example

The following example project includes a wrapper target that uses the html-wrapper task to generate a wrapper with deep linking, Player detection, and Express Install logic. This target (wrapper) also sets the height and width of the SWF file. The project also includes a clean target that deletes all the files generated by the wrapper target.

 <?xml version="1.0" encoding="utf-8"?> 
<!-- myWrapperBuild.xml --> 
<project name="My Wrapper Builder" basedir="."> 
	<taskdef resource="flexTasks.tasks" classpath="${basedir}/lib/flexTasks.jar"/> 
	<property name="FLEX_HOME" value="C:/p4/flex/flex/sdk"/> 
	<property name="APP_ROOT" value="c:/temp/ant/wrapper"/> 
	<target name="wrapper"> 
		<html-wrapper 
			title="Welcome to My Flex App" 
			file="index.html" 
			height="300" 
			width="400" 
			application="app" 
			swf="Main" 
			history="true" 
			express-install="true" 
			version-detection="true" 
			output="${APP_ROOT}"/> 
	</target> 
	<target name="clean"> 
		<delete> 
			<!-- Deletes playerProductInstall.swf --> 
			<fileset dir="${APP_ROOT}" 
				includes="playerProductInstall.swf" 
				defaultexcludes="false"/> 
			<!-- Deletes the swfobject.js file --> 
			<fileset dir="${APP_ROOT}" includes="*.js" defaultexcludes="false"/> 
			<!-- Deletes the previously-generated HTML wrapper file --> 
			<fileset dir="${APP_ROOT}" includes="*.html" defaultexcludes="false"/> 
			<!-- Deletes the history files --> 
			<fileset dir="${APP_ROOT}/history" includes="*.*" defaultexcludes="false"/> 
		</delete> 
	</target> 
</project> 

Using the asdoc task

The Flex Ant tasks include a task to run the asdoc utility. This utility generates HTML documentation based on a defined set of tags that you can include in your ActionScript and MXML files.

For more information about using ASDoc, see ASDoc.

Required attributes

The asdoc Ant task requires that you specify a target class or classes to generate ASDoc for. This must be either a list of one or more classes, a directory of classes, or a namespace. You specify these by using the doc-classes, doc-sources, or doc-namespaces attributes.

If you use the doc-classes or doc-namespaces attributes, you must also specify a source-path argument. If you use the doc-namespaces attribute, you must also specify a namespace attribute.

It's best to specify a value for the output attribute. If you do not specify a value, Ant creates a directory called asdoc-output in the same directory that you launched the command from. Ant then stores the HTML output files in that new directory.

Unsupported options

All options of the asdoc utility are supported by the asdoc Ant task.

Example

The following example defines two targets, doc and clean. The doc target generates ASDoc for the Spark and MX button classes. The clean target deletes all the files generated by the doc target.
<?xml version="1.0" encoding="utf-8"?> 
<project name="ASDoc Builder" basedir="."> 
	<property name="FLEX_HOME" value="C:/p4/flex/flex/sdk"/> 
	<property name="OUTPUT_DIR" value="C:/temp/ant/asdoc"/> 
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
	<target name="doc"> 
		<asdoc output="${OUTPUT_DIR}" lenient="true" failonerror="true"> 
			<doc-sources 
				path-element="${FLEX_HOME}/frameworks/projects/spark/src/spark/components/Button.as"/> 
			<doc-sources 
				path-element="${FLEX_HOME}/frameworks/projects/framework/src/mx/controls/Button.as"/> 
		</asdoc> 
	</target> 
	<target name="clean"> 
		<delete includeEmptyDirs="true"> 
			<fileset dir="${OUTPUT_DIR}" includes="**/*"/> 
		</delete> 
	</target> 
</project>

You will have to change the values of the Flex home and output directory to match the locations of the directories on your file system.

To run this example, you can use the following Ant command:

ant clean doc

This example generates simple ASDoc output for the Spark and MX Button controls by using the doc-sources attribute. The output does not include all the parent classes that provide the inherited methods, properties, events, and other members of the Button controls.

To generate ASDoc that includes the parent classes of the Button controls, you can use an Ant task that uses the doc-classes attribute. When you do this, you must be sure to also define the source-path for the classes.

The following example generates ASDoc for the MX Button control. It includes the parent classes that this control inherits its members from.
<?xml version="1.0" encoding="utf-8"?> 
<project name="ASDoc Builder" basedir="."> 
	<property name="FLEX_HOME" value="C:/p4/flex/flex/sdk"/> 
	<property name="OUTPUT_DIR" value="C:/temp/ant/asdoc"/> 
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
	<target name="doc"> 
		<asdoc output="${OUTPUT_DIR}" lenient="true" failonerror="true"> 
			<compiler.source-path 
				path-element="${FLEX_HOME}/frameworks/projects/framework/src"/> 
			<doc-classes class="mx.controls.Button"/> 
		</asdoc> 
	</target> 
	<target name="clean"> 
		<delete includeEmptyDirs="true"> 
			<fileset dir="${OUTPUT_DIR}" includes="**/*"/> 
		</delete> 
	</target> 
</project>

You can also define an asdoc Ant task that includes all components in a particular namespace by using the doc-namespaces attribute. When you want to document all classes in a namespace, you must also point to the manifest file for that namespace by using the namespace attribute.

The following example generates ASDoc for all components in the Spark namespace:
<?xml version="1.0" encoding="utf-8"?> 
<project name="ASDoc Builder" basedir="."> 
	<property name="FLEX_HOME" value="C:/p4/flex/flex/sdk"/> 
	<property name="OUTPUT_DIR" value="C:/temp/ant/asdoc"/> 
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
	<target name="doc"> 
		<asdoc output="${OUTPUT_DIR}" lenient="true" failonerror="true"> 
			<compiler.source-path 
				path-element="${FLEX_HOME}/frameworks/projects/spark/src"/> 
			<doc-namespaces uri="library://ns.adobe.com/flex/spark"/> 
			<namespace 
				uri="library://ns.adobe.com/flex/spark" 
				manifest="${FLEX_HOME}/frameworks/projects/spark/manifest.xml"/> 
		</asdoc> 
	</target> 
	<target name="clean"> 
		<delete includeEmptyDirs="true"> 
			<fileset dir="${OUTPUT_DIR}" includes="**/*"/> 
		</delete> 
	</target> 
</project>

In this example, only the members that are inherited from other classes in the Spark namespace are added to the ASDoc output.

The flex-config.xml file contains a list of predefined namespace URIs and the locations of their manifest files. As a result, if you use the asdoc Ant task to generate ASDoc for one of these namespaces, and not a custom namespace, then you are not required to define the location of the manifest file. This is because the asdoc Ant task reads in their definitions. It is, however, best practice to define the manifest file location for all namespaces.

Navigation

Using Flex » Testing and automation

Adobe and Adobe Flash Player are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries and are used by permission from Adobe. No other license to the Adobe trademarks are granted.