# Documenting dynamic properties and functions with ScriptDoc [edit]

This page describes how to document a dynamically generated function in your code using ScriptDoc.

## Introduction

You can use ScriptDoc to make dynamically created functions and objects appear in Code Assist. ScriptDoc has an @alias tag that you can add to your documentation so that you can access these objects in Code Assist.

## Instructions

Aptana includes a good example of documentation for dynamically generated properties and functions in the .sdoc file for the AFLAX library. To view this documentation, follow the instructions in Getting started with Aptana and AFLAX and create a sample AFLAX project. After creating your sample project, go into the lib > AFLAX folder, and open the aflax.js and aflax.sdoc files.

### Properties

To see how dynamic properties are documented, in the aflax.js file, scroll down to the following excerpt (starting around line 871):

    /**
     * The properties to expose from Flash on the MovieClip object.
     */
    AFLAX.MovieClip.movieClipProperties = [
    	"_x",
    	"_y",
    	"_height",
    	"_width",
    	"_rotation",
    	"_xmouse",
    	"_ymouse",
    	"_xscale",
    	"_yscale",
    	"_alpha",
    	"blendMode",
    	"_visible",
    	"cacheAsBitmap"
    	];

Each property in this list has a dynamically created "get" and a "set" function to retrieve or change the value of the property. The "get" and "set" functions are documented separately in the aflax.sdoc file.

Documentation for the dynamic MovieClip properties starts around line 39 in aflax.sdoc. An example of the documentation blocks, which use the @alias tag to give the get and set functions a name, is shown below:

    /**
     * Sets the X coordinate of this MovieClip
     * @alias AFLAX.MovieClip.prototype.set_x
     * @param {Number} x The X coordinate
     */

    /**
     * Returns the X coordinate of this MovieClip
     * @alias AFLAX.MovieClip.prototype.get_x
     * @return {Number} The X coordinate
     */

As you can see, the @alias tag uses the full namespace for the functions. These functions will be available in Code Assist for AFLAX.

### Functions

Dynamically generated functions are documented in a similar way to dynamically generated properties. The excerpt below (starting near line 890) shows the list of dynamically generated functions for the MovieClip object in AFLAX:

    /**
     * The functions to expose from Flash on the MovieClip object.
     */
    AFLAX.MovieClip.movieClipFunctions = [
    	"beginFill",
    	"clear",
    	"curveTo",
    	"endFill",
    	"getURL",
    	"lineStyle",
    	"lineTo",
    	"moveTo",
    	"removeMovieClip"
    	];

Each of these functions has a separate documentation block in the aflax.sdoc file. The @alias tag gives the name of the function. This is shown in the example below for the beginFill function:

    /**
     * Begins drawing a fill on the Stage.
     * @alias AFLAX.MovieClip.prototype.beginFill
     * @param {Number} rgb Color to fill with(0x000000 - 0xFFFFFF). A fill is not created if rgb is not specified or is undefined.
     * @param {Number} [alpha] Alpha level to fill with (0-100)
     */

These functions will also be available in Code Assist.

## Related Topics

- ScriptDoc comprehensive tag reference
- ScriptDoc tag quick reference

Retrieved from "http://aptana.com/docs/index.php/Documenting_dynamic_properties_and_functions_with_ScriptDoc"