Kinesis SoftwareKineticFusion

[Show Table of Contents]

9 Working with ActionScript

[Hide Table of Contents]



9.2 Referencing External ActionScript

Embedding explicit ActionScript within an RVML document is not always optimal. There is no way to reuse ActionScript blocks either within the same document or between similar RVML documents. This section will look at ways that external ActionScript can be referenced from RVML.

9.2.1 Using RVML 'src' Attribute

There are four RVML elements that allow users to specify scripts directly in RVML:

As well as allowing direct embedding of ActionScript, each element can also have a 'src' attribute specified instead. This attribute identified the name or URL of a source ActionScript file whose contents are inlined directly into the element. When the location of 'src' attribute refers to a file, the script is replaced with a '#include' directive that ensure that any nested '#include' directives are relative to the top-level file. Where the location is a URL the contents of the URL are read and inserted. This means that any '#include' elements must be absolute references or relative to the location of the RVML document.

9.2.2 Using '#include' directive

KineticFusion provides full support for nested '#include' directives. While this directive is somewhat deprecated with the introduction of AS2.0 it is still used in AS2.0 classes (notably within Macromedia's component classes), and for developers working with AS1.0. The '#include' directive can be defined anywhere within a script block: the contents of the referenced file are inlined to the exact location of the '#include statement. Nested '#include' statements are allowed provided a file is not included that contains a direct or indirect reference to a 'parent' file that is being included. KineticFusion will signal this as an error as this would otherwise cause an infinite loop.

The file specified in a '#include' directive can be an absolute or relative file name. By default, KineticFusion will use the current document to locate all relative files: when used inside an RVML document, the current document is assumed to be the actual RVML document itself. It is also possible to specify a list of include locations in which to locate files specified using a relative file name: these locations can be defined using the configuration option:kinesis.actionscript.includePath.

9.2.3 Using ActionScript 2.0 Classes

With the introduction of ActionScript 2.0, the most common way of including external ActionScript is through referencing ActionScript classes. See the section 'Integrating Classes into RVML' for more information.