http://www.adobe.com 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: 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

    User Flash Player Trust Directory

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

    The Flash movie to load into ESTK.

    The context in which this snippet can run.


    The documentation for this class was generated from the following file:
  • Adobe Solutions NetworkCopyright© 2008 Adobe Systems Incorporated. All rights reserved.

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