Adobe ExtendScript Toolkit

ExtendScript ToolKit

# ActionScriptDemo Class Reference

#### Usage

1. Read the section on Flash Player Security below.
2. Run the sample in the ExtendScript Toolkit (see Readme.txt).
3. The dialog window appears with a start flash button than when activated loads the Flash Movie.
4. The Flash movie contains three buttons and two text areas.
5. Clicking the buttons calls the JavaScript functions from the ActionScript environment and passes data as arguments to the functions.

#### Description

This sample shows how to use the ScriptUI FlashPlayer element to invoke JavaScript functions in ActionScript, and ActionsScript functions in JavaScript. It passes simple data between the two scripting environments, and displays passed values.

The Flash application to be used with this sample must be located in the resources folder and have the same name as this sample. The application is a Flash presentation. The ActionScript script shows how to import the ExternalInterface class, and how to register and call external functions, which are defined in this script. The ActionScript source code is provided as a comment block in the FlashDemo.JSX file.

#### Flash Player Security

Adobe ExtendScript supports the Flash Player client-runtime security model. This affects which SWF files can be loaded into ESTK and run successfully. You must set the correct security permission to allow the operation that the SWF file performs. There are 3 basic levels of security for local SWF files:

- Access the local file system only (default): A local SWF file can read from the local file system and universal naming convention (UNC) network paths, but cannot communicate with the Internet.
- Access the network only: A local SWF file can access the network, but not the local file system where it is installed.
- Access to the local file system and the network: A local SWF file can read from the local file system where it is installed, read and write to and from servers, and can cross-script other SWF files on either the network or the local file system. These files are trusted.

To create a SWF file that can 'access the local file system only' or 'access the network only', edit the FLA file and do the following:
- In Adobe Flash, select File > Publish Settings
- In the dialog, select the Flash tab
- Set the option for 'Local playback security' to either 'access network only' or 'access local files only'

  For more information on local file security see:

  http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001136.html
  http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001604.html

  To allow a local file to be trusted,(that is, allow a SWF file to access both network and local files as well as allow cross scripting), you can either create a trust file, or use the Settings Manager. This sample and the accompanying SWF file have been created with the default permissions; therefore to run the sample correctly, you must use one of these techniques, as described in the following sections.

  #### Create a Trust File

  You can create a trust file in either the Global Flash Player Trust directory or in the User Flash Player Trust directory. A Trust file is a simple text file with a .cfg file extension, that contains the location to a local SWF file. For example, to run this sample as a trusted file on Windows, create a text file that contains the path and file name (replacing SDKINSTALL with your local SDK installation location):

      	SDKINSTALL\Resources\ActionScriptDemo.swf

  Save this text file with the extension .cfg in a folder named 'FlashPlayerTrust' (which you may need to create), in one of the following locations, depending on the platform and users for which the SWF should be trusted.

  Global Flash Player Trust Directory

  - In Windows: system\Macromed\Flash\FlashPlayerTrust
    - for example:

          C:\windows\system32\Macromed\Flash\FlashPlayerTrust

  - In Mac OS: app support/Macromedia/FlashPlayerTrust
    - for example:

          /Library/Application Support/Macromedia/FlashPlayerTrust

  User Flash Player Trust Directory

  - In Windows: app data\Macromedia\Flash Player\#Security\FlashPlayerTrust
    - for example:

          C:\Documents and Settings\your-user-name\Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust

  - In Mac OS: app data/Macromedia/Flash Player/#Security/FlashPlayerTrust
    - for example:

          /Users/your-user-name/Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust

  #### Use the Settings Manager

  The Settings Manager allows you to make changes to various global settings, including whether to allow a SWF file to be trusted. When ESTK loads a non-trusted file that attempts a trusted action, the Flash Player presents a dialog giving the user the choice to navigate to the Settings Manager.
  - When you run this sample (if you have not created a trust file for it) ESTK displays a security dialog warning about the SWF file. Click 'Settings...' in this dialog.
    The Adobe Flash Player Settings Manager opens in a web browser. (You may need to install the Adobe Flash Plugin before you see this page correctly.)
  - On the Global Security Settings tab (the default tab), click 'Edit Locations' and choose 'Add Location' from the drop down list.
    A dialog appears showing the path of the SWF that Bridge is trying to load.
  - Click 'Browse for files', navigate to the location of the SWF file (SDKINSTALL/Resources/ActionScriptDemo.swf) and click OK (There is no confirm dialog).
  - Close the web browser and restart ESTK.
  ESTK can now play the Flash movie and data can be passed between the two scripting environments.

  For more information on the Settings Manager and Trust files see:

  http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001952.html

  List of all members.

  ## Public Member Functions

  void | ActionScriptDemo ()
  Boolean | run ()
  | Functional part of this Snippet.
  Boolean | canRun ()
  | Determines whether snippet can be run given current context.

  ## Public Attributes

  File | flashFile
  | The Flash movie to load into ESTK.
  String | requiredContext
  | The context in which this snippet can run.

  ## Constructor & Destructor Documentation

  void ActionScriptDemo::ActionScriptDemo | ( |  | ) |

  ## Member Function Documentation

  Boolean ActionScriptDemo::run | ( |  | ) |

  Functional part of this Snippet.

  Creates a Dialog window and adds a FlashPlayer control. A button on the dialog enables the activation of loading the flash player which extends the functionality with buttons that interact with the JavaScript functions; getJavaScriptString. getJavaScriptNumber and launchJavaScript. a flash movie.

  Returns:
    True if the snippet ran as expected, false otherwise

  Boolean ActionScriptDemo::canRun | ( |  | ) |

  Determines whether snippet can be run given current context.

  The snippet fails if these preconditions are not met:

  - The Flash file must be available
  Returns:
    True if this snippet can run, false otherwise

  ## Member Data Documentation

  File ActionScriptDemo::flashFile

  The Flash movie to load into ESTK.

  String ActionScriptDemo::requiredContext

  The context in which this snippet can run.

  The documentation for this class was generated from the following file:
  - ActionScriptDemo.jsx

Copyright© 2008 Adobe Systems Incorporated. All rights reserved.

Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks