View comments | RSS feed

Overview of the Macromedia Flash JavaScript API

The ActionScript language lets you write scripts to perform actions in the Flash Player environment (that is, while a SWF file is playing). 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). These scripts can be used to help streamline the authoring process. For example, you can write scripts to automate repetitive tasks, add custom tools to the Tools panel, or add timeline effects.

The Flash JavaScript API is designed to resemble the Macromedia Dreamweaver and Macromedia 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 will have an effect.

The JavaScript API also contains a number of methods that let you implement extensibility using a combination of JavaScript and custom C code. For more information, see C-Level Extensibility.

The JavaScript interpreter in Flash is the Mozilla SpiderMonkey engine, version 1.5, which is available on the web at www.mozilla.org/js/spidermonkey/. SpiderMonkey is one of the two reference implementations of the JavaScript 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.


Version 8

Comments


jdowdell said on Apr 12, 2006 at 2:36 PM :
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00004335.html

Use of text "scripts" here is ambiguous, because readers are dealing with two scripting languages already. Better to say "JavaScript" (or "browser script") when you don't mean ActionScript, thanks.

"The JavaScript interpreter in Flash is the Mozilla SpiderMonkey engine," It is? I thought the JavaScript was evaluated in the browser, then a message passed across the NPRuntime interface (or the MS interface) for execution by Flash Player's logic engine. Does the browser actually pass the text JavaScript across to the plugin for evaluation and execution there...!?
markerickson said on Apr 24, 2006 at 2:52 PM :
This page is confusing because it starts by referring to ActionScript and
the Flash player. Better to start by clearly stating that the "Flash
JavaScript API" is about scripting the "Flash Application / Flash authoring
environment", then emphasize that it is simlar to Dreamweaver and
Fireworks. Finally emphasize that it is not the Flash ActionScript that
makes the flash document active, nor is it JavaScript in the browser.

Good news is that you can do some amazing things with the Flash
application through the "Macromedia Flash JavaScript API" (please just
call it Flash Application Scripting). You can simply automate repetitive
actions and much more including creating some amazingly intericate
and complex stuff. Even better, you can use most of your ActionScript
knowledge to make it happen. Read the other pages for more details.

Comment on jdowdell comment... As mentioned above. This document
refers to the Flash "Application" or Flash authoring environment.
Although the docs are confusing, they are correct as long as you
carefully parse which "Flash" and scripts this page is referring to.
sunil_syal13 said on Dec 6, 2006 at 7:47 AM :
Flash 8 documentation says "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)."
But i am able to run a jsfl file from the command menu while no fla file is opened.
Narendra kumar said on May 21, 2007 at 11:29 PM :
I would definitely advice a dose of caution when it comes to JSFL. The File API is extremely useful, but it also has the potential to be used maliciously. It is extremely simple to write a JSFL script that deletes critical files (intentionally or unintentionally). Pair this with the fact that JSFL files execute when double clicked, instead of opening to be edited, and you have a potentially dangerous situation. I would definitely urge you to change this behavior in the next release of Flash or to service pack - when I double click a JSFL, it should open to edit, so that I can review it's functionality prior to running it (it's too easy to dbl-click by accident when you want to edit it).

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00004335.html