Flash Samples

ActionScript™, which lets you create scripts that execute at run time in. Adobe® ... you create scripts that run in the authoring environment (that is, while a user has ... Several JavaScript API samples are available in a folder named Samples/.
55KB taille 112 téléchargements 562 vues
Extending Flash As a user of Adobe® Flash® CS3 Professional, you may be familiar with ActionScript™, which lets you create scripts that execute at run time in Adobe® Flash® Player. The Flash JavaScript application programming interface (JavaScript API) is a complementary programming tool that lets you create scripts that run in the 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. Several JavaScript API samples are available in a folder named Samples/ ExtendingFlash within the ZIP file located at www.adobe.com/go/ learn_fl_samples. This document contains a brief overview of each sample. WHERE TO STORE SAMPLE JSFL FILES Some of the examples use JSFL files. The folder in which to store the sample JSFL files for running them on your computer is: ■

Windows® 2000 or Windows® XP: boot drive\Documents and Settings\user\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\Commands



Mac OS® X: Macintosh HD/Users/userName/Library/Application Support/Adobe/ Flash CS3/language/Configuration/Commands

39

SAMPLES DESCRIBED IN THIS DOCUMENT ■

Shape command



Get and set filters command



PolyStar tool



Trace Bitmap panel



Sample DLL

Shape command A sample JavaScript API script named Shape.jsfl is located in the ExtendingFlash/Shape folder. This script displays information about the contours of a selected shape in the Output panel. To install and run the Shape script: 1.

Copy the Shape.jsfl file to the Configuration/Commands folder (see WHERE TO STORE SAMPLE JSFL FILES near the beginning of this document).

2.

In a Flash document (FLA file), select a shape object.

3.

Select Commands > Shape to run the script.

Get and set filters command A sample JavaScript API script named filtersGetSet.jsfl is located in the ExtendingFlash/filtersGetSet folder. This script adds filters to a selected object and displays information about the filters being added in the Output panel. To install and run the filtersGetSet script:

40

Extending Flash

1.

Copy the filtersGetSet.jsfl file to the Configuration/Commands folder (see WHERE TO STORE SAMPLE JSFL FILES near the beginning of this document).

2.

In a Flash document (FLA file), select a text, movie clip, or button object.

3.

Select Commands > filtersGetSet to run the script.

PolyStar tool A sample JavaScript API script named PolyStar.jsfl is located in the ExtendingFlash/PolyStar folder. This script provides an example of adding a tool to the Tools panel using the JavaScript API. The PolyStar.jsfl replicates the PolyStar tool that can be found in the Flash Tools panel. The script demonstrates how to build the PolyStar tool using the JavaScript API, and includes detailed comments describing what the code is doing. Read this file to gain a better understanding of how the JavaScript API can be used. You should also read the PolyStar.xml file in the Configuration/Tools directory to learn more about how to build your own tool.

Trace Bitmap panel A set of files named TraceBitmap.fla and TraceBitmap.swf are located in the ExtendingFlash/TraceBitmapPanel folder. These files comprise an advanced example to illustrate how to design and build a panel to control the functions of Flash. They also show the use of the MMExecute() function to call JavaScript commands from an ActionScript script. To run the TraceBitmap sample: 1.

If Flash is running, exit from Flash.

2.

Copy the TraceBitmap.swf file to the WindowSWF folder, which is a subdirectory of the Configuration folder at the same level as the Commands folder (see WHERE TO STORE SAMPLE JSFL FILES near the beginning of this document).

3.

Start Flash.

4.

Create or open a Flash document (FLA file), and import a bitmap or JPEG image into the file. You can use the flower.jpg file provided in the ExtendingFlash/ TraceBitmapPanel folder. or another image of your choice.

5.

With the imported image selected, select Window > Other Panels > TraceBitmap.

6.

Click Submit. The image is converted into a group of shapes.

Trace Bitmap panel

41

Sample DLL Advanced users can use the C-level extensibility mechanism to implement Flash extensibility files using a combination of JavaScript and custom C code. You define functions using C, bundle them in a dynamic linked library (DLL) or a shared library, save the library in the appropriate directory, and then call the functions from JavaScript using the JavaScript API. Sample DLL implementations are in the ExtendingFlash/ dllSampleComputeSum folder. For information about installing and using this sample, see “Sample DLL implementation” in Chapter 3, “C-Level Extensibility,” in Extending Flash.

42

Extending Flash