What’s new in the javascript api – Adobe Extending Flash Professional CS5 User Manual
Page 26
4
EXTENDING FLASH PROFESSIONAL
Introduction
Last updated 5/2/2011
•
command.
•
From the file system, double-click the script file.
To add a tool implemented in a JSFL file to the Tools panel:
1 Copy the JSFL file for the tool and any other associated files to the Tools folder (see “
2 Select Edit > Customize Tools Panel (Windows) or Flash
> Customize Tools Panel (Macintosh).
3 Add the tool to the list of available tools.
4 Click OK.
You can add individual JavaScript API commands to ActionScript files by using the
MMExecute()
function, which is
documented in the ActionScript 3.0 Language and Components Reference. However, the
MMExecute()
function has an
effect only when it is used in the context of a custom user interface element, such as a component Property inspector,
or a SWF panel within the authoring environment. Even if called from ActionScript, JavaScript API commands have
no effect in Flash Player or outside the authoring environment.
To issue a command from an ActionScript script:
•
Use the following syntax (you can concatenate several commands into one string):
MMExecute(Javascript command string);
You can also run a script from the command line.
To run a script from the command line on Windows:
•
Use the following syntax (add path information as required):
"flash.exe" myTestFile.jsfl
To run a script from the “Terminal” application on the Macintosh:
•
Use the following syntax (add path information as required):
osascript -e 'tell application "flash" to open alias "Mac OS X:Users:user:myTestFile.jsfl" '
The
osascript
command can also run AppleScript in a file. For example, you could include the following text in
a file named myScript:
tell application "flash"
open alias "Mac OS X:Users:user:myTestFile.jsfl"
end tell
Then, to run the script, you would use this command:
osascript myScript
What’s new in the JavaScript API
In Flash CS5 and CS5.5, some objects, methods, and properties have been added while others have been removed.
These changes are summarized below.
If you have not used the JavaScript API before, you might want to skip this section and go directly to “