Sample implementations

 < Day Day Up > 

Several sample JSFL implementations are included with Flash 8. You can review and install these files to familiarize yourself with the JavaScript API. The samples are installed in a folder named Samples/ExtendingFlash within the folder in which you installed Flash. For example, if you installed Flash using the default setting, the samples are placed in the following location:

  • In Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ExtendingFlash

  • On the Macintosh: Macintosh HD/Applications/Macromedia/Flash 8/Samples and Tutorials/Samples/ExtendingFlash

Sample Shape command

A sample JavaScript API script named Shape.jsfl is located in the ExtendingFlash/Shape folder (see "Sample implementations" above). This script displays information about the contours of the shape in the Output panel.

To install and run the Shape script:

  1. Copy the Shape.jsfl file to the Configuration/Commands folder (see "Saving JSFL files" on page 7).

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

  3. Select Commands > Shape to run the script.

Sample get and set filters command

A sample JavaScript API script named filtersGetSet.jsfl is located in the ExtendingFlash/filtersGetSet folder (see "Sample implementations" on page 19). 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:

  1. Copy the filtersGetSet.jsfl file to the Configuration/Commands folder (see "Saving JSFL files" on page 7).

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

  3. Select Commands > filtersGetSet to run the script.

Sample PolyStar tool

A sample JavaScript API script named PolyStar.jsfl is located in the ExtendingFlash/PolyStar folder (see "Sample implementations" on page 19).

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 Tools directory to learn more about how to build your own tool.

Flash includes an earlier (obfuscated) version of the PolyStar.jsfl script that you must remove in order to use the sample PolyStar.jsfl file.

To remove the earlier version of the PolyStar.jsfl file that was installed with Flash:

  1. Select Edit > Customize Tools Panel (Windows) or Flash > Customize Tools Panel (Macintosh).

  2. In the Customize Tools Panel dialog box, click the Rectangle tool on the left side of the dialog box.

    The Rectangle tool and the PolyStar tool should now be listed in the Current Selection list on the right side of the dialog box.

  3. Select the PolyStar tool in the Current Selection list.

  4. Click Remove.

  5. Click OK.

  6. Quit Flash.

  7. Remove only the PolyStar.jsfl file from the Configuration/Tools folder (see "Saving JSFL files" on page 7). The PolyStar.xml and PolyStar.png files are needed by the new PolyStar.jsfl file that you will install later. When you restart Flash, the PolyStar tool no longer appears in the Customize Tools Panel dialog box.

To install the updated PolyStar example files:

  1. If Flash is running, exit the application.

  2. Copy the new PolyStar.jsfl file to the Configuration/Tools folder (see "Saving JSFL files" on page 7). The PolyStar.xml and PolyStar.png files that you see in this folder are needed by the new PolyStar.jsfl file.

  3. Restart Flash.

  4. Select Edit > Customize Tools Panel (Windows) or Flash > Customize Tools Panel (Macintosh). You should see PolyStar tool in the available tools list.

  5. Click the Rectangle tool at the left side of the Customize Tools Panel dialog box. The Rectangle Tool should appear in the Current Selection list at the right side of the dialog box.

  6. Select the PolyStar tool from the Available Tools list.

  7. Click Add.

  8. Click OK.

    The PolyStar tool now appears in the Rectangle tool pop-up menu.

Sample Trace Bitmap panel

A set of files named TraceBitmap.fla and TraceBitmap.swf are located in the ExtendingFlash/TraceBitmapPanel folder (see "Sample implementations" on page 19). These files 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 Configuration/WindowSWF folder (see "Saving JSFL files" on page 7).

  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 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.

Sample DLL

A sample DLL implementation is located in the ExtendingFlash/dllSampleComputeSum folder (see "Sample implementations" on page 19). For more information about building DLLs, see Chapter 3, "C-Level Extensibility," on page 533.

     < Day Day Up > 


    Developing Extensions for Macromedia Flash 8
    Developing Extensions for Macromedia Flash 8
    ISBN: 032139416X
    EAN: 2147483647
    Year: 2005
    Pages: 81

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net