flash object (fl)

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The flash object represents the Flash application. You can use flash or fl to refer to this object. This documentation uses fl throughout.

Method summary for the flash object

The following methods can be used with the flash object.

Method

Description

fl.browseForFileURL()

Opens a File Open or File Save system dialog box and lets the user specify a file to be opened or saved.

fl.browseForFolderURL()

Displays a Browse for Folder dialog box and lets the user select a folder.

fl.closeAll()

Closes all open documents, displaying the Save As dialog box for any documents that were not previously saved.

fl.closeDocument()

Closes the specified document.

fl.closeProject()

Closes the Flash Project (FLP) file that is currently open.

fl.createDocument()

Opens a new document and selects it.

fl.createProject()

Creates a Flash Project (FLP) file with the specified name.

fl.enableImmediateUpdates()

Lets the script developer enable immediate visual updates of the timeline when executing effects.

fl.fileExists()

Checks whether a file already exists on disk.

fl.findDocumentIndex()

Returns an array of integers that represent the position of a document in the fl.documents array.

fl.getAppMemoryInfo()

Returns an integer that represents the number of bytes being used in a specified area of Flash.exe memory.

fl.getDocumentDOM()

Retrieves the DOM (Document object) of the currently active document.

fl.getProject()

Returns a Project object that represents the currently open project.

fl.mapPlayerURL()

Maps an escaped Unicode URL to a UTF-8 or MBCS URL.

fl.openDocument()

Opens a Flash (FLA) document for editing in a new Flash Document window and gives it the focus.

fl.openProject()

Opens a Flash Project (FLP) file in the Flash authoring tool for editing.

fl.openScript()

Opens a script (JSFL, AS, ASC) or other file (XML, TXT) in the Flash text editor.

fl.quit()

Quits Flash, prompting the user to save any changed documents.

fl.reloadEffects()

Reloads all effects descriptors defined in the user's Configuration Effects folder.

fl.reloadTools()

Rebuilds the Tools panel from the toolconfig.xml file. Used only when creating extensible tools.

fl.revertDocument()

Reverts the specified FLA document to its last saved version.

fl.runScript()

Executes a JavaScript file.

fl.saveAll()

Saves all open documents, displaying the Save As dialog box for any documents that were not previously saved.

fl.saveDocument()

Saves the specified document as a FLA document.

fl.saveDocumentAs()

Displays the Save As dialog box for the specified document.

fl.setActiveWindow()

Sets the active window to be the specified document.

fl.showIdleMessage()

Lets you disable the warning about a script running too long.

fl.trace()

Sends a text string to the Output panel.


Property summary for the flash object

The following properties can be used with the flash object.

Properties

Description

fl.activeEffect

Read-only; the Effect object for the current effect being applied.

fl.componentsPanel

Read-only; a componentsPanel object, which represents the Components panel.

fl.configDirectory

Read-only; a string that specifies the full path for the local user's Configuration folder as a platform-specific path.

fl.configURI

Read-only; a string that specifies the full path for the local user's Configuration directory as a file:/// URI.

fl.contactSensitiveSelection

A Boolean value that specifies whether Contact Sensitive selection mode is enabled.

fl.createNewDocList

Read-only; an array of strings that represent the various types of documents that can be created.

fl.createNewDocListType

Read-only; an array of strings that represent the file extensions of the types of documents that can be created.

fl.createNewTemplateList

Read-only; an array of strings that represent the various types of templates that can be created.

fl.documents

Read-only; an array of Document objects (see Document object) that represent the documents (FLA files) that are currently open for editing.

fl.drawingLayer

Read-only; the drawingLayer object that an extensible tool should use when the user wants to temporarily draw while dragging.

fl.effects

Read-only; an array of Effect objects (see Effect object), based on XML parameter file.

fl.Math

Read-only; the Math object, which provides methods for matrix and point operations.

fl.mruRecentFileList

Read-only; an array of the complete filenames in the Most Recently Used (MRU) list that the Flash authoring tool manages.

fl.mruRecentFileListType

Read-only; an array of the file types in the MRU list that the Flash authoring tool manages.

fl.objectDrawingMode

A Boolean value that specifies whether the object drawing model is enabled.

fl.outputPanel

Read-only; reference to the outputPanel object.

fl.tools

Read-only; an array of Tools objects.

fl.version

Read-only; the long string version of the Flash authoring tool, including platform.

fl.xmlui

Read-only; an XMLUI object.


fl.activeEffect

Availability

Flash MX 2004.

Usage

fl.activeEffect

Description

Read-only property; the Effect object for the current effect being applied. For a list of properties available to fl.activeEffect, see "Property summary for the Effect object" on page 190.

Example

The following example stores an object that represents the current effect in the ef variable.

var ef = fl.activeEffect;

fl.browseForFileURL()

Availability

Flash MX 2004.

Usage

fl.browseForFileURL( browseType [, title [, previewArea ] ])

Parameters

browseType A string that specifies the type of file browse operation. Acceptable values are "open", "select" or "save". The values "open" and "select" open the system File Open dialog box. Each value is provided for compatibility with Dreamweaver. The value "save" opens a system File Save dialog box.

title A string that specifies the title for the File Open or File Save dialog box. If this parameter is omitted, a default value is used. This parameter is optional.

previewArea An optional parameter that is ignored by Flash and Fireworks and is present only for compatibility with Dreamweaver.

Returns

The URL of the file, expressed as a file:/// URI; returns null if the user cancels out of the dialog box.

Description

Method; opens a File Open or File Save system dialog box and lets the user specify a file to be opened or saved.

Example

The following example lets the user choose a FLA file to open and then opens the file. (The fl.browseForFileURL() method can browse for any type of file, but fl.openDocument() can open only FLA files.)

var fileURL = fl.browseForFileURL("open", "Select file"); var doc = fl.openDocument(fileURL);

See also

fl.browseForFolderURL()

fl.browseForFolderURL()

Availability

Flash 8.

Usage

fl.browseForFolderURL( [ description ] )

Parameters

description An optional string that specifies the description of the Browse For Folder dialog box. If this parameter is omitted, nothing is shown in the description area.

Returns

The URL of the folder, expressed as a file:/// URI; returns null if the user cancels out of the dialog box.

Description

Method; displays a Browse for Folder dialog box and lets the user select a folder.

Note

The title of the dialog box is always "Browse for Folder." Use the description parameter to add more detail in the description area under the title, such as "Select a folder" or "Select the path that contains the profile you want to import."


Example

The following example lets the user select a folder and then displays a list of files in that folder.

var folderURI = fl.browseForFolderURL("Select a folder."); var folderContents = FLfile.listFolder(folderURI);

See also

fl.browseForFileURL(), FLfile object

fl.closeAll()

Availability

Flash MX 2004.

Usage

fl.closeAll()

Parameters

None.

Returns

Nothing.

Description

Method; closes all open documents, displaying the Save As dialog box for any documents that were not previously saved. The method prompts the user, if necessary, but does not terminate the application. See also fl.closeDocument().

Example

The following code closes all open documents.

fl.closeAll();

fl.closeDocument()

Availability

Flash MX 2004.

Usage

fl.closeDocument( documentObject [, bPromptToSaveChanges] )

Parameters

documentObject, [ bPromptToSaveChanges ]

documentObject A Document object. If documentObject refers to the active document, the Document window might not close until the script that calls this method finishes executing.

bPromptToSaveChanges A Boolean value. If it is false, the user is not prompted if the document contains unsaved changes; that is, the file is closed and the changes are discarded. If the value is true, and if the document contains unsaved changes, the user is prompted with the standard yes-or-no dialog box. The default value is true. This parameter is optional.

Returns

A Boolean value: true if successful; false otherwise.

Description

Method; closes the specified document. See also fl.closeAll().

Example

The following example illustrates two ways of closing a document.

// Closes the specified document and prompts to save changes. fl.closeDocument(fl.documents[0]); fl.closeDocument(fl.documents[0] , true); // Use of true is optional. // Closes the specified document without prompting to save changes. fl.closeDocument(fl.documents[0], false);

fl.closeProject()

Availability

Flash 8.

Usage

fl.closeProject()

Parameters

None.

Returns

A Boolean value of TRue if the project was successfully closed; false if there is no project file open.

Description

Method; closes the Flash Project (FLP) file that is currently open.

The following example attempts to close a project file, and displays a message indicating whether the file was successfully closed.

fl.trace("The project was" + (fl.closeProject() ? "closed" : "not   closed"));

See also

fl.getProject(), fl.openProject(), Project object

fl.componentsPanel

Availability

Flash MX 2004.

Usage

fl.componentsPanel

Description

Read-only property; a componentsPanel object, which represents the Components panel.

Example

The following example stores a componentsPanel object in the comPanel variable.

var comPanel = fl.componentsPanel;

fl.configDirectory

Availability

Flash MX 2004.

Usage

fl.configDirectory

Description

Read-only property; a string that specifies the full path for the local user's Configuration directory in a platform-specific format. To specify this path as a file:/// URI, which is not platform-specific, use fl.configURI.

Example

The following example displays the Configuration directory in the Output panel.

fl.trace( "My local configuration directory is " + fl.configDirectory );

fl.configURI

Availability

Flash MX 2004.

Usage

fl.configURI

Description

Read-only property; a string that specifies the full path for the local user's Configuration directory as a file:/// URI. See also fl.configDirectory.

Example

The following example runs a specified script. Using fl.configURI lets you specify the location of the script without knowing which platform the script is running on.

// To run a command in your commands menu, change "Test.Jsfl" // to the command you want to run in the line below. fl.runScript( fl.configURI + "Commands/Test.jsfl" );

fl.contactSensitiveSelection

Availability

Flash 8.

Usage

fl.contactSensitiveSelection

Description

A Boolean value that specifies whether Contact Sensitive selection mode is enabled (TRue) or not (false).

Example

The following example shows how to disable Contact Sensitive selection mode before making a selection, and then how to reset it to its original value after making the selection.

var contact = fl.contactSensitiveSelection; fl.contactSensitiveSelection = false; // Insert selection code here. fl.contactSensitiveSelection = contact;

fl.createDocument()

Availability

Flash MX 2004.

Usage

fl.createDocument( [docType] )

Parameters

docType A string that specifies the type of document to create. Acceptable values are "timeline", "presentation", and "application". The default value is "timeline". This parameter is optional.

Returns

The Document object for the newly created document, if the method is successful. If an error occurs, the value is undefined.

Description

Method; opens a new document and selects it. Values for size, resolution, and color are the same as the current defaults.

Example

The following example creates different types of documents.

// Create a timeline-based Flash document. fl.createDocument(); fl.createDocument("timeline"); // Create a Slide Presentation document. fl.createDocument("presentation"); // Create a Form Application document. fl.createDocument("application");

fl.createNewDocList

Availability

Flash MX 2004.

Usage

fl.createNewDocList

Description

Read-only property; an array of strings that represent the various types of documents that can be created.

Example

The following example displays the types of documents that can be created in the Output panel.

fl.trace("Number of choices " + fl.createNewDocList.length); for (i = 0; i < fl.createNewDocList.length; i++)   fl.trace("choice: " + fl.createNewDocList[i]);

fl.createNewDocListType

Availability

Flash MX 2004.

Usage

fl.createNewDocListType

Description

Read-only property; an array of strings that represent the file extensions of the types of documents that can be created. The entries in the array correspond directly (by index) to the entries in the fl.createNewDocList array.

Example

The following example displays the extensions of the types of documents that can be created in the Output panel.

fl.trace("Number of types " + fl.createNewDocListType.length); for (i = 0; i < fl.createNewDocListType.length; i++) fl.trace("type: " +   fl.createNewDocListType[i]);

fl.createNewTemplateList

Availability

Flash MX 2004.

Usage

fl.createNewTemplateList

Description

Read-only property; an array of strings that represent the various types of templates that can be created.

Example

The following example displays the types of templates that can be created in the Output panel.

fl.trace("Number of template types: " + fl.createNewTemplateList.length);   for (i = 0; i < fl.createNewTemplateList.length; i++) fl.trace("type: " +   fl.createNewTemplateList[i]);

fl.createProject()

Availability

Flash 8.

Usage

fl.createProject( fileURI [ , name ] )

Parameters

fileURI A string, expressed as a file:/// URI, that specifies the name of the Flash Project (FLP) file to be created.

name An optional string that is displayed as the project name in the Project panel. If name is omitted, the name of the FLP file (excluding path or extension) is displayed in the Project panel.

Returns

A Project object if the method is successful; undefined if the file can't be created (for example, fileURI contains a directory that doesn't exist).

Description

Method; creates a Flash Project (FLP) file with the specified name. If the file can't be created, an informational dialog box is displayed. If the file already exists, a dialog box is displayed asking whether to overwrite the file.

Example

The following example creates a project file in the specified directory (if it exists) and specifies a name to display in the Project panel.

var myProject = fl.createProject("file:///C|/Projects/   MasterProject_2005.flp", "Master Project");

See also

fl.getProject(), fl.openProject(), Project object

fl.documents

Availability

Flash MX 2004.

Usage

fl.documents

Description

Read-only property; an array of Document objects (see Document object) that represent the documents (FLA files) that are currently open for editing.

Example

The following example stores an array of open documents in the docs variable.

var docs = fl.documents;

The following example displays the names of currently open documents in the Output panel.

for (doc in fl.documents) {   fl.trace(fl.documents[doc].name); }

fl.drawingLayer

Availability

Flash MX 2004.

Usage

fl.drawingLayer

Description

Read-only property; the drawingLayer object that an extensible tool should use when the user wants to temporarily draw while dragging (for example, when creating a selection marquee).

Example

See drawingLayer.setColor().

fl.effects

Availability

Flash MX 2004.

Usage

fl.effects

Description

Read-only property; an array of Effect objects (see Effect object), based on XML parameter file. These are not effects, but a description of effects. The array length corresponds to the number of effects (based on the XML parameter definition files, not the number of JSFL implementation files) registered when the program opens.

Example

The following example returns the first registered effect:

ef = fl.effects[0]

fl.enableImmediateUpdates()

Availability

Flash MX 2004.

Usage

fl.enableImmediateUpdates(bEnableUpdates)

Parameters

bEnableUpdates A Boolean value that specifies whether to enable (TRue) or disable (false) immediate visual updates of the timeline when executing effects.

Returns

Nothing.

Description

Method; lets the script developer enable immediate visual updates of the timeline when executing effects. Immediate updates are normally suppressed so the user does not see intermediate steps that can be visually distracting and can make the effect appear to take longer than necessary. This method is purely for debugging purposes and should not be used in effects that are deployed in the field. After the effect completes, the internal state is reset to suppress immediate updates.

Example

The following example enables immediate updates.

fl.enableImmediateUpdates(true) ; fl.trace("Immediate updates are enabled");

fl.fileExists()

Availability

Flash MX 2004.

Usage

fl.fileExists( fileURI )

Parameters

fileURI A string, expressed as a file:/// URI, that contains the path to the file.

Returns

A Boolean value: TRue if the file exists on disk; false otherwise.

Description

Method; checks whether a file already exists on disk.

Example

The following example displays TRue or false in the Output panel for each specified file, depending on whether the file exists.

alert(fl.fileExists("file:///C|/example.fla")); alert(fl.fileExists("file:///C|/example.jsfl")); alert(fl.fileExists(""));

fl.findDocumentIndex()

Availability

Flash MX 2004.

Usage

fl.findDocumentIndex( name )

Parameters

name The document name for which you want to find the index. The document must be open.

Returns

An array of integers that represent the position of the document name in the fl.documents array.

Description

Method; returns an array of integers that represent the position of the document name in the fl.documents array. More than one document with the same name can be open (if the documents are located in different folders).

Example

The following example displays information about the index position of any open files named test.fla in the Output panel:

var filename = "test.fla" var docIndex = fl.findDocumentIndex(filename); for (var index in docIndex)   fl.trace(filename + " is open at index " + docIndex[index]);

See also

fl.documents

fl.getAppMemoryInfo()

Availability

Flash 8 (Windows only).

Usage

fl.getAppMemoryInfo( memType )

Parameters

memType An integer that specifies the memory utilization area to be queried. For a list of acceptable values, see the following description.

Returns

An integer that represents the number of bytes being used in a specified area of Flash.exe memory.

Description

Method (Windows only); returns an integer that represents the number of bytes being used in a specified area of Flash.exe memory. Use the following table to determine which value you want to pass as memType.

memType

Resource data

0

PAGEFAULTCOUNT

1

PEAKWORKINGSETSIZE

2

WORKINGSETSIZE

3

QUOTAPEAKPAGEDPOOLUSAGE

4

QUOTAPAGEDPOOLUSAGE

5

QUOTAPEAKNONPAGEDPOOLUSAGE

6

QUOTANONPAGEDPOOLUSAGE

7

PAGEFILEUSAGE

8

PEAKPAGEFILEUSAGE


Example

The following example displays the current working memory consumption.

var memsize = fl.getAppMemoryInfo(2); fl.trace("Flash current memory consumption is " + memsize + " bytes or " +   memsize/1024 + " KB");

fl.getDocumentDOM()

Availability

Flash MX 2004.

Usage

fl.getDocumentDOM()

Parameters

None.

Returns

A Document object, or null if no documents are open.

Description

Method; retrieves the DOM (Document object) of the currently active document (FLA file). If one or more documents are open but a document does not currently have focus (for example, if a JSFL file has focus), retrieves the DOM of the most recently active document.

Example

The following example displays the name of the current or most recently active document in the Output panel:

var currentDoc = fl.getDocumentDOM(); fl.trace(currentDoc.name);

fl.getProject()

Availability

Flash 8.

Usage

fl.getProject()

Parameters

None.

Returns

A Project object that represents the currently open project. If no project is currently open, returns undefined.

Description

Method; returns a Project object that represents the currently open project.

Example

The following example displays the name of the currently open project in the Output panel.

fl.trace("Current project: " + fl.getProject().name);

See also

fl.createProject(), fl.openProject(), Project object

fl.mapPlayerURL()

Availability

Flash MX 2004.

Usage

fl.mapPlayerURL( URI [, returnMBCS] )

Parameters

URI A string that contains the escaped Unicode URL to map.

returnMBCS A Boolean value that you must set to TRue if you want an escaped MBCS path returned. Otherwise, the method returns UTF-8. The default value is false. This parameter is optional.

Returns

A string that is the converted URL.

Description

Method; maps an escaped Unicode URL to a UTF-8 or MBCS URL. Use this method when the string will be used in ActionScript to access an external resource. You must use this method if you need to handle multibyte characters.

Example

The following example converts a URL to UTF-8 so the player can load it.

var url = MMExecute( "fl.mapPlayerURL(" + myURL + ", false);" ); mc.loadMovie( url);

fl.Math

Availability

Flash MX 2004.

Usage

fl.Math

Description

Read-only property; the Math object provides methods for matrix and point operations.

Example

The following shows the transformation matrix of the selected object, and its inverse.

// Select an element on the Stage and then run this script. var mat =fl.getDocumentDOM().selection[0].matrix; for(var prop in mat){   fl.trace("mat."+prop+" = " + mat[prop]); } var invMat = fl.Math.invertMatrix( mat ); for(var prop in invMat) { fl.trace("invMat."+prop+" = " + invMat[prop]); }

fl.mruRecentFileList

Availability

Flash MX 2004.

Usage

fl.mruRecentFileList

Description

Read-only property; an array of the complete filenames in the Most Recently Used (MRU) list that the Flash authoring tool manages.

Example

The following example displays the number of recently opened files, and the name of each file, in the Output panel.

fl.trace("Number of recently opened files: " +   fl.mruRecentFileList.length); for (i = 0; i < fl.mruRecentFileList.length; i++) fl.trace("file: " +   fl.mruRecentFileList[i]);

fl.mruRecentFileListType

Availability

Flash MX 2004.

Usage

fl.mruRecentFileListType

Description

Read-only property; an array of the file types in the MRU list that the Flash authoring tool manages. This array corresponds to the array in the fl.mruRecentFileList property.

Example

The following example displays the number of recently opened files, and the type of each file, in the Output panel.

fl.trace("Number of recently opened files: " +   fl.mruRecentFileListType.length); for (i = 0; i < fl.mruRecentFileListType.length; i++) fl.trace("type: " +   fl.mruRecentFileListType[i]);

fl.objectDrawingMode

Availability

Flash 8.

Usage

fl.objectDrawingMode

Description

Property; a Boolean value that specifies whether the object drawing mode is enabled (TRue) or the merge drawing mode is enabled (false).

Example

The following example toggles the state of the object drawing mode:

var toggleMode = fl.objectDrawingMode; if (toggleMode) {   fl.objectDrawingMode = false; } else {   fl.objectDrawingMode = true; }

fl.openDocument()

Availability

Flash MX 2004.

Usage

fl.openDocument( fileURI )

Parameters

fileURI A string, expressed as a file:/// URI, that specifies the name of the file to be opened.

Returns

The Document object for the newly opened document, if the method is successful. If the file is not found, or is not a valid FLA file, an error is reported and the script is cancelled.

Description

Method; opens a Flash document (FLA file) for editing in a new Flash Document window and gives it the focus. For a user, the effect is the same as selecting File > Open and then selecting a file. If the specified file is already open, the window that contains the document comes to the front. The window that contains the specified file becomes the currently selected document.

Example

The following example opens a file named Document.fla that is stored in the root directory on the C drive, stores a Document object representing that document in the doc variable, and sets the document to be the currently selected document. That is, until focus is changed, fl.getDocumentDOM() refers to this document.

var doc = fl.openDocument("file:///c|/Document.fla");

fl.openProject()

Availability

Flash MX 2004; return value changed in Flash 8.

Usage

fl.openProject( fileURI )

Parameters

fileURI A string, expressed as a file:/// URI, that specifies the path of the Flash Project (FLP) file to open.

Returns

Nothing in Flash MX 2004; a Project object in Flash 8.

Description

Method; opens a Flash Project (FLP) file in the Flash authoring tool for editing.

Example

The following example opens a project file named myProjectFile.flp that is stored in the root directory on the C drive.

fl.openProject("file:///c|/myProjectFile.flp");

See also

fl.closeProject(), fl.createProject(), fl.getProject(), Project object

fl.openScript()

Availability

Flash MX 2004.

Usage

fl.openScript( fileURI )

Parameters

fileURI A string, expressed as a file:/// URI, that specifies the path of the JSFL, AS, ASC, XML, TXT or other file that should be loaded into the Flash text editor.

Returns

Nothing.

Description

Method; opens a script (JSFL, AS, ASC) or other file (XML, TXT) in the Flash text editor.

Example

The following example opens a file named my_test.jsfl that is stored in the /temp directory on the C drive.

fl.openScript("file:///c|/temp/my_test.jsfl");

fl.outputPanel

Availability

Flash MX 2004.

Usage

fl.outputPanel

Description

Read-only property; reference to the outputPanel object.

Example

See outputPanel object.

fl.quit()

Availability

Flash MX 2004.

Usage

fl.quit( [bPromptIfNeeded] )

Parameters

bPromptIfNeeded A Boolean value that is true (default) if you want the user to be prompted to save any modified documents. Set this parameter to false if you do not want the user to be prompted to save modified documents. In the latter case, any modifications in open documents will be discarded and the application will exit immediately. Although it is useful for batch processing, use this method with caution. This parameter is optional.

Returns

Nothing.

Description

Method; quits Flash, prompting the user to save any changed documents.

Example

The following example illustrates quitting with and without asking to save modified documents.

// Quit with prompt to save any modified documents. fl.quit(); fl.quit(true); // True is optional. // Quit without saving any files. fl.quit(false);

fl.reloadEffects()

Availability

Flash MX 2004.

Usage

fl.reloadEffects()

Parameters

None.

Returns

Nothing.

Description

Method; reloads all effects descriptors defined in the user's Configuration Effects folder. This permits you to rapidly change the scripts during development, and it provides a mechanism to improve the effects without relaunching the application. This method works best if used in a command placed in the Commands folder.

Example

The following example is a one-line script that you can place in the Commands folder. When you need to reload effects, go to the Commands menu and execute the script.

fl.reloadEffects();

fl.reloadTools()

Availability

Flash MX 2004.

Usage

fl.reloadTools()

Parameters

None.

Returns

Nothing.

Description

Method; rebuilds the Tools panel from the toolconfig.xml file. This method is used only when creating extensible tools. Use this method when you need to reload the Tools panel, for example, after modifying the JSFL file that defines a tool that is already present in the panel.

Example

The following example is a one-line script that you can place in the Commands folder. When you need to reload the Tools panel, run the script from the Commands menu.

fl.reloadTools();

fl.revertDocument()

Availability

Flash MX 2004.

Usage

fl.revertDocument( documentObject )

Parameters

documentObject A Document object. If documentObject refers to the active document, the Document window might not revert until the script that calls this method finishes executing.

Returns

A Boolean value: true if the Revert operation completes successfully; false otherwise.

Description

Method; reverts the specified FLA document to its last saved version. Unlike the File > Revert menu option, this method does not display a warning window that asks the user to confirm the operation. See also document.revert() and document.canRevert().

Example

The following example reverts the current FLA document to its last saved version; any changes made since the last save are lost.

fl.revertDocument(fl.getDocumentDOM());

fl.runScript()

Availability

Flash MX 2004.

Usage

fl.runScript( fileURI [, funcName [, arg1, arg2, ...] ])

Parameters

fileURI A string, expressed as a file:/// URI, that specifies the name of the script file to execute.

funcName A string that identifies a function to execute in the JSFL file that is specified in fileURI. This parameter is optional.

arg An optional parameter that specifies one or more arguments to be passed to funcname.

Returns

The function's result as a string, if funcName is specified; otherwise, nothing.

Description

Method; executes a JavaScript file. If a function is specified as one of the arguments, it runs the function and also any code in the script that is not within the function. The rest of the code in the script runs before the function is run.

Example

Suppose there is a script file named testScript.jsfl in the root directory on the C drive, and its contents are as follows:

function testFunct(num, minNum) {   fl.trace("in testFunct: 1st arg: " + num + " 2nd arg: " + minNum); } for (i=0; i<2; i++) {   fl.trace("in for loop i=" + i); } fl.trace("end of for loop"); // End of testScript.jsfl

If you issue the following command:

fl.runScript("file:///C|/testScript.jsfl", "testFunct", 10, 1);

The following information appears in the Output panel:

in for loop i=0 in for loop i=1 end of for loop in testFunct: 1st arg: 10 2nd arg: 1

You can also just call testScript.jsfl without executing a function:

fl.runScript("file:///C|/testScript.jsfl");

which produces the following in the Output panel:

in for loop i=0 in for loop i=1 end of for loop

fl.saveAll()

Availability

Flash MX 2004.

Usage

fl.saveAll()

Parameters

None.

Returns

Nothing.

Description

Method; saves all open documents.

NOTE

If a file has never been saved, or has not been modified since the last time it was saved, the file isn't saved. To allow an unsaved or unmodified file to be saved, use fl.saveDocumentAs().


Example

The following example saves all open documents.

fl.saveAll();

See also

document.save(), document.saveAndCompact(), fl.saveDocument(), fl.saveDocumentAs()

fl.saveDocument()

Availability

Flash MX 2004.

Usage

fl.saveDocument( document [, fileURI] )

Parameters

document A Document object that specifies the document to be saved. If document is null, the active document is saved.

fileURI A string, expressed as a file:/// URI, that specifies the name of the saved document. If the fileURI parameter is null or omitted, the document is saved with its current name. This parameter is optional.

Returns

A Boolean value: true if the save operation completes successfully; false otherwise.

NOTE

If the file has never been saved, or has not been modified since the last time it was saved, the file isn't saved and false is returned. To allow an unsaved or unmodified file to be saved, use fl.saveDocumentAs().


Description

Method; saves the specified document as a FLA document.

Example

The following example saves the current document and two specified documents.

// Save the current document. alert(fl.saveDocument(fl.getDocumentDOM())); // Save the specified documents. alert(fl.saveDocument(fl.documents[0], "file:///C|/example1.fla")); alert(fl.saveDocument(fl.documents[1],"file:///C|/example2.fla"));

See also

document.save(), document.saveAndCompact(), fl.saveAll(), fl.saveDocumentAs()

fl.saveDocumentAs()

Availability

Flash MX 2004.

Usage

fl.saveDocumentAs( document )

Parameters

document A Document object that specifies the document to save. If document is null, the active document is saved.

Returns

A Boolean value: true if the Save As operation completes successfully; false otherwise.

Description

Method; displays the Save As dialog box for the specified document.

Example

The following example prompts the user to save the specified document, and then displays an alert message that indicates whether the document was saved.

alert(fl.saveDocumentAs(fl.documents[1]));

See also

document.save(), document.saveAndCompact(), fl.saveAll(), fl.saveDocument()

fl.setActiveWindow()

Availability

Flash MX 2004.

Usage

fl.setActiveWindow( document [, bActivateFrame] )

Parameters

document A Document object that specifies the document to select as the active window.

bActivateFrame An optional parameter that is ignored by Flash and Fireworks and is present only for compatibility with Dreamweaver.

Returns

Nothing.

Description

Method; sets the active window to be the specified document. This method is also supported by Dreamweaver and Fireworks. If the document has multiple views (created by Edit In New Window), the first view is selected.

Example

The following example shows two ways to save a specified document.

fl.setActiveWindow(fl.documents[0]); var theIndex = fl.findDocumentIndex("myFile.fla"); fl.setActiveWindow(fl.documents[theIndex]);

fl.showIdleMessage()

Availability

Flash 8.

Usage

fl.showIdleMessage( show )

Parameters

show A Boolean value specifying whether to enable or disable the warning about a script running too long.

Returns

Nothing.

Description

Method; lets you disable the warning about a script running too long (pass false for show). You might want to do this when processing batch operations that take a long time to complete. To re-enable the alert, issue the command again, this time passing TRue for show.

Example

The following example illustrates how to disable and re-enable the warning about a script running too long.

fl.showIdleMessage(false); var result = timeConsumingFunction(); fl.showIdleMessage(true);

fl.tools

Availability

Flash MX 2004.

Usage

fl.tools

Description

Read-only property; an array of Tools objects (see Tools object). This property is used only when creating extensible tools.

fl.trace()

Availability

Flash MX 2004.

Usage

fl.trace( message )

Parameters

message A string that appears in the Output panel.

Returns

Nothing.

Description

Method; sends a text string to the Output panel, terminated by a new line, and displays the Output panel if it is not already visible. This method is identical to outputPanel.trace(), and works in the same way as the trace() statement in ActionScript.

To send a blank line, use fl.trace("") or fl.trace("\n"). You can use the latter command inline, making \n a part of the message string.

Example

The following example displays several lines of text in the Output panel:

fl.outputPanel.clear(); fl.trace("Hello World!!!"); var myPet = "cat"; fl.trace("\nI have a " + myPet); fl.trace(""); fl.trace("I love my " + myPet); fl.trace("Do you have a " + myPet +"?");

fl.version

Availability

Flash MX 2004.

Usage

fl.version

Description

Read-only property; the long string version of the Flash authoring tool, including platform.

Example

The following example displays the version of the Flash authoring tool in the Output panel.

alert( fl.version ); // For example, WIN 7,0,0,380

fl.xmlui

Availability

Flash MX 2004.

Usage

fl.xmlui

Description

Read-only property; an XMLUI object. This property lets you get and set XMLUI properties in a XMLUI dialog box and lets you accept or cancel the dialog box programmatically.

Example

See XMLUI object.

     < 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