Chapter 1: introduction, Working with the javascript api, Creating jsfl files – Adobe Extending Flash Professional CS5 User Manual
Page 23
1
Last updated 5/2/2011
Chapter 1: Introduction
As a user of Adobe® Flash® Professional CS5 or CS5.5, you may be familiar with Adobe® ActionScript®, which lets you
create scripts that execute at run time in Adobe® Flash® Player. The Flash JavaScript application programming interface
(JavaScript API) described in this document is a complementary programming tool that lets you create scripts that run
in the authoring environment.
This document describes the objects, methods, and properties available in the JavaScript API. It assumes that you
know how to use the documented commands when working in the authoring environment. If you have a question
about what a particular command does, use other documents in Flash Help, such as Using Flash, to find that
information.
This document also assumes that you are familiar with JavaScript or ActionScript syntax and with basic programming
concepts such as functions, parameters, and data types.
Working with the JavaScript API
The Flash JavaScript API lets you write scripts to perform several actions in the Flash authoring environment (that is,
while a user has the Flash program open). This functionality is different from the ActionScript language, which lets
you write scripts to perform actions in the Flash Player environment (that is, while a SWF file is playing). This
functionality is also different from JavaScript commands that you might use in pages displayed in a web browser.
Using the JavaScript API, you can write Flash application scripts to help streamline the authoring process. For
example, you can write scripts to automate repetitive tasks or add custom tools to the Tools panel.
The Flash JavaScript API is designed to resemble the Adobe® Dreamweaver® and Adobe® Fireworks® JavaScript API
(which were designed based on the Netscape JavaScript API). The Flash JavaScript API is based on a Document Object
Model (DOM), which allows Flash documents to be accessed using JavaScript objects. The Flash JavaScript API
includes all elements of the Netscape JavaScript API, plus the Flash DOM. These added objects and their methods and
properties are described in this document. You can use any of the elements of the native JavaScript language in a Flash
script, but only elements that make sense in the context of a Flash document have an effect.
The JavaScript API also contains methods that let you implement extensibility using a combination of JavaScript and
custom C code. For more information, see “
The JavaScript interpreter in Flash is the Mozilla SpiderMonkey engine, version 1.6, which is available on the web at
language developed by Mozilla.org. It is the same engine that is embedded in the Mozilla browser.
SpiderMonkey implements the core JavaScript language as defined in the ECMAScript (ECMA-262) edition 3
language specification and it is fully compliant with the specification. Only the browser-specific host objects, which
are not part of the ECMA-262 specification, are not supported. Similarly, many JavaScript reference guides distinguish
between core JavaScript and client-side (browser-related) JavaScript. Only core JavaScript applies to the Flash
JavaScript interpreter.
Creating JSFL files
You can use Adobe Flash Professional or your preferred text editor to write and edit Flash JavaScript (JSFL) files. If
you use Flash, these files have a .jsfl extension by default. To write a script, select File
> New
> Flash JavaScript File.