User Guide

44 Chapter 3: Using ActionScript
Netscape DevEdge Online has a JavaScript Developer Central site
(http://developer.netscape.com/tech/javascript/index.html) that contains documentation and
articles about ActionScript.
Core JavaScript Guide.
For more information about using ActionScript in Flex, see Flex ActionScript Language Reference,
which is included in the Flex documentation set.
Comparing ActionScript and ECMAScript (JavaScript)
The following are some of the differences between ActionScript and JavaScript:
ActionScript does not support browser-specific objects such as Document, Window,
and Anchor.
ActionScript does not completely support all of the JavaScript built-in objects.
ActionScript supports syntax constructs that are not permitted in JavaScript (for example, the
tellTarget and ifFrameLoaded actions and slash syntax) to support previous releases.
However, Macromedia does not recommend the use of these syntax constructs; instead, use
ActionScript elements that are like those in JavaScript (for example,
with, _framesloaded,
and dot syntax).
ActionScript does not support some JavaScript syntax constructs, such as statement labels.
In ActionScript, the eval action can only perform variable references.
In JavaScript, when a string is evaluated in a Boolean context and the string has a nonzero
length, the result is
true; if the string doesnt have a nonzero length, the result is false. In
ActionScript, the string is converted to a number. If the number is nonzero, the result is
true;
otherwise, the result is
false.
About ActionScript in MXML applications
ActionScript extends the capabilities of Flex application developers. With ActionScript, you can
define event listeners and handlers, get or set component properties, handle callback functions,
and create new classes, packages, and components.
You can use ActionScript in your Flex applications in the following ways:
Insert ActionScript code blocks with the <mx:Script> tag. In these code blocks, you can add
new functions, handle errors and events, and perform other tasks in your application or its
supporting MXML files.
Call global ActionScript functions that are stored in the system_classes directory structure.
Reference external classes and packages in user_classes to handle more complex tasks. This lets
you take advantage of ActionScript support for object-oriented programming concepts such as
code reuse and inheritance.
Use standard Flex components. The logic of components and helper classes in the Flex
application model is based on ActionScript classes.
Extend existing components with ActionScript classes.