Extending Flash
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are eith
Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Overview of the Macromedia Flash JavaScript API . . . . . . . . . . . . . . . . . 5 What’s new in the JavaScript API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 The Flash Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Sample implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
outputPanel object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334 Parameter object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Path object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343 Project object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350 ProjectItem object . . . . . . . . . . . . . . . . . . . . . . .
Introduction As a Macromedia Flash user, you may be familiar with ActionScript, which lets you create scripts that execute at runtime in Macromedia 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. This document describes the objects, methods, and properties available in the JavaScript API.
The Flash JavaScript API is designed to resemble the Macromedia Dreamweaver and Macromedia Fireworks JavaScript API (which were designed based on the Netscape JavaScript API). The Flash JavaScript API is based on a Document Object Model (DOM), which allows Flash documents to be accessed using JavaScript objects. The Flash JavaScript API includes all elements of the Netscape JavaScript API, plus the Flash DOM. These added objects and their methods and properties are described in this document.
To copy commands from the History panel to the Clipboard: 1. Select one or more commands in the History panel. 2. Do one of the following: ■ Click the Copy button. ■ Select Copy Steps from the options pop-up menu. To view JavaScript commands in the History panel: ■ Select View > JavaScript in Panel from the options pop-up menu. Saving JSFL files You can have JSFL scripts available within the Flash authoring environment by storing them in one of several folders within the Configuration folder.
There are three locations where you can store command, effect, and tool files so they can be accessed in the authoring environment.
Running JSFL files There are several ways to run JSFL files. The most common ways are discussed in this section. To run a script that is in the Commands folder, do one of the following: ■ Select Commands > Script Name. ■ Use a keyboard shortcut that you have assigned to the script. To assign a keyboard shortcut, use Edit > Keyboard Shortcuts and select Drawing Menu Commands from the Commands pop-up menu. Expand the Commands node in the menu tree to view a list of available scripts.
To run a script from the command line on Windows: ■ Use the following syntax (add path information as required): "flash.exe" myTestFile.jsfl To run a script from the command line on the Macintosh: ■ Use the following syntax (add path information as required): osascript -e 'tell application "flash" to open alias "Mac OS X:Users:user:myTestFile.jsfl" ' The osascript command can also run AppleScript in a file.
New objects The following objects are new in Flash 8: Filter object Project object ProjectItem object The following object was implemented in a Flash MX 2004 update release, but is newly documented in this release: FLfile object New methods and properties The following methods and properties are new in Flash 8: componentsPanel.reload() document.addFilter() document.changeFilterOrder() document.crop() document.deleteEnvelope() document.disableAllFilters() document.disableFilter() document.
document.setMetadata() document.swapStrokeAndFill() document.union() document.zoomFactor element.layer element.selected fill.focalPoint fill.linearRGB fill.overflow fl.browseForFolderURL() fl.closeProject() fl.contactSensitiveSelection fl.createProject() fl.objectDrawingMode fl.getAppMemoryInfo() fl.getProject() fl.objectDrawingMode fl.showIdleMessage() frame.getCustomEase() frame.hasCustomEase frame.setCustomEase() frame.useSingleEaseCurve shape.isDrawingObject stroke.capType stroke.joinType stroke.
symbolItem.scalingGridRect text.antiAliasSharpness text.antiAliasThickness textAttrs.letterSpacing text.fontRenderingMode videoItem.sourceFilePath videoItem.videoType xmlui.getControlItemElement() xmlui.getEnabled() xmlui.getVisible() xmlui.setControlItemElement() xmlui.setControlItemElements() xmlui.setEnabled() xmlui.setVisible() Other changes The following items have new parameters, additional acceptable values for existing parameters, or other implementation changes in Flash 8: document.
The Flash Document Object Model The Flash Document Object Model (DOM) for the Flash JavaScript API consists of a set of top-level functions (see “Top-Level Functions and Methods” on page 23) and two top-level objects—the FLfile object and the flash object (fl). Each object is guaranteed to be available to a script because it always exists when the Flash authoring environment is open. For more information, see FLfile object and flash object (fl). When referring to the flash object, you can use flash or fl.
The Document object An important property of the top-level flash object is the fl.documents property. (See fl.documents property.) The fl.documents property contains an array of Document objects that each represent one of the FLA files currently open in the authoring environment. The properties of each Document object represent most of the elements that a FLA file can contain. Therefore, a large portion of the DOM is composed of child objects and properties of the Document object.
Specifying the target of an action Unless otherwise specified, methods affect the current focus or selection. For example, the following script doubles the size of the current selection because no particular object is specified: fl.getDocumentDOM().scaleSelection(2, 2); In some cases, you might want an action to specifically target the currently selected item in the Flash document. To do this, use the array that the document.selection property contains (see document.selection).
Finally, some objects are subclasses of other objects, rather than being children of other objects. An object that is a subclass of another object has methods and/or properties of its own in addition to the methods and properties of the other object (the superclass). Subclasses share the same level in the hierarchy as their superclass. For example, the Item object is a superclass of the BitmapItem object (see Item object and BitmapItem object).
06 Instance object (abstract class, subclass of Element object) 06 BitmapInstance object (subclass of Instance object) 06 CompiledClipInstance object (subclass of Instance object) 06 ComponentInstance object (subclass of SymbolInstance object) 07 Parameter object (componentInstance.parameters) 06 SymbolInstance object (subclass of Instance object) 06 Text object (subclass of Element object) 07 TextRun object (text.textRuns array) 08 TextAttrs object (textRun.
02 Math object 02 outputPanel object 02 Project object 03 ProjectItem object (project.items array) 02 Tools object (fl.tools array) 03 ToolObj object (tools.toolObjs array) 02 XMLUI object Sample implementations 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.
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.
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.
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.
CHAPTER 1 1 Top-Level Functions and Methods This chapter describes the top-level functions and methods that are available when you use the Macromedia Flash JavaScript application programming interface (JavaScript API). For information about where to store JavaScript API files, see “Saving JSFL files” on page 7. The following lists summarize the areas in the authoring environment that relate to each function or method. Following the lists, the functions and methods are listed in alphabetical order.
Extensible tools The following functions are available in scripts that create extensible tools: activate() configureTool() deactivate() keyDown() keyUp() mouseDoubleClick() mouseDown() mouseMove() mouseUp() notifySettingsChanged() setCursor() activate() Availability Flash MX 2004. Usage function activate() { // statements } Parameters None. Returns Nothing. Description Function; called when the extensible tool becomes active (that is, when the tool is selected in the Tools panel).
Example The following example sets the value of tools.activeTool when the extensible tool is selected in the Tools panel: function activate() { var theTool = fl.tools.activeTool } See also tools.activeTool alert() Availability Flash MX 2004. Usage alert ( alertText ) Parameters alertText A string that specifies the message you want to display in the Alert dialog box. Returns Nothing. Description Method; displays a string in a modal Alert dialog box, along with an OK button.
configureEffect() Availability Flash MX 2004. Usage function configureEffect() { // Statements } Parameters None. Returns Nothing. Description Function; called once when Flash loads; place any global initialization statements for your effect inside this function. The per instance parameter data for an effect cannot be accessed here. See also executeEffect(), removeEffect() configureTool() Availability Flash MX 2004. Usage function configureTool() { // statements } Parameters None. Returns Nothing.
Description Function; called when Flash opens and the extensible tool is loaded into the Tools panel. Use this function to set any information Flash needs to know about the tool. Example The following examples show two possible implementations of this function: function configureTool() { theTool = fl.tools.activeTool; theTool.setToolName("myTool"); theTool.setIcon("myTool.png"); theTool.setMenuString("My Tool's menu string"); theTool.setToolTip("my tool's tool tip"); theTool.setOptionsFile( "mtTool.
Example The following example displays the message “Sort data?” in an Alert dialog box: confirm("Sort data?"); See also alert(), prompt() deactivate() Availability Flash MX 2004. Usage function deactivate() { // statements } Parameters None. Returns Nothing. Description Function; called when the extensible tool becomes inactive (that is, when the active tool changes from this tool to another one). Use this function to perform any cleanup the tool needs.
executeEffect() Availability Flash MX 2004. Usage function executeEffect() { // statements } Parameters None. Returns Nothing. Description Function; called when the user first applies an effect or changes an effect’s properties. The code contained in this function modifies the original object(s) to create the desired effect. It is also responsible for copying the original to a hidden layer if necessary for the removeEffect function.
Description Function; called when the extensible tool is active and the user presses a key. The script should call tools.getKeyDown() to determine which key was pressed. Example The following example displays information about which key was pressed when the extensible tool is active and the user presses a key. function keyDown() { fl.trace("key " + fl.tools.getKeyDown() + " was pressed"); } See also keyUp(), tools.getKeyDown() keyUp() Availability Flash MX 2004.
Example The following example displays a message in the Output panel when the extensible tool is active and a key is released. function keyUp() { fl.trace("Key is released"); } See also keyDown() mouseDoubleClick() Availability Flash MX 2004. Usage function mouseDoubleClick() { // statements } Parameters None. Returns Nothing. Description Function; called when the extensible tool is active and the mouse button is double-clicked on the Stage.
mouseDown() Availability Flash MX 2004. Usage function mouseDown( [ pt ] ) { // statements } Parameters A point that specifies the location of the mouse when the button is pressed. It is passed to the function when the mouse button is pressed. This parameter is optional. pt Returns Nothing. Description Function; called when the extensible tool is active and the mouse button is pressed while the pointer is over the Stage.
mouseMove() Availability Flash MX 2004. Usage function mouseMove( [ pt ] ) { // statements } Parameters A point that specifies the current location of the mouse. It is passed to the function whenever the mouse moves, which tracks the mouse location. If the Stage is in edit or edit-in-place mode, the point coordinates are relative to the object being edited. Otherwise, the point coordinates are relative to the Stage. This parameter is optional. pt Returns Nothing.
mouseUp() Availability Flash MX 2004. Usage function mouseUp() { // statements } Parameters None. Returns Nothing. Description Function; called whenever the extensible tool is active and the mouse button is released after being pressed on the Stage. Example The following example displays a message in the Output panel when the extensible tool is active and the mouse button is released. function mouseUp() { fl.trace("mouse is up"); } notifySettingsChanged() Availability Flash MX 2004.
Returns Nothing. Description Function; called when the extensible tool is active and the user changes its options in the Property inspector. You can use the tools.activeTool property to query the current values of the options (see tools.activeTool). Example The following example displays a message in the Output panel when the extensible tool is active and the user changes its options in the Property inspector. function notifySettingsChanged() { var theTool = fl.tools.activeTool; var newValue = theTool.
Example The following example prompts the user to enter a user name. If the user types a name and clicks OK, the name appears in the Output panel. var userName = prompt("Enter user name", "Type user name here"); fl.trace(userName); See also alert(), confirm() removeEffect() Availability Flash MX 2004. Usage function removeEffect() { // statements } Parameters None. Returns Nothing. Description Function; called when the user changes an effect’s properties or uses the Remove Effect menu item.
setCursor() Availability Flash MX 2004. Usage function setCursor() { // statements } Parameters None. Returns Nothing. Description Function; called when the extensible tool is active and the mouse moves, to allow the script to set custom pointers. The script should call tools.setCursor() to specify the pointer to use. For a list that shows which pointers correspond to which integer values, see tools.setCursor(). Example function setCursor() { fl.tools.
Top-Level Functions and Methods
2 CHAPTER 2 Objects This chapter briefly describes each of the objects available in the Flash JavaScript application programming interface (JavaScript API). The objects are listed in alphabetical order in the following table: Object Description BitmapInstance object The BitmapInstance object is a subclass of the Instance object and represents a bitmap in a frame. BitmapItem object A BitmapItem object refers to a bitmap in the library of a document.
Object Description Filter object The Filter object contains all the properties for all filters. flash object (fl) The flash object represents the Flash application. FLfile object The FLfile object lets you write Flash extensions that can access, modify, and remove files and folders on the local file system. folderItem object The folderItem object is a subclass of the Item object. fontItem object The fontItem object is a subclass of the Item object.
Object Description Shape object The Shape object is a subclass of the Element object. The Shape object provides more precise control than the drawing APIs for manipulating or creating geometry on the Stage. SoundItem object The SoundItem object is a subclass of the Item object. It represents a library item used to create a sound. Stroke object The Stroke object contains all the settings for a stroke, including the custom settings.
CHAPTER 3 Objects BitmapInstance object Inheritance Element object > Instance object > BitmapInstance object Availability Flash MX 2004. Description The BitmapInstance object is a subclass of the Instance object and represents a bitmap in a frame (see Instance object). Method summary for the BitmapInstance object In addition to the Instance object methods, you can use the following methods with the BitmapInstance object: Method Description bitmapInstance.
Parameters None. Returns An object that contains width, height, depth, bits, and, if the bitmap has a color table, cTab properties. The bits element is an array of bytes. The cTab element is an array of color values of the form "#RRGGBB". The length of the array is the length of the color table. The byte array is meaningful only when referenced by a DLL or shared library. You typically use it only when creating an extensible tool or effect.
Example The following code retrieves the width of the bitmap in pixels: // Get the number of pixels in the horizontal dimension. var bmObj = fl.getDocumentDOM().selection[0]; var isBitmap = bmObj.instanceType; if(isBitmap == "bitmap"){ var numHorizontalPixels = bmObj.hPixels; } See also bitmapInstance.vPixels bitmapInstance.setBits() Availability Flash MX 2004. Usage bitmapInstance.setBits(bitmap) Parameters An object that contains height, width, depth, bits, and cTab properties.
Example The following code tests whether the current selection is a bitmap, and then sets the height of the bitmap to 150 pixels: var isBitmap = fl.getDocumentDOM().selection[0].instanceType; if(isBitmap == "bitmap"){ var bits = fl.getDocumentDOM().selection[0].getBits(); bits.height = 150; fl.getDocumentDOM().selection[0].setBits(bits); } See also bitmapInstance.getBits() bitmapInstance.vPixels Availability Flash MX 2004. Usage bitmapInstance.
CHAPTER 4 Objects BitmapItem object Inheritance Item object > BitmapItem object Availability Flash MX 2004. Description A BitmapItem object refers to a bitmap in the library of a document. The BitmapItem object is a subclass of the Item object (see Item object). Property summary for the BitmapItem object In addition to the Item object properties, the BitmapItem object has following properties: Property Description bitmapItem.
Example The following code sets the allowSmoothing property of the first item in the library of the current document to true: fl.getDocumentDOM().library.items[0].allowSmoothing = true; alert(fl.getDocumentDOM().library.items[0].allowSmoothing); bitmapItem.compressionType Availability Flash MX 2004. Usage bitmapItem.compressionType Description Property; a string that determines the type of image compression applied to the bitmap. Acceptable values are "photo" or "lossless". If the value of bitmapItem.
Example The following code sets the quality property of the first item in the library of the current document to 65: fl.getDocumentDOM().library.items[0].quality = 65; alert(fl.getDocumentDOM().library.items[0].quality); bitmapItem.useImportedJPEGQuality Availability Flash MX 2004. Usage bitmapItem.useImportedJPEGQuality Description Property; a Boolean value that specifies whether to use the default imported JPEG quality (true) or not (false). Available only for JPEG compression.
CHAPTER 5 Objects CompiledClipInstance object Inheritance Element object > Instance object > CompiledClipInstance object Availability Flash MX 2004. Description The CompiledClipInstance object is a subclass of the Instance object. It is essentially an instance of a movie clip that has been converted to a compiled clip library item. (See Instance object.
compiledClipInstance.accName Availability Flash MX 2004. Usage compiledClipInstance.accName Description Property; a string that is equivalent to the Name field in the Accessibility panel. Screen readers identify objects by reading the name aloud. Example The following example gets and sets the accessibility name of the first selected object: // Get the name of the object. var theName = fl.getDocumentDOM().selection[0].accName; // Set the name of the object. fl.getDocumentDOM().selection[0].
compiledClipInstance.description Availability Flash MX 2004. Usage compiledClipInstance.description Description Property; a string that is equivalent to the Description field in the Accessibility panel. The description is read by the screen reader. Example The following example illustrates getting and setting the description property: // Get the description of the current selection. var theDescription = fl.getDocumentDOM().selection[0].description; // Set the description of the current selection. fl.
compiledClipInstance.shortcut Availability Flash MX 2004. Usage compiledClipInstance.shortcut Description Property; a string that is equivalent to the Shortcut field in the Accessibility panel. The shortcut is read by the screen readers. This property is not available for dynamic text fields. Example The following example illustrates getting and setting the shortcut property: // Get the shortcut key of the object. var theShortcut = fl.getDocumentDOM().selection[0].
compiledClipInstance.tabIndex Availability Flash MX 2004. Usage compiledClipInstance.tabIndex Description Property; an integer that is equivalent to the Tab Index field in the Accessibility panel. Creates a tab order in which objects are accessed when the user presses the Tab key. Example The following example illustrates getting and setting the tabIndex property: // Get the tabIndex of the object. var theTabIndex = fl.getDocumentDOM().selection[0].tabIndex; // Set the tabIndex of the object. fl.
CHAPTER 6 Objects ComponentInstance object Inheritance Element object > Instance object > SymbolInstance object > ComponentInstance object Availability Flash MX 2004. Description The ComponentInstance object is a subclass of the SymbolInstance object and represents a component in a frame. (See SymbolInstance object.
CHAPTER 7 Objects componentsPanel object Availability Flash MX 2004. Description The componentsPanel object, which represents the Components panel, is a property of the flash object (fl) and can be accessed by fl.componentsPanel. (See flash object (fl).) Method summary for the componentsPanel object You can use the following methods with the componentsPanel object: Method Description componentsPanel.addItemToDocument() Adds the specified component to the document at the specified position.
Description Adds the specified component to the document at the specified position. Examples The following examples illustrate some ways to use this method: fl.componentsPanel.addItemToDocument({x:0, y:0}, "User Interface", "CheckBox"); fl.componentsPanel.addItemToDocument({x:0, y:100}, "Data", "WebServiceConnector"); fl.componentsPanel.addItemToDocument({x:0, y:200}, "User Interface", "Button"); componentsPanel.reload() Availability Flash 8. Usage componentsPanel.reload() Parameters None.
CHAPTER 8 Objects Contour object Availability Flash MX 2004. Description A Contour object represents a closed path of half edges on the boundary of a shape. Method summary for the Contour object You can use the following method with the Contour object: Property Description contour.getHalfEdge() Returns a HalfEdge object on the contour of the selection. Property summary for the Contour object You can use the following properties with the Contour object: Property Description contour.
Description Method; returns a HalfEdge object on the contour of the selection. Example This example traverses all the contours of a selected shape and shows the coordinates of the vertices in the Output panel: // with a shape selected var elt = fl.getDocumentDOM().selection[0]; elt.beginEdit(); var contourArray = elt.contours; var contourCount = 0; for (i=0; i
contour.interior Availability Flash MX 2004. Usage contour.interior Description Read-only property; the value is true if the contour encloses an area; false otherwise. Example This example traverses all the contours in the selected shape and shows the value of the interior property for each contour in the Output panel: var elt = fl.getDocumentDOM().selection[0]; elt.beginEdit(); var contourArray = elt.contours; var contourCount = 0; for (i=0; i
Example The following example traverses all the contours of the selected shape and shows the value of the orientation property of each contour in the Output panel: var elt = fl.getDocumentDOM().selection[0]; elt.beginEdit(); var contourArray = elt.contours; var contourCount = 0; for (i=0; i
Objects Document object Availability Flash MX 2004. Description The Document object represents the Stage. That is, only FLA files are considered documents. Method summary for the Document object You can use the following methods with the Document object. Method Description document.addDataToDocument() Stores specified data with a document. document.addDataToSelection() Stores specified data with the selected object(s). document.addFilter() Applies a filter to the selected objects. document.
Method Description document.canEditSymbol() Indicates whether Edit Symbols menu and functionality is enabled. document.canRevert() Determines whether you can use the document.revert() or fl.revertDocument() method successfully. document.canTestMovie() Determines whether you can use the document.testMovie() method successfully. document.canTestScene() Determines whether you can use the document.testScene() method successfully. document.
Method Description document.distributeToLayers() Performs a distribute-to-layers operation on the current selection; equivalent to selecting Distribute to Layers. document.documentHasData() Checks the document for persistent data with the specified name. document.duplicatePublishProfile() Duplicates the currently active profile and gives the duplicate version focus. document.
Method Description document.getElementTextAttr() Gets a specified TextAttrs property of the selected text objects. document.getFilters() Returns an array that contains the list of filters applied to the currently selected object(s). document.getMetadata() Returns a string containing the XML metadata associated with the document. document.getSelectionRect() Gets the bounding rectangle of the current selection. document.getTextString() Gets the currently selected text. document.
Method Description document.punch() Uses top selected drawing object to punch through all selected drawing objects underneath it. document.removeAllFilters() Removes all filters from the selected object(s).< document.removeDataFromDocument() Removes persistent data with the specified name that has been attached to the document. document.removeDataFromSelection() Removes persistent data with the specified name that has been attached to the selection. document.
Method Description document.setBlendMode() Sets the blend mode for the selected objects. document.setCustomFill() Sets the fill settings for the Tools panel, Property inspector, and any selected shapes. document.setCustomStroke() Sets the stroke settings for the Tools panel, Property inspector, and any selected shapes. document.setElementProperty() Sets the specified Element property on selected object(s) in the document. document.
Method Description document.setTextSelection() Sets the text selection of the currently selected text field to the values specified by the startIndex and endIndex values. document.setTextString() Inserts a string of text. document.setTransformationPoint() Moves the transformation point of the current selection. document.skewSelection() Skews the selection by a specified amount. document.smoothSelection() Smooths the curve of each selected fill outline or curved line. document.
Property summary for the Document object You can use the following properties with the Document object. Property Description document.accName A string that is equivalent to the Name field in the Accessibility panel. document.autoLabel A Boolean value that is equivalent to the Auto Label check box in the Accessibility panel. document.backgroundColor A string, hexadecimal value, or integer that represents the background color. document.
Property Description document.timelines Read-only; an array of Timeline objects (see Timeline object). document.viewMatrix Read-only; a Matrix object. document.width An integer that specifies the width of the document (Stage) in pixels. document.zoomFactor Specifies the zoom percent of the Stage at author time. document.accName Availability Flash MX 2004. Usage document.accName Description Property; a string that is equivalent to the Name field in the Accessibility panel.
Parameters name A string that specifies the name of the data to add. type A string that defines the type of data to add. Acceptable values are type are and "byteArray". "integer", "integerArray", "double", "doubleArray", "string", data the value to add. Valid types depend on the type parameter. Returns Nothing. Description Method; stores specified data with a document. Data is written to the FLA file and is available to JavaScript when the file reopens.
Description Method; stores specified data with the selected object(s). Data is written to the FLA file and is available to JavaScript when the file reopens. Only symbols and bitmaps support persistent data. Example The following example adds an integer value of 12 to the selected object: fl.getDocumentDOM().addDataToSelection("myData", "integer", 12); See also document.removeDataFromSelection() document.addFilter() Availability Flash 8. Usage document.
document.addItem() Availability Flash MX 2004. Usage document.addItem( position, item ) Parameters A point that specifies the x and y coordinates of the location at which to add the item. It uses the center of a symbol or the upper-left corner of a bitmap or video. position An Item object that specifies the item to add and the library from which to add it (see Item object). item Returns A Boolean value: true if successful; false otherwise.
document.addNewLine() Availability Flash MX 2004. Usage document.addNewLine( startPoint, endpoint ) Parameters startpoint A pair of floating-point numbers that specify the x and y coordinates where the line starts. endpoint A pair of floating-point numbers that specify the x and y coordinates where the line ends. Returns Nothing. Description Method; adds a new path between two points. The method uses the document’s current stroke attributes and adds the path on the current frame and current layer.
Parameters boundingRectangle A rectangle that specifies the bounds of the oval to be added. For information on the format of boundingRectangle, see document.addNewRectangle(). A Boolean value that, if set to true, causes the method to create the shape without a fill. The default value is false. This parameter is optional. bSuppressFill bSuppressStroke A Boolean value that, if set to true, causes the method to create the shape without a stroke. The default value is false. This parameter is optional.
document.addNewPublishProfile() Availability Flash MX 2004. Usage document.addNewPublishProfile( [profileName ] ) Parameters profileName The unique name of the new profile. If you do not specify a name, a default name is provided. This parameter is optional. Returns An integer that is the index of the new profile in the profiles list. Returns -1 if a new profile cannot be created. Description Method; adds a new publish profile and makes it the current one.
Parameters A rectangle that specifies the bounds within which the new rectangle is added, in the format {left:value1,top:value2,right:value3,bottom:value4}. The left and top values specify the location of the upper-left corner (e.g., left:0,top:0 represents the upper-left of the Stage), and the right and bottom values specify location of the lower-right corner.
Example The following example adds a new rectangle with no rounding on the corners within the specified coordinates; it is 100 pixels in width and in height: flash.getDocumentDOM().addNewRectangle({left:0,top:0,right:100,bottom:100}, 0); The following example adds a new rectangle with no rounding on the corners and without a fill; it is 100 pixels in width and 200 in height: flash.getDocumentDOM().
Example The following example adds a new scene named myScene after the current scene in the current document. The variable success will be true when the new scene is created; false otherwise. var success = flash.getDocumentDOM().addNewScene("myScene"); The following example adds a new scene using the default naming convention. If only one scene exists, the newly created scene is named "Scene 2". fl.getDocumentDOM().addNewScene(); document.addNewText() Availability Flash MX 2004. Usage document.
document.align() Availability Flash MX 2004. Usage document.align( alignmode [, bUseDocumentBounds ] ) Parameters alignmode A string that specifies how to align the selection. Acceptable values are "left", and "horizontal center". "right", "top", "bottom", "vertical center", A Boolean value that, if set to true, causes the method to align to the bounds of the document. Otherwise, the method uses the bounds of the selected objects. The default is false. This parameter is optional.
Returns A Boolean value: true if document.screenOutline can be used safely; false otherwise. Description Method; use before using the document.screenOutline property. If this method returns the value true, you can safely access document.screenOutline; Flash displays an error if you access document.screenOutline in a document without screens. Example The following example determines whether screens methods can be used in the current document: if(fl.getDocumentDOM().allowScreens()) { fl.
Example The following example moves the current selection to the front: fl.getDocumentDOM().arrange("front"); document.autoLabel Availability Flash MX 2004. Usage document.autoLabel Description Property; a Boolean value that is equivalent to the Auto Label check box in the Accessibility panel. You can use this property to tell Flash to automatically label objects on the Stage with the text associated with them.
Example The following example sets the background color to black: fl.getDocumentDOM().backgroundColor = '#000000'; document.breakApart() Availability Flash MX 2004. Usage document.breakApart() Parameters None. Returns Nothing. Description Method; performs a break-apart operation on the current selection. Example The following example breaks apart the current selection: fl.getDocumentDOM().breakApart(); document.canEditSymbol() Availability Flash MX 2004. Usage document.
Description Method; indicates whether the Edit Symbols menu and functionality are enabled. This is not related to whether the selection can be edited. This method should not be used to test whether fl.getDocumentDOM().enterEditMode() is allowed. Example The following example displays in the Output panel the state of the Edit Symbols menu and functionality: fl.trace("fl.getDocumentDOM().canEditSymbol() returns: " + fl.getDocumentDOM().canEditSymbol()); document.canRevert() Availability Flash MX 2004.
document.canTestMovie() Availability Flash MX 2004. Usage document.canTestMovie() Parameters None. Returns A Boolean value: true if you can use the document.testMovie() method successfully: false otherwise. Description Method; determines whether you can use the document.testMovie() method successfully. Example The following example tests whether fl.getDocumentDOM().testMovie() can be used. If so, it calls the method. if(fl.getDocumentDOM().canTestMovie()){ fl.getDocumentDOM().
Returns A Boolean value: true if you can use the document.testScene() method successfully; false otherwise. Description Method; determines whether you can use the document.testScene() method successfully. Example The following example first tests whether fl.getDocumentDOM().testScene() can be used successfully. If so, it calls the method. if(fl.getDocumentDOM().canTestScene()){ fl.getDocumentDOM().testScene(); } See also document.canTestMovie(), document.testMovie() document.
If you then issue the command fl.getDocumentDOM().changeFilterOrder(0, 2), the filters are rearranged as follows: Before: gradientBevelFilter, blurFilter, dropShadowFilter, glowFilter After: blurFilter, dropShadowFilter, gradientBevelFilter, glowFilter Example The following example moves the filter that is currently in the second position in the Filter list to the first position: fl.getDocumentDOM().changeFilterOrder(1,0); See also document.addFilter(), document.disableFilter(), document.
document.clipCut() Availability Flash MX 2004. Usage document.clipCut() Parameters None. Returns Nothing. Description Method; cuts the current selection from the document and writes it to the Clipboard. Example The following example cuts the current selection from the document and writes it to the Clipboard: fl.getDocumentDOM().clipCut(); document.clipPaste() Availability Flash MX 2004. Usage document.
Example The following examples pastes the Clipboard contents to the center of the document: fl.getDocumentDOM().clipPaste(); The following example pastes the Clipboard contents in place in the current document: fl.getDocumentDOM().clipPaste(true); document.close() Availability Flash MX 2004. Usage document.
document.convertLinesToFills() Availability Flash MX 2004. Usage document.convertLinesToFills() Parameters None. Returns Nothing. Description Method; converts lines to fills on the selected objects. Example The following example converts the current selected lines to fills: fl.getDocumentDOM().convertLinesToFills(); document.convertToSymbol() Availability Flash MX 2004. Usage document.
Description Method; converts the selected Stage item(s) to a new symbol. For information on defining linkage and shared asset properties for a symbol, see Item object. Example The following examples create a movie clip symbol with a specified name, a button symbol with a specified name, and a movie clip symbol with a default name: newMc = fl.getDocumentDOM().convertToSymbol("movie clip", "mcSymbolName", "top left"); newButton = fl.getDocumentDOM().
document.currentPublishProfile Availability Flash MX 2004. Usage document.currentPublishProfile Description Property; a string that specifies the name of the active publish profile for the specified document. Example The following example adds a new publish profile with the default name and then displays the name of the profile in the Output panel: fl.getDocumentDOM().addNewPublishProfile(); fl.outputPanel.trace(fl.getDocumentDOM().
The following example changes the active timeline from the main timeline to a scene named "myScene". var i = 0; var curTimelines = fl.getDocumentDOM().timelines; while(i < fl.getDocumentDOM().timelines.length){ if(curTimelines[i].name == "myScene"){ fl.getDocumentDOM().currentTimeline = i; } ++i; } See also document.getTimeline() document.deleteEnvelope() Availability Flash 8. Usage document.deleteEnvelope(); Parameters None. Returns A Boolean value: true if successful; false otherwise.
document.deletePublishProfile() Availability Flash MX 2004. Usage document.deletePublishProfile() Parameters None. Returns An integer that is the index of the new current profile. If a new profile is not available, the method leaves the current profile unchanged and returns its index. Description Method; deletes the currently active profile, if there is more than one. There must be at least one profile left.
Description Method; deletes the current scene (Timeline object) and, if the deleted scene was not the last one, sets the next scene as the current Timeline object. If the deleted scene was the last one, it sets the first object as the current Timeline object. If only one Timeline object (scene) exists, it returns the value false. Example Assuming there are three scenes (Scene0, Scene1, and Scene2) in the current document, the following example makes Scene2 the current scene and then deletes it: fl.
document.description Availability Flash MX 2004. Usage document.description Description Property; a string that is equivalent to the Description field in the Accessibility panel. The description is read by the screen reader. Example The following example sets the description of the document: fl.getDocumentDOM().description= "This is the main movie"; The following example gets the description of the document and displays it in the Output panel: fl.trace(fl.getDocumentDOM().description); document.
Example The following example disables all filters on the selected objects: fl.getDocumentDOM().disableAllFilters(); See also document.addFilter(), document.changeFilterOrder(), document.disableFilter(), document.disableOtherFilters(), document.enableAllFilters(), document.getFilters(), document.removeAllFilters(), Filter object document.disableFilter() Availability Flash 8. Usage document.
document.disableOtherFilters() Availability Flash 8. Usage document.disableOtherFilters( enabledFilterIndex ) Parameters enabledFilterIndex An integer representing the zero-based index of the filter that should remain enabled after other filters are disabled. Returns Nothing. Description Method; disables all filters except the one at the specified position in the Filters list. Example The following example disables all filters except the second filter in the list (index value of 1): fl.
Parameters distributemode A string that specifies where to distribute the selected object. Acceptable values are "left edge", "horizontal center", "right edge", "top edge", "vertical center", and "bottom edge". bUseDocumentBounds A Boolean value that, when set to true, distributes the selected objects using the bounds of the document. Otherwise, the method uses the bounds of the selected object. The default is false. Returns Nothing. Description Method; distributes the selection.
Returns Nothing. Description Method; performs a distribute-to-layers operation on the current selection—equivalent to selecting Distribute to Layers. This method displays an error if there is no selection. Example The following example distributes the current selection to layers: fl.getDocumentDOM().distributeToLayers(); document.documentHasData() Availability Flash MX 2004. Usage document.documentHasData( name ) Parameters name A string that specifies the name of the data to check.
document.duplicatePublishProfile() Availability Flash MX 2004. Usage document.duplicatePublishProfile( [profileName ] ) Parameters profileName A string that specifies the unique name of the duplicated profile. If you do not specify a name, the method uses the default name. This parameter is optional. Returns An integer that is the index of the new profile in the profile list. Returns -1 if the profile cannot be duplicated.
Example The following example duplicates the second scene in the current document: fl.getDocumentDOM().editScene(1); //set the middle scene to current scene var success = fl.getDocumentDOM().duplicateScene(); document.duplicateSelection() Availability Flash MX 2004. Usage document.duplicateSelection() Parameters None. Returns Nothing. Description Method; duplicates the selection on the Stage.
Description Method; makes the specified scene the currently selected scene for editing. Example Assuming that there are three scenes (Scene0, Scene1, and Scene2) in the current document, the following example makes Scene2 the current scene and then deletes it: fl.getDocumentDOM().editScene(2); fl.getDocumentDOM().deleteScene(); document.enableAllFilters() Availability Flash 8. Usage document.enableAllFilters() Parameters None. Returns Nothing.
document.enableFilter() Availability Flash 8. Usage document.enableFilter( filterIndex ) Parameters filterIndex An integer specifying the zero-based index of the filter in the Filters list to enable. Returns Nothing. Description Method; enables the specified filter for the selected object(s). Example The following example enables the second filter of the selected object(s): fl.getDocumentDOM().enableFilter(1); See also document.addFilter(), document.changeFilterOrder(), document.
Returns Nothing. Description Method; switches the authoring tool into the editing mode specified by the parameter. If no parameter is specified, the method defaults to symbol-editing mode, which has the same result as right-clicking the symbol to invoke the context menu and selecting Edit. Example The following example puts Flash in edit-in-place mode for the currently selected symbol: fl.getDocumentDOM().
Example The following example exits symbol-editing mode: fl.getDocumentDOM().exitEditMode(); See also document.enterEditMode() document.exportPNG() Availability Flash 8. Usage document.exportPNG([fileURI [, bCurrentPNGSettings [, bCurrentFrame]]]) Parameters A string, expressed as a file:/// URI, that specifies the filename for the exported file. If fileURI is an empty string or is not specified, Flash displays the Export Movie dialog box.
document.exportPublishProfile() Availability Flash MX 2004. Usage document.exportPublishProfile( fileURI ) Parameters fileURI A string, expressed as a file:/// URI, that specifies the path of the XML file to which the profile is exported. Returns Nothing. Description Method; exports the currently active profile to an XML file. Example The following example exports the currently active profile to the file named profile.xml in the folder /Documents and Settings/username/Desktop on the C drive: fl.
Returns Nothing. Description Method; exports the document in the Flash SWF format. Example The following example exports the document to the specified file location with the current publish settings: fl.getDocumentDOM().exportSWF("file:///C|/Documents and Settings/joe_user/ Desktop/qwerty.swf"); The following example displays the Export Movie dialog box and the Export Flash Player dialog box and then exports the document based on the specified settings: fl.getDocumentDOM().
Example The following example sets the areChildrenAccessible variable to the value of the forceSimple property; a value of false means the children are accessible: var areChildrenAccessible = fl.getDocumentDOM().forceSimple; The following example sets the forceSimple property to allow the children of the document to be accessible: fl.getDocumentDOM().forceSimple = false; document.frameRate Availability Flash MX 2004. Usage document.
Description Method; identical to retrieving the value of the To Stage button in the Align panel. Gets the preference that can be used for document.align(), document.distribute(), document.match(), and document.space() methods on the document. Example The following example retrieves the value of the To Stage button in the Align panel. If the return value is true, the To Stage button is active; otherwise, it is not. var isAlignToDoc = fl.getDocumentDOM().getAlignToDocument(); fl.getDocumentDOM().
document.getCustomFill() Availability Flash MX 2004. Usage document.getCustomFill( [ objectToFill ] ) Parameters objectToFill A string that specifies the location of the fill object. The following values are valid: returns the fill object of the Tools panel and Property inspector. ■ "toolbar" ■ "selection" returns the fill object of the selection. If you omit this parameter, the default value is "selection". If there is no selection, the method returns undefined. This parameter is optional.
document.getCustomStroke() Availability Flash MX 2004. Usage document.getCustomStroke( [locationOfStroke] ) Parameters locationOfStroke A string that specifies the location of the stroke object. The following values are valid: ■ "toolbar", if set, returns the stroke object of the Tools panel and Property inspector. ■ "selection", if set, returns the stroke object of the selection. If you omit this parameter, it defaults to "selection". If there is no selection, it returns undefined.
document.getDataFromDocument() Availability Flash MX 2004. Usage document.getDataFromDocument( name ) Parameters name A string that specifies the name of the data to return. Returns The specified data. Description Method; retrieves the value of the specified data. The type returned depends on the type of data that was stored. Example The following example adds an integer value of 12 to the current document and uses this method to display the value in the Output panel: fl.getDocumentDOM().
Returns The value of the specified property. Returns null if the property is an indeterminate state, as when multiple elements are selected with different property values. Returns undefined if the property is not a valid property of the selected element. Description Method; gets the specified Element property for the current selection. For a list of acceptable values, see “Property summary for the Element object” on page 193.
Returns If one text field is selected, the property is returned if there is only one value used within the text. Returns undefined if there are several values used inside the text field. If several text fields are selected, and all the text alignment values are equal, the method returns this value. If several text fields are selected, but all the text alignment values are not equal, the method returns undefined.
Description Method; returns an array that contains the list of filters applied to the currently selected object(s). If multiple objects are selected and they don’t have identical filters, this method returns the list of filters applied to the first selected object. Example See document.setFilters(). See also document.addFilter(), document.changeFilterOrder(), document.setFilters(), Filter object document.getMetadata() Availability Flash 8. Usage document.getMetadata() Parameters None.
document.getSelectionRect() Availability Flash MX 2004. Usage document.getSelectionRect() Parameters None. Returns The bounding rectangle of the current selection, or 0 if nothing is selected. For information on the format of the return value, see document.addNewRectangle(). Description Method; gets the bounding rectangle of the current selection. If a selection is non-rectangular, the smallest rectangle encompassing the entire selection is returned.
Parameters An integer that is an index of first character to get. This parameter is optional. startIndex endIndex An integer that is an index of last character to get. This parameter is optional. Returns A string that contains the selected text. Description Method; gets the currently selected text. If the optional parameters are not passed, the current text selection is used. If text is not currently opened for editing, the whole text string is returned.
Returns The current Timeline object. Description Method; retrieves the current Timeline object in the document. The current timeline can be the current scene, the current symbol being edited, or the current screen. Example The following example gets the Timeline object and returns the number of frames in the longest layer: var longestLayer = fl.getDocumentDOM().getTimeline().frameCount; fl.
Example The following example gets the transformation point for the current selection. The transPoint.x property gives the x coordinate of the transformation point. The transPoint.y property gives the y coordinate of the transformation point: var transPoint = fl.getDocumentDOM().getTransformationPoint(); See also document.setTransformationPoint() document.group() Availability Flash MX 2004. Usage document.group() Parameters None. Returns Nothing.
Description Property; an integer that specifies the height of the document (Stage) in pixels. Example The following example sets the height of the Stage to 400 pixels: fl.getDocumentDOM().height = 400; See also document.width document.importFile() Availability Flash 8. Usage document.importFile(fileURI [, importToLibrary]) Parameters fileURI A string, expressed as a file:/// URI, that specifies the path of the file to import.
document.importPublishProfile() Availability Flash MX 2004. Usage document.importPublishProfile( fileURI ) Parameters fileURI A string, expressed as a file:/// URI, that specifies the path of the XML file defining the profile to import. Returns An integer that is the index of the imported profile in the profiles list. Returns -1 if the profile cannot be imported. Description Method; imports a profile from a file. Example The following example imports the profile contained in the profile.
Description Method; imports a SWF file into the document. This method performs the same operation as using the Import menu command to specify a SWF file. In Flash 8 and later, you can also use document.importFile() to import a SWF file (as well as other types of files). Example The following example imports the "mySwf.swf" file from the Flash Configuration folder: fl.getDocumentDOM().importSWF(fl.configURI+"mySwf.swf"); See also document.importFile() document.intersect() Availability Flash 8.
document.library Availability Flash MX 2004. Usage document.library Description Read-only property; the library object for a document. Example The following example gets the library for the currently focused document: var myCurrentLib = fl.getDocumentDOM().library; Assuming the currently focused document is not fl.documents[1], the following example gets the library for a non-focused library or for a library you opened using File > Open as external library: var externalLib = fl.documents[1].
document.match() Availability Flash MX 2004. Usage document.match( bWidth, bHeight [, bUseDocumentBounds] ) Parameters bWidth A Boolean value that, when set to true, causes the method to make the widths of the selected items the same. A Boolean value that, when set to true, causes the method to make the heights of the selected items the same. bHeight bUseDocumentBounds A Boolean value that, when set to true, causes the method to match the size of the objects to the bounds of the document.
document.mouseClick() Availability Flash MX 2004. Usage document.mouseClick( position, bToggleSel, bShiftSel ) Parameters position A pair of floating-point values that specify the x and y coordinates of the click in pixels. A Boolean value that specifies the state of the Shift key: true for pressed; false for not pressed. bToggleSel A Boolean value that specifies the state of the application preference Shift select: for on; false for off. bShiftSel true Returns Nothing.
Parameters position A pair of floating-point values that specify the x and y coordinates of the click in pixels. A Boolean value that records whether the Alt key is down at the time of the event: true for pressed; false for not pressed. bAltdown A Boolean value that records whether the Shift key was down when the event occurred: true for pressed; false for not pressed. bShiftDown A Boolean value that indicates the state of the application preference Shift select: true for on; false for off.
Description Method; if the selection contains at least one path with at least one Bézier point selected, moves all selected Bézier points on all selected paths by the specified amount. Example The following example moves the selected Bézier points 10 pixels to the right and 5 pixels down: fl.getDocumentDOM().moveSelectedBezierPointsBy({x:10, y:5}); document.moveSelectionBy() Availability Flash MX 2004. Usage document.
document.name Availability Flash MX 2004. Usage document.name Description Read-only property; a string that represents the name of a document (FLA file). Example The following example sets the variable fileName to the filename of the first document in the documents array: var fileName = flash.documents[0].name; The following example displays the names of all the open documents in the Output panel: var openDocs = fl.documents; for(var i=0;i < opendocs.length; i++){ fl.trace(i + " " + opendocs[i].
Description Method; optimizes smoothing for the current selection, allowing multiple passes, if specified, for optimal smoothing. This method is equivalent to selecting Modify > Shape > Optimize. Example The following example optimizes the curve of the current selection to 50º of smoothing with multiple passes: fl.getDocumentDOM().optimizeCurves(50, true); document.path Availability Flash MX 2004. Usage document.
Description Method; publishes the document according to the active Publish Settings (File > Publish Settings). This method is equivalent to selecting File > Publish. Example The following example publishes the current document: fl.getDocumentDOM().publish(); document.publishProfiles Availability Flash MX 2004. Usage document.publishProfiles Description Read-only property; an array of the publish profile names for the document.
Description Method; uses top selected drawing object to punch through all selected drawing objects underneath it. This method returns false if there are no drawing objects selected, or if any of the selected items are not drawing objects. Example The following example punches through drawing objects underneath the selected drawing object: fl.getDocumentDOM().punch(); See also document.crop(), document.deleteEnvelope(), document.intersect(), document.union(), shape.isDrawingObject document.
document.removeDataFromSelection() Availability Flash MX 2004. Usage document.removeDataFromSelection( name ) Parameters name A string that specifies the name of the persistent data to remove. Returns Nothing. Description Method; removes persistent data with the specified name that has been attached to the selection. Example The following example removes from the selection the persistent data named "myData": fl.getDocumentDOM().removeDataFromSelection("myData"); See also document.
Example The following example removes all filters from the selected object(s): fl.getDocumentDOM().removeAllFilters(); See also document.addFilter(), document.changeFilterOrder(), document.disableAllFilters(), document.getFilters(), document.removeFilter(), Filter object document.removeFilter() Availability Flash 8. Usage document.removeFilter( filterIndex ) Parameters An integer specifying the zero-based index of the filter to remove from the selected object(s). filterIndex Returns Nothing.
document.renamePublishProfile() Availability Flash MX 2004. Usage document.renamePublishProfile( [profileNewName ] ) Parameters profileNewName An optional parameter that specifies the new name for the profile. The new name must be unique. If the name is not specified, a default name is provided. Returns A Boolean value: true if the name is changed successfully; false otherwise. Description Method; renames the current profile.
Description Method; renames the currently selected scene in the Scenes panel. The new name for the selected scene must be unique. Example The following example renames the current scene to "new name": var success = fl.getDocumentDOM().renameScene("new name"); document.reorderScene() Availability Flash MX 2004. Usage document.reorderScene( sceneToMove, sceneToPutItBefore ) Parameters sceneToMove An integer that specifies which scene to move, with 0 (zero) being the first scene.
document.resetTransformation() Availability Flash MX 2004. Usage document.resetTransformation() Parameters None. Returns Nothing. Description Method; resets the transformation matrix. This method is equivalent to selecting Modify > Transform > Remove transform. Example The following example resets the transformation matrix for the current selection: fl.getDocumentDOM().resetTransformation(); document.revert() Availability Flash MX 2004. Usage document.revert() Parameters None. Returns Nothing.
Description Method; reverts the specified document to its previously saved version. This method is equivalent to selecting File > Revert. Example The following example reverts the current document to the previously saved version: fl.getDocumentDOM().revert(); See also document.canRevert(), fl.revertDocument() document.rotateSelection() Availability Flash MX 2004. Usage document.rotateSelection( angle [, rotationPoint] ) Parameters angle A floating-point value that specifies the angle of the rotation.
document.save() Availability Flash MX 2004. Usage document.save( [ bOkToSaveAs ] ) Parameters bOkToSaveAs An optional parameter that specifies whether to open the Save As dialog box. Returns A Boolean value: true if the save operation completes successfully; false otherwise. Description Method; saves the document in its default location. This method is equivalent to selecting File > Save.
Parameters An optional parameter that, if true or omitted and the file was never saved, opens the Save As dialog box. If false and the file was never saved, the file is not saved. The default value is true. bOkToSaveAs Returns A Boolean value: true if the save-and-compact operation completes successfully; false otherwise. Description Method; saves and compacts the file. This method is equivalent to selecting File > Save and Compact.
Returns Nothing. Description Method; scales the selection by a specified amount. This method is equivalent to using the Free Transform tool to scale the object. Example The following example expands the width of the current selection to double the original width and shrinks the height to half: flash.getDocumentDOM().scaleSelection(2.0, 0.5); The following example flips the selection vertically: fl.getDocumentDOM().scaleSelection(1, -1); The following example flips the selection horizontally: fl.
See also document.allowScreens(), ScreenOutline object document.selectAll() Availability Flash MX 2004. Usage document.selectAll() Parameters None. Returns Nothing. Description Method; selects all items on the Stage. This method is equivalent to pressing Control+A (Windows) or Command+A (Macintosh) or selecting Edit > Select All. Example The following example selects everything that is currently visible to the user: fl.getDocumentDOM().selectAll(); See also document.selection, document.
To add objects to the array, you must first select them in one of the following ways: ■ Manually select object(s) on the Stage. ■ Use one of the selection methods, such as document.setSelectionRect(), document.setSelectionBounds(), document.mouseClick(), document.mouseDblClk(), or document.selectAll(). ■ Manually select a frame or frames. ■ Use one of the methods of the Timeline object to select a frame or frames, such as timeline.getSelectedFrames(), timeline.setSelectedFrames(), or timeline.
The following example is an advanced example. It shows how to loop through the layer array and elements array to locate instances of a particular symbol and select them. You could extend this example to include loops for multiple frames or scenes. This example assigns all instances of the movie clip myMovieClip in the first frame to the current selection: // Assigns the layers array to the variable "theLayers". var theLayers = fl.getDocumentDOM().getTimeline().
Parameters None. Returns Nothing. Description Method; deselects any selected items. Example The following example deselects any items that are selected: fl.getDocumentDOM().selectNone(); See also document.selectAll(), document.selection document.setAlignToDocument() Availability Flash MX 2004. Usage document.setAlignToDocument( bToStage ) Parameters bToStage A Boolean value that, if set to true, aligns objects to the Stage. If set to false, it does not. Returns Nothing.
Example The following example enables the To Stage button in the Align panel to align objects with the Stage: fl.getDocumentDOM().setAlignToDocument(true); See also document.getAlignToDocument() document.setBlendMode() Availability Flash 8. Usage document.setBlendMode( mode ) Parameters A string that represents the desired blend mode for the selected objects.
document.setCustomFill() Availability Flash MX 2004. Usage document.setCustomFill( fill ) Parameters A Fill object that specifies the fill settings to be used. See Fill object. fill Returns Nothing. Description Method; sets the fill settings for the Tools panel, Property inspector, and any selected shapes. This allows a script to set the fill settings before drawing the object, rather than drawing the object, selecting it, and changing the fill settings.
Returns Nothing. Description Method; sets the stroke settings for the Tools panel, Property inspector, and any selected shapes. This allows a script to set the stroke settings before drawing the object, rather than drawing the object, selecting it, and changing the stroke settings. It also lets a script change the Tools panel and Property inspector stroke settings.
Description Method; sets the specified Element property on selected object(s) in the document. This method does nothing if there is no selection. Example The following example sets the width of all selected objects to 100 and the height to 50: fl.getDocumentDOM().setElementProperty("width", 100); fl.getDocumentDOM().setElementProperty("height", 50); document.setElementTextAttr() Availability Flash MX 2004. Usage document.
Example The following examples set the fillColor, italic, and bold text attributes for the selected text items: var success = fl.getDocumentDOM().setElementTextAttr("fillColor", "#00ff00"); var pass = fl.getDocumentDOM().setElementTextAttr("italic", true, 10); var ok = fl.getDocumentDOM().setElementTextAttr("bold", true, 5, 15); document.setFillColor() Availability Flash MX 2004. Usage document.
document.setFilterProperty() Availability Flash 8. Usage document.setFilterProperty( property, filterIndex, value ) Parameters property A string specifying the property to be set. Acceptable values are "blurX", "blurY", "quality", angle", "distance", "strength", "knockout", "inner", "bevelType", "color", "shadowColor", filterIndex and "highlightColor". An integer specifying the zero-based index of the filter in the Filters list.
document.setFilters() Availability Flash 8. Usage document.setFilters( filterArray ) Parameters filterArray The array of filters currently specified. Returns Nothing. Description Method; applies filters to the selected objects. Use this method after calling document.getFilters() and making any desired changes to the filters. Example The following example gets the filters on the selected object and sets the blurX property for all Blur filters to 50: var myFilters = fl.getDocumentDOM().
Parameters opacity An integer between 0 (transparent) and 100 (completely saturated) that adjusts the transparency of the instance. Returns Nothing. Description Methods; sets the opacity of the instance. Example The following example sets the opacity of the tint to a value of 50: fl.getDocumentDOM().setInstanceAlpha(50); document.setInstanceBrightness() Availability Flash MX 2004. Usage document.
document.setInstanceTint() Availability Flash MX 2004. Usage document.setInstanceTint( color, strength ) Parameters color The color of the tint, in one of the following formats: ■ A string in the format "#RRGGBB" or "#RRGGBBAA" ■ A hexadecimal number in the format 0xRRGGBB ■ An integer that represents the decimal equivalent of a hexadecimal number This parameter is equivalent to picking the Color: Tint value for a symbol in the Property Inspector.
Returns A Boolean value: true if successful; false otherwise. Description Method; sets the XML metadata for the specified document, overwriting any existing metadata. The XML passed as strMetadata is validated and may be rewritten before being stored. If it cannot be validated as legal XML or violates specific rules, then the XML metadata is not set and false is returned. (If false is returned, there is no way to get more detailed error information.
In the second example, metadata is in tags, but with different schemas all in one rdf:Description tag. This example also includes comments, which will be ignored and discarded by the Document.setMetadata():
fill.focalPoint Availability Flash 8. Usage fill.focalPoin Description Property; an integer that specifies the gradient focal point horizontal offset from the transformation point. A value of 10, for example, would place the focal point at 10/255 of the distance from the transformation point to the edge of the gradient. A value of -255 would place the focal point at the left boundary of the gradient. The default value is 0. This property is available only if the value of the fill.
fill.matrix Availability Flash MX 2004. Usage fill.matrix Description Property; a Matrix object that defines the placement, orientation, and scales for gradient fills. fill.overflow Availability Flash 8. Usage fill.overflow Description Property; a string that specifies the behavior of a gradient’s overflow. Acceptable values are "extend", "repeat", and "reflect"; the strings are not case-sensitive. The default value is "extend".
Description Property; an array of integers, each in the range 0 ... 255, indicating the position of the corresponding color. This property is available only if the value of the fill.style property is either "radialGradient" or "linearGradient". Example The following example specifies the colors to use in a linear gradient for the current selection: var fill = fl.getDocumentDOM().getCustomFill(); fill.style = "linearGradient"; fill.colorArray = [ 0x00ff00, 0xff0000, 0x0000ff ]; fill.
CHAPTER 15 Objects Filter object Availability Flash 8. Description This object contains all the properties for all filters. The filter.name property specifies the type of filter, and determines which properties are applicable to each filter. See filter.name. To return the filter list for an object or objects, use document.getFilters(). To apply filters to an object or objects, use document.setFilters(). See document.getFilters() and document.setFilters().
Property Description filter.knockout A Boolean value that specifies whether the filter is a knockout filter (true) or not (false). filter.name A string that specifies the type of filter (read-only property). filter.quality A string that specifies the blur quality. filter.saturation A float value that specifies the saturation value of the filter. filter.shadowColor A string, hexadecimal value, or integer that represents the shadow color. filter.
filter.blurX Availability Flash 8. Usage filter.blurX Description Property; a float value that specifies the amount to blur in the x direction, in pixels. Acceptable values are between 0 and 255. This property is defined for Filter objects with a value of "bevelFilter", "blurFilter", "dropShadowFilter", "glowFilter", "gradientBevelFilter", or "gradientGlowFilter" for the filter.name property.
Example See filter.blurX. See also document.setFilterProperty(), filter.blurX filter.brightness Availability Flash 8. Usage filter.brightness Description Property; a float value that specifies the brightness of the filter. Acceptable values are between -100 and 100. This property is defined for Filter objects with a value of "adjustColorFilter" for the filter.name property. Example The following example sets the brightness to 30.
Description Property; the color of the filter, in one of the following formats: ■ A string in the format "#RRGGBB" or "#RRGGBBAA" ■ A hexadecimal number in the format 0xRRGGBB ■ An integer that represents the decimal equivalent of a hexadecimal number This property is defined for Filter objects with a value of "dropShadowFilter" or "glowFilter" for the filter.name property.
Example The following example sets the contrast value to -15.5 for the Adjust Color filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.length; i++){ if(myFilters[i].name == 'adjustColorFilter'){ myFilters[i].contrast = -15.5; } } fl.getDocumentDOM().setFilters(myFilters); filter.distance Availability Flash 8. Usage filter.distance Description Property; a float value that specifies the distance between the filter’s effect and an object, in pixels.
filter.hideObject Availability Flash 8. Usage filter.hideObject Description Property; a Boolean value that specifies whether the source image is hidden (true) or displayed (false). This property is defined for Filter objects with a value of "dropShadowFilter" for the filter.name property. Example The following example sets the hideObject value to true for the Drop Shadow filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.
Example The following example sets the highlight color to "#ff00003e" for the Bevel filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.length; i++){ if(myFilters[i].name == 'bevelFilter'){ myFilters[i].highlightColor = '#ff00003e'; } } fl.getDocumentDOM().setFilters(myFilters); filter.hue Availability Flash 8. Usage filter.hue Description Property; a float value that specifies the hue of the filter. Acceptable values are between -180 and 180.
filter.inner Availability Flash 8. Usage filter.inner Description Property; a Boolean value that specifies whether the shadow is an inner shadow (true) or not (false). This property is defined for Filter objects with a value of "dropShadowFilter" or "glowFilter" for the filter.name property. Example The following example sets the value of the inner property to true for the Glow filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.
Example The following example sets the knockout property to true for the Glow filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.length; i++){ if(myFilters[i].name == 'glowFilter'){ myFilters[i].knockout = true; } } fl.getDocumentDOM().setFilters(myFilters); See also document.setFilterProperty() filter.name Availability Flash 8. Usage filter.name Description Read-only property; a string that specifies the type of filter.
filter.quality Availability Flash 8. Usage filter.quality Description Property; a string that specifies the blur quality. Acceptable values are "low", "medium", and "high" ("high" is similar to a Gaussian blur). This property is defined for Filter objects with a value of "bevelFilter", "blurFilter", "dropShadowFilter", “glowFilter", "gradientGlowFilter", or "gradientBevelFilter" for the filter.name property.
Example The following example sets the saturation value to 0 (grayscale) for the Adjust Color filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.length; i++){ if(myFilters[i].name == 'adjustColorFilter'){ myFilters[i].saturation = 0; } } fl.getDocumentDOM().setFilters(myFilters); See also document.setFilterProperty() filter.shadowColor Availability Flash 8. Usage filter.
Example The following example sets the shadow color to "#ff00003e" for the Bevel filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.length; i++){ if(myFilters[i].name == 'bevelFilter'){ myFilters[i].shadowColor = '#ff00003e'; } } fl.getDocumentDOM().setFilters(myFilters); See also document.setFilterProperty() filter.strength Availability Flash 8. Usage filter.
filter.type Availability Flash 8. Usage filter.type Description Property; a string that specifies the type of bevel or glow. Acceptable values are "inner", "outer", and "full". This property is defined for Filter objects with a value of "bevelFilter", "gradientGlowFilter", or "gradientBevelFilter" for the filter.name property. Example The following example sets the type to "full" for all Bevel filters on the selected object(s): var myFilters = fl.getDocumentDOM().getFilters(); for(i=0; i < myFilters.
CHAPTER 16 Objects flash object (fl) 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.
Method Description 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.
Properties Description 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.
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.
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.
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.
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.
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.
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.
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 A string that specifies the type of document to create.
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.
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.
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.
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.
Parameters A Boolean value that specifies whether to enable (true) or disable (false) immediate visual updates of the timeline when executing effects. bEnableUpdates 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.
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.
fl.getAppMemoryInfo() Availability Flash 8 (Windows only). Usage fl.getAppMemoryInfo( memType ) Parameters An integer that specifies the memory utilization area to be queried. For a list of acceptable values, see the following description. memType 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.
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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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 A string, expressed as a file:/// URI, that specifies the name of the script file fileURI to execute. funcName fileURI.
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.
See also document.save(), document.saveAndCompact(), fl.saveDocument(), fl.saveDocumentAs() fl.saveDocument() Availability Flash MX 2004. Usage fl.saveDocument( document [, fileURI] ) Parameters A Document object that specifies the document to be saved. If document is null, the active document is saved. document 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.
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.
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.
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.
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.
CHAPTER 17 Objects FLfile object Availability Flash MX 2004 7.2. Description The FLfile object lets you write Flash extensions that can access, modify, and remove files and folders on the local file system. The FLfile API is provided in the form of an extension to the JavaScript API.
Method summary for the FLfile object The following methods can be used with the FLfile object. Method Description FLfile.copy() Copies a file. FLfile.createFolder() Creates one or more folders. FLfile.exists() Determines the existence of a file or folder. FLfile.getAttributes() Finds out if a file is writable, read-only, hidden, visible, or a system folder. FLfile.getCreationDate() Specifies how many seconds have passed between January 1, 1970, and the time the file or folder was created.
Parameters fileURI A string, expressed as a file:/// URI, that specifies the file you want to copy. copyURI A string, expressed as a file:/// URI, that specifies the location and name of the copied file. Returns A Boolean value of true if successful; false otherwise. Description Method; copies a file from one location to another. This method returns false if copyURI already exists. Example The following example makes a backup copy of a configuration file named config.
Description Method; creates one or more folders at the specified location. You can create multiple folders at one time. For example, the following command creates both the MyData and the TempData folders if they don’t already exist: FLfile.createFolder("file:///c|/MyData/TempData") Example The following example creates two subfolders under the configuration folder (fl.configURI). fl.trace(FLfile.createFolder(fl.
Examples The following example checks for a file called mydata.txt and displays an alert box indicating whether the file exists. var fileURI = "file:///c|/temp/mydata.txt"; if (FLfile.exists(fileURI)) { alert( fileURI + " exists!"); } else { alert( fileURI + " does not exist."); } The following example checks to see if a required configuration file exists. If the file doesn’t exist, it is created: var configFile = "file:///C|/MyApplication/config.ini"; if (!FLfile.exists(configFile)) { FLfile.
Description Method; returns a string representing the attributes of the specified file or folder, or an empty string if the file has no specific attributes (that it, it is not read-only, not hidden, and so on). You should always use FLfile.exists() to test for the existence of a file or folder before using this method.
Returns A string containing a hexadecimal number that represents the number of seconds that have elapsed between January 1, 1970, and the time the file or folder was created, or "00000000" if the file or folder doesn’t exist. Description Method; specifies how many seconds have passed between January 1, 1970, and the time the file or folder was created. This method is used primarily to compare the creation or modification dates of files or folders.
Description Method; returns a JavaScript Date object that represents the date and time when the specified file or folder was created. Example The following example displays (in human-readable form) the date a file was created in the Output panel: // Make sure the specified file exists. var file1Date = FLfile.getCreationDateObj("file:///c|/temp/file1.txt"); fl.trace(file1Date); See also FLfile.getCreationDate(), FLfile.getModificationDateObj() FLfile.getModificationDate() Availability Flash MX 2004 7.2.
Example The following example compares the modification dates of two files and determines which of the two was modified most recently: // Make sure the specified files exist. file1 = "file:///C|/MyApplication/MyApp.fla" file2 = "file:///C|/MyApplication/MyApp.as" modificationTime1 = FLfile.getModificationDate(file1) modificationTime2 = FLfile.
Example The following example displays (in human-readable form) the date a file was last modified in the Output panel: // Make sure the specified file exists. var file1Date = FLfile.getModificationDateObj("file:///c|/temp/file1.txt"); trace(file1Date); See also FLfile.getCreationDateObj(), FLfile.getModificationDate() FLfile.getSize() Availability Flash MX 2004 7.2. Usage FLfile.
FLfile.listFolder() Availability Flash MX 2004 7.2. Usage FLfile.listFolder( folderURI [, filesOrDirectories ] ) Parameters folderURI A string, expressed as a file:/// URI, specifying the folder whose contents you want to retrieve. You can include a wildcard mask as part of folderURI. Valid wildcards are * (matches one or more characters) and ? (matches a single character). filesOrDirectories An optional string that specifies whether to return only filenames or only folder (directory) names.
The following example uses a file mask in the specified folderURI to return the names of all the executable files in the Windows application folder: var executables = FLfile.listFolder("file:///C|/WINDOWS/*.exe","files") alert(executables.join("\n")) FLfile.read() Availability Flash MX 2004 7.2. Usage FFLfile.read() Parameters A string, expressed as a file:/// URI, specifying the file or folder whose attributes you want to retrieve.
FLfile.remove() Availability Flash MX 2004 7.2. Usage FLfile.remove( fileOrFolderURI ) Parameters fileOrFolderURI A string, expressed as a file:/// URI, specifying the file or folder you want to remove (delete). Returns A Boolean value of true if successful; false otherwise. Description Method; deletes the specified file or folder. If the folder contains files, those files will be deleted as well. Files with the R (read-only) attribute cannot be removed.
The following example deletes the Configuration folder and its contents: FLfile.remove("file:///C|/MyApplication/Configuration/") See also FLfile.createFolder(), FLfile.getAttributes() FLfile.setAttributes() Availability Flash MX 2004 7.2. Usage FLfile.setAttributes( fileURI, strAttrs ) Parameters fileURI A string, expressed as a file:/// URI, specifying the file whose attributes you want to set. A string specifying values for the attribute(s) you want to set.
If you include both R and W in strAttrs, the R is ignored and the file is set as writable. Similarly, if you pass H and V, the H is ignored and the file is set as visible. If you want to make sure the archive attribute is not set, use this command with the N parameter before setting attributes. That is, there is no direct counterpart to A that turns off the archive attribute. Examples The following example sets the file mydata.txt to be read-only and hidden. It has no effect on the archive attribute.
Returns A Boolean value of true if successful; false otherwise. Description Method; writes the specified string to the specified file (as UTF-8). If the specified file does not exist, it is created. However, the folder in which you are placing the file must exist before you use this method. To create folders, use FLfile.createFolder(). Example The following example attempts to write the string "xxx" to the file mydata.txt and displays an alert message if the write succeeded.
CHAPTER 18 Objects folderItem object Inheritance Item object > folderItem object Availability Flash MX 2004. Description The folderItem object is a subclass of the Item object. There are no unique methods or properties of folderItem. See Item object.
CHAPTER 19 Objects fontItem object Inheritance Item object > fontItem object Availability Flash MX 2004. Description The fontItem object is a subclass of the Item object. There are no unique methods or properties of fontItem. See Item object.
CHAPTER 20 Objects Frame object Availability Flash MX 2004. Description The Frame object represents frames in the layer. Method summary for the Frame object The following methods can be used with the Frame object. Method Description frame.getCustomEase() Returns an array of JavaScript objects, each of which has an x and y property. frame.setCustomEase() Specifies a cubic Bézier curve to be used as a custom ease curve.
Property Description frame.motionTweenRotateTimes An integer that specifies the number of times the tweened element rotates between the starting keyframe and the next keyframe. frame.motionTweenScale A Boolean value; specifies whether the tweened element scales to the size of the object in the following keyframe, increasing its size with each frame in the tween (true) or doesn’t scale (false). frame.
Property Description frame.tweenType A string that specifies the type of tween. frame.useSingleEaseCurve A Boolean value that specifies whether a single custom ease curve is used for easing information for all properties. frame.actionScript Availability Flash MX 2004. Usage frame.actionScript Description Property; a string that represents ActionScript code. To insert a new line character, use "\\n". Example The following example assigns stop() to first frame top layer action: fl.getDocumentDOM().
frame.elements Availability Flash MX 2004. Usage frame.elements Description Read-only property; an array of Element objects (see Element object). The order of elements is the order in which they are stored in the FLA file. If there are multiple shapes on the Stage, and each is ungrouped, Flash treats them as one element. If each shape is grouped, so there are multiple groups on the Stage, Flash sees them as separate elements.
Description Method; returns an array of objects that represent the control points for the cubic Bézier curve that defines the ease curve. Example The following example returns the custom ease value of the position property for the first frame in the top layer: var theFrame = fl.getDocumentDOM().getTimeline().layers[0].frames[0] var easeArray = theFrame.getCustomEase( "position" ); See also frame.hasCustomEase, frame.setCustomEase(), frame.useSingleEaseCurve frame.hasCustomEase Availability Flash 8.
frame.labelType Availability Flash MX 2004. Usage frame.labelType Description Property; a string that specifies the type of Frame name. Acceptable values are "none", "name", "comment", and "anchor". Setting a label to "none" clears the frame.name property. Example The following example sets the name of the first frame in the top layer to "First Frame" and then sets its label to "comment": fl.getDocumentDOM().getTimeline().layers[0].frames[0].name = 'First Frame'; fl.getDocumentDOM().getTimeline().
frame.motionTweenRotate Availability Flash MX 2004. Usage frame.motionTweenRotate Description Property; a string that specifies how the tweened element rotates. Acceptable values are "none", "auto", "clockwise", and "counter-clockwise". A value of "auto" means the object will rotate in the direction requiring the least motion to match the rotation of the object in the following keyframe. If you want to specify a value for frame.motionTweenOrientToPath, set this property to "none". Example See frame.
frame.motionTweenScale Availability Flash MX 2004. Usage frame.motionTweenScale Description Property; a Boolean value; specifies whether the tweened element scales to the size of the object in the following keyframe, increasing its size with each frame in the tween (true) or doesn’t scale (false). Example The following example specifies that the tweened element should scale to the size of the object in the following keyframe, increasing its size with each frame in the tween. fl.getDocumentDOM().
Description Property; a Boolean value; if set to true, synchronizes the animation of the tweened object with the main timeline. Example The following example specifies that tweened object should be synchronized with the timeline: fl.getDocumentDOM().getTimeline().layers[0].frames[0].motionTweenSync = true; frame.name Availability Flash MX 2004. Usage frame.name Description Property; a string that specifies the name of the frame.
Parameters A string that specifies the property the ease curve should be used for. Acceptable values are "all", "position", "rotation", "scale", "color", and "filters". property An array of objects that defines the ease curve. Each array element must be a JavaScript object with x and y properties. easeCurve Returns Nothing. Description Method; specifies an array of control point and tangent endpoint coordinates that describe a cubic Bézier curve to be used as a custom ease curve.
frame.shapeTweenBlend Availability Flash MX 2004. Usage frame.shapeTweenBlend Description Property; a string that specifies how a shape tween is blended between the shape in the keyframe at the start of the tween and the shape in the following keyframe. Acceptable values are "distributive" and "angular". frame.soundEffect Availability Flash MX 2004. Usage frame.soundEffect Description Property; a string that specifies effects for a sound that is attached directly to a frame (frame.soundLibraryItem).
Description Property; a library item (see SoundItem object) used to create a sound. The sound is attached directly to the frame. Example The following example assigns the first item in the library to the soundLibraryItem property of the first frame: // The first item in the library must be a sound object fl.getDocumentDOM().getTimeline().layers[0].frames[0].soundLibraryItem =fl.getDocumentDOM().library.items[0]; frame.soundLoop Availability Flash MX 2004. Usage frame.
Example The following example specifies that a sound should play two times: fl.getDocumentDOM().getTimeline().layers[0].frames[0].soundLoopMode = "repeat"; fl.getDocumentDOM().getTimeline().layers[0].frames[0].soundLoop = 2; frame.soundName Availability Flash MX 2004. Usage frame.soundName Description Property; a string that specifies the name of a sound that is attached directly to a frame (frame.soundLibraryItem), as stored in the library.
frame.startFrame Availability Flash MX 2004. Usage frame.startFrame Description Read-only property; the index of the first frame in a sequence. Example In the following example, stFrame is the index of the first frame in the frame sequence. In this example, a frame sequence is spanning the six frames from Frame 5 to Frame 10. Therefore, the value of stFrame at any frame between Frame 5 and Frame 10 is 4 (remember that index values are different from frame number values). var stFrame = fl.
Example The following example specifies that the motion of the tweened object should begin fairly rapidly and decelerate toward the end of the animation: fl.getDocumentDOM().getTimeline().layers[0].frames[0].tweenEasing = 50; frame.tweenType Availability Flash MX 2004. Usage frame.tweenType Description Property; a string that specifies the type of tween; acceptable values are "motion", "shape", or "none". The value "none" removes the motion tween. Use the timeline.
frame.useSingleEaseCurve Availability Flash 8. Usage frame.useSingleEaseCurve Description Property; a Boolean value. If true, a single custom ease curve is used for easing information for all properties. If false, each property has its own ease curve. This property is ignored if the frame doesn’t have custom easing applied. Example The following example specifies that a single custom ease curve should be used for all properties of the first frame on the first layer: var theFrame = fl.getDocumentDOM().
CHAPTER 21 Objects HalfEdge object Availability Flash MX 2004. Description The HalfEdge object is the directed side of the edge of a Shape object. An edge has two half edges. You can transverse the contours of a shape by “walking around” these half edges. For example, starting from a half edge, you can trace all the half edges around a contour of a shape, and return to the original half edge. Half edges are ordered.
Usage halfEdge.getEdge() Parameters None. Returns An Edge object. Description Method; gets the Edge object for the HalfEdge object. See Edge object. Example The following example illustrates getting an edge and a half edge for the specified shape. var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge(0); var edge = hEdge.getEdge(); halfEdge.getNext() Availability Flash MX 2004. Usage halfEdge.getNext() Parameters None. Returns A HalfEdge object.
Example The following example stores the next half edge of the specified contour in the nextHalfEdge variable: var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge( 0 ); var nextHalfEdge = hEdge.getNext(); halfEdge.getOppositeHalfEdge() Availability Flash MX 2004. Usage halfEdge.getOppositeHalfEdge() Parameters None. Returns A HalfEdge object. Description Method; gets the HalfEdge object on the other side of the edge.
Returns A HalfEdge object. Description Method; gets the preceding HalfEdge object on the current contour. NO TE Although half edges have a direction and a sequence order, edges do not. Example The following example stores the previous half edge of the specified contour in the prevHalfEdge variable: var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge( 0 ); var prevHalfEdge = hEdge.getPrev(); halfEdge.getVertex() Availability Flash MX 2004. Usage halfEdge.
halfEdge.id Availability Flash MX 2004. Usage halfEdge.id Description Read-only property; a unique integer identifier for the HalfEdge object. Example The following example displays a unique identifier for the specified half edge in the Output panel: var shape = fl.getDocumentDOM().selection[0]; alert(shape.contours[0].getHalfEdge().id); halfEdge.index Availability Flash MX 2004. Usage halfEdge.
CHAPTER 22 Objects Instance object Inheritance Element object > Instance object Availability Flash MX 2004. Description Instance is a subclass of the Element object. Property summary for the Instance object In addition to all of the Element object properties, Instance has the following properties: Property Description instance.instanceType Read-only; a string that represents the type of Instance. instance.libraryItem Library item used to instantiate this instance. instance.
instance.libraryItem Availability Flash MX 2004. Usage instance.libraryItem Description Property; a library item used to instantiate this instance. You can change this property only to another library item of the same type (that is, you cannot set a symbol instance to refer to a bitmap). See library object. Example The following example changes the selected symbol to refer to the first item in the library: fl.getDocumentDOM().selection[0].libraryItem = fl.getDocumentDOM().library.
CHAPTER 23 Objects Item object Availability Flash MX 2004. Description The Item object is an abstract base class. Anything in the library derives from Item. See also library object. Method summary for the Item object The following methods are available for the Item object. Method Description item.addData() Adds specified data to a library item. item.getData() Retrieves the value of the specified data. item.hasData() Determines whether the library item has the named data. item.
Property Description item.linkageImportForRS A Boolean value. If true, the item is imported for runtime sharing. item.linkageURL A string that specifies the URL where the SWF file containing the shared asset is located. item.name A string that specifies the name of the library item, which includes the folder structure. item.addData() Availability Flash MX 2004. Usage item.addData( name, type, data ) Parameters name A string that specifies the name of the data.
item.getData() Availability Flash MX 2004. Usage item.getData( name ) Parameters name A string that specifies the name of the data to retrieve. Returns The data specified by the name parameter. The type of data returned depends on the type of stored data. Description Method; retrieves the value of the specified data. Example The following example gets the value of the data named myData from the first item in the library and stores it in the variable libData. var libData = fl.getDocumentDOM().library.
Example The following example shows a message in the Output panel if the first item in the library contains data point named myData: if ( fl.getDocumentDOM().library.items[0].hasData( "myData" ) ){ fl.trace("Yep, it's there!"); } item.itemType Availability Flash MX 2004. Usage item.itemType Description Read-only property; a string that specifies the type of element.
Example The following example specifies that the ActionScript 2.0 class name associated with the first item in the library is myClass: fl.getDocumentDOM().library.items[0].linkageClassName = "myClass"; item.linkageExportForAS Availability Flash MX 2004. Usage item.linkageExportForAS Description Property; a Boolean value. If this property is true, the item is exported for ActionScript. You can also set the item.linkageExportForRS and item.linkageExportInFirstFrame properties to true.
Description Property; a Boolean value. If this property is true, the item is exported for runtime sharing. You can also set the item.linkageExportForAS and item.linkageExportInFirstFrame properties to true. If you set this property to true, the item.linkageImportForRS property must be set to Also, you must specify an identifier (item.linkageIdentifier) and a URL (item.linkageURL). false. Example The following example sets this property for the specified library item: fl.getDocumentDOM().library.
item.linkageIdentifier Availability Flash MX 2004. Usage item.linkageIdentifier Description Property; a string that specifies the name Flash will use to identify the asset when linking to the destination SWF file. Flash ignores this property if item.linkageImportForRS, item.linkageExportForAS, and item.linkageExportForRS are set to false. Conversely, this property must be set when any of those properties are set to true.
item.linkageURL Availability Flash MX 2004. Usage item.linkageURL Description Property; a string that specifies the URL where the SWF file containing the shared asset is located. Flash ignores this property if item.linkageImportForRS, item.linkageExportForAS, and item.linkageExportForRS are set to false. Conversely, this property must be set when any of those properties are set to true.
item.removeData() Availability Flash MX 2004. Usage item.removeData( name ) Parameters name Specifies the name of the data to remove from the library item. Returns Nothing. Description Property; removes persistent data from the library item. Example The following example removes the data named myData from the first item in the library: fl.getDocumentDOM().library.items[0].
CHAPTER 24 Objects Layer object Availability Flash MX 2004. Description The Layer object represents a layer in the timeline. The timeline.layers property contains an array of Layer objects, which can be accessed by fl.getDocumentDOM().getTimeline().layers. Property summary for the Layer object The following properties are available for the Layer object: Property Description layer.color A string, hexadecimal value, or integer that specifies the color assigned to outline the layer. layer.
layer.color Availability Flash MX 2004. Usage layer.color Description Property; the color assigned to outline the layer, in one of the following formats: ■ A string in the format "#RRGGBB" or "#RRGGBBAA" ■ A hexadecimal number in the format 0xRRGGBB ■ An integer that represents the decimal equivalent of a hexadecimal number This property is equivalent to the Outline color setting in the Layer Properties dialog box.
layer.frames Availability Flash MX 2004. Usage layer.frames Description Read-only property; an array of Frame objects (see Frame object). Example The following example sets the variable frameArray to the array of Frame objects for the frames in the current document: var frameArray = fl.getDocumentDOM().getTimeline().layers[0].frames; To determine if a frame is a keyframe, check whether the frame.startFrame property matches the array index, as shown in the following example: var frameArray = fl.
Example The following example stores the percentage value of the first layer’s height setting: var layerHeight = fl.getDocumentDOM().getTimeline().layers[0].height; The following example sets the height of the first layer to 300 percent: fl.getDocumentDOM().getTimeline().layers[0].height = 300; layer.layerType Availability Flash MX 2004. Usage layer.layerType Description Property; a string that specifies the current use of the layer; equivalent to the Type setting in the Layer Properties dialog box.
Example The following example stores the Boolean value for the status of the first layer in the lockStatus variable: var lockStatus = fl.getDocumentDOM().getTimeline().layers[0].locked; The following example sets the status of the first layer to unlocked: fl.getDocumentDOM().getTimeline().layers[0].locked = false; layer.name Availability Flash MX 2004. Usage layer.name Description Property; a string that specifies the name of the layer.
layer.parentLayer Availability Flash MX 2004. Usage layer.parentLayer Description Property; a Layer object that represents the layer’s containing folder, guiding, or masking layer. Acceptable values for the parent layer are a folder, guide, or mask layer that precedes the layer, or the parentLayer of the preceding or following layer. Setting the layer’s parentLayer does not move the layer’s position in the list; trying to set a layer’s parentLayer to a layer that would require moving it has no effect.
CHAPTER 25 Objects library object Availability Flash MX 2004. Description The library object represents the Library panel. It is a property of the Document object (see document.library) and can be accessed by fl.getDocumentDOM().library. The library object contains an array of items of different types, including symbols, bitmaps, sounds, and video. Method summary for the library object The following methods are available for the library object: Method Description library.
Method Description library.newFolder() Creates a new folder with the specified name, or a default name ("untitled folder #") if no folderName parameter is provided, in the currently selected folder. library.renameItem() Renames the currently selected library item in the Library panel. library.selectAll() Selects or deselects all items in the library. library.selectItem() Selects a specified library item. library.selectNone() Selects all the library items. library.
Description Method; adds the current or specified item to the Stage at the specified position. Example The following example adds the currently selected item to the Stage at the (3, 60) position: fl.getDocumentDOM().library.addItemToDocument({x:3, y:60}); The following example adds the item Symbol1 located in folder1 of the library to the Stage at the (550, 485) position: fl.getDocumentDOM().library.addItemToDocument({x:550.0, y:485.0}, "folder1/ Symbol1"); library.
library.deleteItem() Availability Flash MX 2004. Usage library.deleteItem( [ namePath ] ) Parameters A string that specifies the name of the item to be deleted. If the item is in a folder, you can specify its name and path using slash notation. If you pass a folder name, the folder and all its items are deleted. If no name is specified, Flash deletes the currently selected item or items. To delete all the items in the Library panel, select all items before using this method. This parameter is optional.
Returns A Boolean value: true if the item is duplicated successfully; false otherwise. If more than one item is selected, Flash returns false. Description Method; makes a copy of the currently selected or specified item. The new item has a default name (such as item copy) and is set as the currently selected item. If more than one item is selected, the command fails. Example The following example creates a copy of the item square in the library folder test: fl.getDocumentDOM().library.
library.expandFolder() Availability Flash MX 2004. Usage library.expandFolder( bExpand [, bRecurseNestedParents [, namePath ] ] ) Parameters A Boolean value: if true, the folder is expanded; if false (the default), the folder is collapsed. bExpand A Boolean value: if true, all the folders within the specified folder are expanded or collapsed, based on the value of bExpand. The default value is false. This parameter is optional.
Parameters A string that specifies the name of the item. If the item is in a folder, you can specify its name and path using slash notation. namePath Returns An integer value representing the item’s zero-based index value. Description Method; returns the library item’s index value (zero-based). The library index is flat, so folders are considered part of the main index. Folder paths can be used to specify a nested item.
library.getItemType() Availability Flash MX 2004. Usage library.getItemType( [ namePath ] ) Parameters A string that specifies the name of the item. If the item is in a folder, specify its name and path using slash notation. If namePath is not specified, Flash provides the type of the current selection. If more than one item is currently selected and no namePath is provided, Flash ignores the command. This parameter is optional. namePath Returns A string value specifying the type of object.
Example The following example stores the array of currently selected library items (in this case, several audio files) in the selItems variable and then changes the sampleRate property of the first audio file in the array to "11 kHz": var selItems = fl.getDocumentDOM().library.getSelectedItems(); selItems[0].sampleRate = "11 kHz"; library.importEmbeddedSWF() Availability Flash MX 2004. Usage library.
library.itemExists() Availability Flash MX 2004. Usage library.itemExists( namePath ) Parameters A string that specifies the name of the item. If the item is in a folder, specify its name and path using slash notation. namePath Returns A Boolean value: true if the specified item exists in the library; false otherwise. Description Method; checks to see if a specified item exists in the library.
library.moveToFolder() Availability Flash MX 2004. Usage library.moveToFolder( folderPath [, itemToMove [, bReplace ] ] ) Parameters A string that specifies the path to the folder in the form "FolderName" or To move an item to the top level, specify an empty string ("") for folderPath. folderPath "FolderName/FolderName". itemToMove A string that specifies the name of the item to move. If itemToMove is not specified, the currently selected items move. This parameter is optional.
Parameters folderPath A string that specifies the name of the folder to be created. If it is specified as a path, and the path doesn’t exist, the path is created. This parameter is optional. Returns A Boolean value: true if folder is created successfully; false otherwise. Description Method; creates a new folder with the specified name, or a default name ("untitled folder #") if no folderName parameter is provided, in the currently selected folder.
library.selectAll() Availability Flash MX 2004. Usage library.selectAll( [ bSelectAll ] ) Parameters A Boolean value that specifies whether to select or deselect all items in the library. Omit this parameter or use the default value of true to select all the items in the library; false deselects all library items. This parameter is optional. bSelectAll Returns Nothing. Description Method; selects or deselects all items in the library.
Parameters A string that specifies the name of the item. If the item is in a folder, you can specify its name and path using slash notation. namePath A Boolean value that specifies whether to replace the current selection or add the item to the current selection. The default value is true (replace current selection). This parameter is optional. bReplaceCurrentSelection A Boolean value that specifies whether to select or deselect an item. The default value is true (select). This parameter is optional.
Description Method; deselects all the library items. Example The following examples deselect all the items in the library: fl.getDocumentDOM().library.selectNone(); fl.getDocumentDOM().library.selectAll(false); library.setItemProperty() Availability Flash MX 2004. Usage library.setItemProperty( property, value ) Parameters A string that is the name of the property to set. For a list of properties, see the Property summary for the Item object and property summaries for its subclasses.
library.updateItem() Availability Flash MX 2004. Usage library.updateItem( [ namePath ] ) Parameters A string that specifies the name of the item. If the item is in a folder, specify its name and path using slash notation. This is the same as right-clicking on an item and selecting Update from the menu in the user interface. If no name is provided, the current selection is updated. This parameter is optional.
CHAPTER 26 Objects Math object Availability Flash MX 2004. Description The Math object is available as a read-only property of the flash object; see fl.Math. This object provides methods that perform common mathematical operations. Method summary for the Math object The following methods are available for the Math object: Method Description Math.concatMatrix() Performs a matrix concatenation and returns the result. Math.invertMatrix() Returns the inverse of the specified matrix. Math.
Description Method; performs a matrix concatenation and returns the result. Example The following example stores the currently selected object in the elt variable, multiplies the object matrix by the view matrix, and stores that value in the mat variable: var elt = fl.getDocumentDOM().selection[0]; var mat = fl.Math.concatMatrix( elt.matrix , fl.getDocumentDOM().viewMatrix ); Math.invertMatrix() Availability Flash MX 2004. Usage Math.
Math.pointDistance() Availability Flash MX 2004. Usage Math.pointDistance(pt1, pt2) Parameters pt1 and pt2 Specify the points between which distance is measured. Returns A floating-point value that represents the distance between the points. Description Method; computes the distance between two points. Example The following example stores the value for the distance between pt1 and pt2 in the dist variable: var pt1 = {x:10, y:20} var pt2 = {x:100, y:200} var dist = fl.Math.
CHAPTER 27 Objects Matrix object Availability Flash MX 2004. Description The Matrix object represents a transformation matrix. Property summary for the Matrix object The following properties are available for the Matrix object: Property Description matrix.a A floating-point value that specifies the (0,0) element in the transformation matrix. matrix.b A floating-point value that specifies the (0,1) element in the matrix. matrix.
Example The a and d properties in a matrix represent scaling. In the following example, the values are set to 2 and 3, respectively, to scale the selected object to two times its width and three times its height: var mat = fl.getDocumentDOM().selection[0].matrix; mat.a = 2; mat.d = 3; fl.getDocumentDOM().selection[0].matrix = mat; You can rotate an object by setting the a, b, c, and d matrix properties relative to one another, where a = d and b = -c. For example, values of 0.5, 0.8, -0.8, and 0.
Example In the following example, you can set b and c to -1 and 0, respectively; these settings skew the object at a 45º vertical angle: var mat = fl.getDocumentDOM().selection[0].matrix; mat.b = -1; mat.c = 0; fl.getDocumentDOM().selection[0].matrix = mat; To skew the object back to its original shape, you can set b and c to 0. See also the matrix.a example. matrix.c Availability Flash MX 2004. Usage matrix.c Description Property; a floating-point value that specifies the (1,0) element in the matrix.
matrix.tx Availability Flash MX 2004. Usage matrix.tx Description Property; a floating-point value that specifies the x-axis location of a symbol’s registration point or the center of a shape. It defines the x translation of the transformation. You can move an object by setting the matrix.tx and matrix.ty properties (see matrix.ty). Example In the following example, setting tx and ty to 0 moves the registration point of the object to point 0,0 in the document: var mat = fl.getDocumentDOM().selection[0].
CHAPTER 28 Objects outputPanel object Availability Flash MX 2004. Description This object represents the Output panel, which displays troubleshooting information such as syntax errors. To access this object, use fl.outputPanel (or flash.outputPanel). See fl.outputPanel. Method summary for the outputPanel object The outputPanel object uses the following methods. Method Description outputPanel.clear() Clears the contents of the Output panel. outputPanel.
Example The following example clears the current contents of the Output panel: fl.outputPanel.clear(); outputPanel.save() Availability Flash MX 2004; bUseSystemEncoding parameter added in Flash 8. Usage outputPanel.save(fileURI [, bAppendToFile [ , bUseSystemEncoding ] ]) Parameters A string, expressed as a file:/// URI, that specifies the local file to contain the contents of the Output panel. fileURI An optional Boolean value.
outputPanel.trace() Availability Flash MX 2004. Usage outputPanel.trace(message) Parameters The message parameter is a string that contains the text to add to 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 fl.trace(), and works in the same way as the trace() statement in ActionScript. To send a blank line, use outputPanel.
CHAPTER 29 Objects Parameter object Availability Flash MX 2004. Description The Parameter object type is accessed from the screen.parameters array (which corresponds to the screen Property inspector in the Flash authoring tool) or by the componentInstance.parameters array (which corresponds to the component Property inspector in the authoring tool). See screen.parameters and componentInstance.parameters.
parameter.category Availability Flash MX 2004. Usage parameter.category Description Property; a string that specifies the category property for the screen parameter or componentInstance parameter. This property provides an alternative way of presenting a list of parameters. This functionality is not available through the Flash user interface. parameter.insertItem() Availability Flash MX 2004. Usage parameter.
Description Method; inserts an item in a list, object, or array. If a parameter is a list, object, or array, the value property is an array. Example The following example inserts the value of "New Value" into the labelPlacement parameter: // Select an instance of a Button component on the Stage. var parms = fl.getDocumentDOM().selection[0].parameters; parms[2].insertItem(0, "name", "New Value", "String"); var values = parms[2].value; for(var prop in values){ fl.
parameter.name Availability Flash MX 2004. Usage parameter.name Description Read-only property; a string that specifies the name of the parameter. Example The following example shows the name of the fifth parameter for the selected component: var parms = fl.getDocumentDOM().selection[0].parameters; fl.trace("name: " + parms[4].name); The following example shows the name of the fifth parameter for the specified screen: var parms = fl.getDocumentDOM().screenOutline.screens[1].parameters; fl.
Example The following example removes the element at index 1 from the labelPlacement parameter of a component: // Select an instance of a Button component on the Stage. var parms = fl.getDocumentDOM().selection[0].parameters; var values = parms[2].value; fl.trace("--Original--"); for(var prop in values){ fl.trace("labelPlacement value = " + values[prop].value); } parms[2].removeItem(1); var newValues = parms[2].value; fl.trace("--After Removing Item--"); for(var prop in newValues){ fl.
Description Property; corresponds to the Value field in the Parameters tab of the Component inspector, the Parameters tab of the Property inspector, or the screen Property inspector. The type of the value property is determined by the valueType property for the parameter (see parameter.valueType). parameter.valueType Availability Flash MX 2004. Usage parameter.valueType Description Read-only property; a string that indicates the type of the screen or component parameter.
CHAPTER 30 Objects Path object Availability Flash MX 2004. Description The Path object defines a sequence of line segments (straight, curved, or both), which you typically use when creating extensible tools. The following example shows an instance of a Path object being returned from the flash object: path = fl.drawingLayer.newPath(); See also the drawingLayer object. Method summary for the Path object The following methods are available for the Path object: Method Description path.
path.addCubicCurve() Availability Flash MX 2004. Usage path.addCubicCurve(xAnchor, yAnchor, x2, y2, x3, y3, x4, y4) Parameters xAnchor A floating-point number that specifies the x position of the first control point. yAnchor A floating-point number that specifies the y position of the first control point. x2 A floating-point number that specifies the x position of the second control point. y2 A floating-point number that specifies the y position of the second control point.
Parameters xAnchor A floating-point value that specifies the x position of the first control point. yAnchor A floating-point value that specifies the y position of the first control point. x2 A floating-point value that specifies the x position of the second control point. y2 A floating-point value that specifies the y position of the second control point. x3 A floating-point value that specifies the x position of the third control point.
Description Method; adds a point to the path. Example The following example creates a new path, stores it in the myPath variable, and assigns the new point to the path: var myPath = fl.drawingLayer.newPath(); myPath.addPoint(10, 100); path.clear() Availability Flash MX 2004. Usage path.clear() Parameters None. Returns Nothing. Description Method; removes all points from the path. Example The following example removes all points from a path stored in the myPath variable: var myPath = fl.
Returns Nothing. Description Method; appends a point at the location of the first point of the path and extends the path to that point, which closes the path. If the path has no points, no points are added. Example The following example creates a closed path: var myPath = fl.drawingLayer.newPath(); myPath.close(); path.makeShape() Availability Flash MX 2004. Usage path.
path.newContour() Availability Flash MX 2004. Usage path.newContour() Parameters None. Returns Nothing. Description Method; starts a new contour in the path. Example The following example creates a hollow square: var myPath = fl.drawingLayer.newPath(); myPath.addPoint( 0, 0); myPath.addPoint( 0, 30); myPath.addPoint(30, 30); myPath.addPoint(30, 0); myPath.addPoint( 0, 0); myPath.newContour(); myPath.addPoint(10, 10); myPath.addPoint(10, 20); myPath.addPoint(20, 20); myPath.addPoint(20, 10); myPath.
path.nPts Availability Flash MX 2004. Usage path.nPts Description Read-only property; an integer representing the number of points in the path. A new path has 0 points. Example The following example uses the Output panel to show the number of points in the path referenced by the myPath variable: var myPath = fl.drawingLayer.newPath(); var numOfPoints = myPath.nPts; fl.
CHAPTER 31 Objects Project object Availability Flash 8. Description The Project object represents a Flash Project (FLP) file. You can use the following commands to return a Project object: ■ To create a new project file, use fl.createProject(). ■ To open an existing project file, use fl.openProject(). ■ To return a Project object for the currently open project, use fl.getProject(). Method summary for the Project object The following methods can be used with the Project object.
project.addFile() Availability Flash 8. Usage project.addFile( fileURI [ , autoCreateFolder ] ) Parameters fileURI A string specifying the file to be added to the project, expressed as a file:/// URI. An optional Boolean value specifying if folders should be automatically created in the Project panel to mirror the path in fileURI; the default value is false. autoCreateFolder Returns If successful, returns a ProjectItem object; otherwise, returns undefined. See ProjectItem object.
Example The following example illustrates several ways to use this command. In this case, the open project file is in the c:\Projects directory, and the only files currently in the project have been added at the root level. // Get the project object var myProject = fl.getProject(); // The following command creates a folder named "files" below the root level in the project, and places myFile.fla in that folder. var newFile = myProject.addFile("file:///C|Projects/files/myFile.fla", true) fl.trace(newFile.
Returns A Boolean value specifying whether the project can be published. Description Method; determines whether the project can be published. A project can be published if it contains at least one FLA file. Example The following example displays a message in the Output panel if the project cannot be published: if (!fl.getProject().canPublishProject()) { fl.trace("Project cannot be published!"); } See also fl.getProject(), project.publishProject(), projectItem.canPublish() project.
Example The following example displays a message in the Output panel if the project cannot be tested: if (!fl.getProject().canTestProject()) { fl.trace("Project cannot be tested!"); } See also fl.getProject(), project.testProject(), projectItem.canTest() project.defaultItem Availability Flash 8. Usage project.defaultItem Description Property; specifies the ProjectItem object that represents the default document in the project. You must specify a default item if you want to test the project.
project.findProjectItem() Availability Flash 8. Usage project.findProjectItem( fileURI ) Parameters fileURI A string specifying the file to search for in the project, expressed as a file:/// URI. Returns A ProjectItem object for the item if successful; otherwise, returns false. See ProjectItem object. Description Method; searches for a specified file in the project.
Example The following example displays the names of all the items in the project in the Output panel: for (i = 0; i < fl.getProject().items.length; i++) { fl.trace(fl.getProject().items[i].displayName); } See also fl.getProject(), ProjectItem object project.name Availability Flash 8. Usage project.name Description Property; the name of the project that appears in the Project panel. Example The following example specifies a new name to be displayed in the Project panel: fl.getProject().
Example The following example displays the path and name of the currently open project file in the Output panel: fl.trace("Project is located at: " + fl.getProject().projectURI); See also fl.getProject(), project.name project.publishProject() Availability Flash 8. Usage project.publishProject() Parameters None. Returns A Boolean value indicating if the project was successfully published. Description Method; publishes the FLA files in a project.
project.testProject() Availability Flash 8. Usage project.testProject() Parameters None. Returns A Boolean value indicating if the project was successfully tested. Description Method; tests the project. A project must have a default document to be tested. Example The following example tests the project after confirming that it can be tested, and then indicates whether the project was tested in the Output panel: if (fl.getProject().canTestProject()) { var bSucceeded = fl.getProject().
CHAPTER 32 Objects ProjectItem object Availability Flash 8. Description The ProjectItem object represents an item (file on disk) that has been added to a project. This object is a property of the Project object (see project.items). You can use the following commands to return a ProjectItem object. ■ To add a new file to a project, use project.addFile(). ■ To locate an item that has already been added to a project, use project.findProjectItem().
projectItem.canPublish() Availability Flash 8. Usage projectItem.canPublish() Parameters None. Returns A Boolean value specifying whether a project item can be published. Description Method; determines whether an item can be published. An item can be published only if it is a FLA file. Example The following example displays a message in the Output panel if the first item in the project cannot be published. var item = fl.getProject().items[0]; if (!item.canPublish()) { fl.trace(item.
Returns A Boolean value specifying whether a project item can be tested. Description Method; determines whether an item can be tested. An item can be tested if it is a FLA or HTML file. Example The following example displays a message in the Output panel if the first item in the project cannot be tested. var item = fl.getProject().items[0]; if (!item.canTest()) { fl.trace(item.name + " cannot be tested!"); } See also fl.getProject(), project.canTestProject(), project.items, projectItem.
projectItem.isMissing Availability Flash 8. Usage projectItem.isMissing Description Read-only property; a Boolean value that specifies whether a file is missing from the disk (for example, if the item has been moved, deleted or renamed). Example The following example displays a message in the Output panel that indicates whether a specific file is on the disk in the expected folder. var item = fl.getProject().findProjectItem("file:///C|/Projects/files/ DynamicHighAscii.fla"); fl.trace("DynamicHighAscii.
Example The following example displays the path and name of each item in the project in the Output panel. files = fl.getProject().items; for (i = 0; i < files.length; i++) { fl.trace(files[i].itemURI); } See also fl.getProject(), projectItem.displayName, project.items projectItem.publish() Availability Flash 8. Usage projectItem.publish() Parameters None. Returns A Boolean value of true if successful; false otherwise. Description Method; publishes a project item.
projectItem.publishProfile Availability Flash 8. Usage projectItem.publishProfile Description Property; a string that specifies the publish profile to use when publishing a project item (FLA file). The publish profile must be an existing profile in the item, or a subsequent call to projectItem.publish() will fail. See projectItem.publish(). If the item is not a FLA file, this property is an empty string (""), and any attempts to set this property fail.
projectItem.test() Availability Flash 8. Usage projectItem.test() Parameters None. Returns A Boolean value that indicates whether the item was successfully tested or not. Descriptionn Method; tests a project item. If the test operation fails because the item is not a FLA or HTML file, this method returns false. Example The following example tests all the FLA and HTML files in the project: for (var i in fl.getProject().items) { var item = fl.getProject().items[i]; if (item.canTest()) { item.
CHAPTER 33 Objects Screen object Availability Flash MX 2004. Description The Screen object represents a single screen in a slide or form document. This object contains properties related to the slide or form. For access to the array of all Screen objects in the document, use the following code: fl.getDocumentDOM().screenOutline.screens Property summary for the Screen object The Screen object has the following properties: Properties Description screen.
Properties Description screen.tabIndex Property; equivalent to the Tab Index field in the Accessibility panel. screen.timeline Read-only; the Timeline object for the screen. See Timeline object. screen.accName Availability Flash MX 2004. Usage screen.accName Description Property; a string that is equivalent to the Name field in the Accessibility panel. Screen readers identify objects by reading the name aloud.
Example The following example checks to see if the current document is a slide or form, and if it is, stores the array of child screens in the myChildren variable and displays their names in the Output panel: var myChildren = new Array(); if(fl.getDocumentDOM().allowScreens) { var myParent = fl.getDocumentDOM().screenOutline.rootScreen.name for (i in fl.getDocumentDOM().screenOutline.rootScreen.childScreens) { myChildren.push(" "+fl.getDocumentDOM().screenOutline.rootScreen.childScreens[i].name); } fl.
screen.forceSimple Availability Flash MX 2004. Usage screen.forceSimple Description Property; a Boolean value that enables or disables accessibility for the object’s children. This is equivalent to the inverse logic of the Make Child Objects Accessible setting in the Accessibility panel. That is, if forceSimple is true, it is the same as the Make Child Object Accessible option being deselected. If forceSimple is false, it is the same as the Make Child Object Accessible option being selected.
Example The following example checks to see if the first screen in the outline is hidden and changes the visibility of the screen accordingly. Then, a message in the Output panel shows what the visibility of the screen was before the change: if (fl.getDocumentDOM().screenOutline.screens[0].hidden) { fl.getDocumentDOM().screenOutline.setScreenProperty("hidden", false); fl.trace(fl.getDocumentDOM().screenOutline.screens[0].name+" had its 'hidden' property set to 'false'"); } else { fl.getDocumentDOM().
screen.name Availability Flash MX 2004. Usage screen.name Description Read-only property; a string that represents the name of the screen. Example The following example checks to see if the current document allows screens (because it is a slide or form document). Then, it assigns the name value of the first child screen in the array to the myName variable and opens the Output panel to show the name of the screen: var myChildren = new Array(); if(fl.getDocumentDOM().allowScreens) { var myName = fl.
Example The following example first checks to see if the current document is a slide or form, and if it is, retrieves and shows the sequence of screens in the Output panel: if(fl.getDocumentDOM().allowScreens) { var myCurrent = fl.getDocumentDOM().screenOutline.rootScreen.childScreens[0].name; var myNext = fl.getDocumentDOM().screenOutline.rootScreen.childScreens[0].nextScreen. name; fl.trace(" The next screen to "+myCurrent+" is "+myNext+". "); } screen.parameters Availability Flash MX 2004.
screen.parentScreen Availability Flash MX 2004. Usage screen.parentScreen Description Read-only property; an object that represents the parent screen. If parentScreen is null, the screen is a top-level screen. Example The following example stores the values for the childScreens and parentScreen properties in variables and then shows those values and their parent/child relationship in the Output panel: if(fl.getDocumentDOM().allowScreens) { var myCurrent = fl.getDocumentDOM().screenOutline.rootScreen.
Example The following example checks to see if the current document is a slide or form, and if it is, retrieves and shows the sequence of screens in the Output panel: if(fl.getDocumentDOM().allowScreens) { var myCurrent = fl.getDocumentDOM().screenOutline.rootScreen.childScreens[1].name; var myNext = fl.getDocumentDOM().screenOutline.rootScreen.childScreens[1].prevScreen. name; fl.trace(" The previous screen to "+myCurrent+" is "+myNext+". "); } screen.silent Availability Flash MX 2004. Usage screen.
screen.tabIndex Availability Flash MX 2004. Usage screen.tabIndex Description Property; equivalent to the Tab Index field in the Accessibility panel. This value lets you determine the order in which objects are accessed when the user presses the Tab key. Example The following example gets the tab index of the object: var theTabIndex = fl.getDocumentDOM().screenOutline.screens[1].tabIndex; The following example sets the tab index of the object to 1: fl.getDocumentDOM().screenOutline.screens[1].
CHAPTER 34 Objects ScreenOutline object Availability Flash MX 2004. Description The ScreenOutline object represents the group of screens in a slide or form document. The object is accessed by using fl.getDocumentDOM().screenOutline. The ScreenOutline object exists only if the document is a slide or form document, so before accessing the property, use document.allowScreens() to verify that a Screens document exists, as shown in the following example: if(fl.getDocumentDOM().allowScreens) { var myName = fl.
Method Description screenOutline.renameScreen() Changes the screen with a specified name to a new name. screenOutline.setCurrentScreen() Sets the current selection in the screen outline to the specified screen. screenOutline.setScreenProperty() Lets the specified property with the specified value for the selected screens. screenOutline.setSelectedScreens() Selects the specified screens in the Screen Outline pane.
Description Method; inserts all the screens, or a named screen and its children, from a specified document under the currently selected screen. If more than one screen is selected, the screen(s) are inserted under the last selected screen, as its sibling. Example The following example copies the “slide1” screen from the myTarget.fla file on the Desktop into the current document (substitute your user name for userName): fl.getDocumentDOM().screenOutline.
Returns Nothing. Description Method; deletes the currently selected screen(s), or a specified screen, and the children of the screen(s). Example The following example removes the screen named apple and all its children: fl.getDocumentDOM().screenOutline.deleteScreen("apple"); screenOutline.duplicateScreen() Availability Flash MX 2004. Usage screenOutline.duplicateScreen( [screenName] ) Parameters A string value that specifies the screen name to duplicate.
screenOutline.getSelectedScreens() Availability Flash MX 2004. Usage screenOutline.getSelectedScreens() Parameters None. Returns An array of selected Screen objects (see Screen object). Description Method; returns an array of Screen objects that are currently selected in the screen outline. Example The following example stores the selected Screen objects in the myArray variable and displays the screen names in the Output panel: var myArray = fl.getDocumentDOM().screenOutline.
Parameters A string indicating the name of the new screen to insert. An empty name will insert a screen with a default screen name, such as Slide n or Form n (where n is the first available unique number). This parameter is optional. name referenceScreen A string indicating the name of the screen into which the new screen is inserted as a child. If this parameter is omitted, the new screen is inserted as a child of the currently selected screen. This parameter is optional.
Parameters A string indicating the name of the new screen to insert. If this parameter is omitted, the method inserts a screen with a default screen name, such as Slide n or Form n (where n is the first available unique number). This parameter is optional. name referenceScreen A string indicating the name of the screen before the new screen. If this parameter is omitted, the new screen is inserted after the currently selected screen.
Parameters screenToMove A string that is the screen name to move. referenceScreen A string that specifies the screen near which screenToMove will be placed. A string that specifies where to move the screen in relation to referenceScreen. Acceptable values are "before", "after", "firstChild", and "lastChild". position Returns A Boolean value: true if the move is successful; false otherwise.
Description Method; changes the screen with a specified name to a new name. Example The following example changes the name of slide1 to Intro: fl.getDocumentDOM().screenOutline.renameScreen("Intro", "slide1"); screenOutline.rootScreen Availability Flash MX 2004. Usage screenOutline.rootScreen Description Read-only property; the first screen in the screen outline. You can use screenOutline.rootScreen as a shortcut for screenOutline.screens[0].
Example The following example stores the array of Screen objects in the myArray variable and then displays their names in the Output panel: var myArray = new Array(); if(fl.getDocumentDOM().allowScreens) { for(var i in fl.getDocumentDOM().screenOutline.screens) { myArray.push(" "+fl.getDocumentDOM().screenOutline.screens[i].name); } fl.trace("The screens array contains objects whose names are: "+myArray+". "); } screenOutline.setCurrentScreen() Availability Flash MX 2004. Usage screenOutline.
screenOutline.setScreenProperty() Availability Flash MX 2004. Usage screenOutline.setScreenProperty( property, value ) Parameters property A string that specifies the property to set. The new value for the property. The type of value depends on the property value being set. For a list of available properties and values, see Property summary for the Screen object. Returns Nothing. Description Method; sets the specified property with the specified value for the selected screens.
screenOutline.setSelectedScreens() Availability Flash MX 2004. Usage screenOutline.setSelectedScreens ( selection [, bReplaceCurrentSelection ] ) Parameters selection An array of screen names to be selected in the screen outline. bReplaceCurrentSelection A Boolean value that, if true, lets you deselect the current selection. The default value is true. If false, Flash extends the current selection to include the specified screens. This parameter is optional. Returns Nothing.
CHAPTER 35 Objects Shape object Inheritance Element object > Shape object Availability Flash MX 2004. Description The Shape object is a subclass of the Element object. The Shape object provides more precise control than the Drawing APIs when manipulating or creating geometry on the Stage. This control is necessary so that scripts can create useful effects and other drawing commands. (See Element object.
shape.beginEdit() Availability Flash MX 2004. Usage shape.beginEdit() Parameters None. Returns Nothing. Description Method; defines the start of an edit session. You must use this method before issuing any commands that change the Shape object or any of its subordinate parts. Example The following example takes the currently selected shape and removes the first edge in the edge array from it: var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit(); shape.deleteEdge(0); shape.endEdit(); shape.
Example The following example stores the first contour in the contours array in the c variable and then stores the HalfEdge object of that contour in the he variable: var c = fl.getDocumentDOM().selection[0].contours[0]; var he = c.getHalfEdge(); shape.deleteEdge() Availability Flash MX 2004. Usage shape.deleteEdge( index ) Parameters A zero-based index that specifies the edge to delete from the shape.edges array. This method changes the length of the shape.edges array. index Returns Nothing.
Description Read-only property; an array of Edge objects (see Edge object). shape.endEdit() Availability Flash MX 2004. Usage shape.endEdit() Parameters None. Returns Nothing. Description Method; defines the end of an edit session for the shape. All changes made to the Shape object or any of its subordinate parts will be applied to the shape. You must use this method after issuing any commands that change the Shape object or any of its subordinate parts.
Example The following example stores the first selected item object in the sel variable and then uses the element.elementType and shape.isDrawingObject properties to determine if the selected item is a drawing object. var sel = fl.getDocumentDOM().selection[0]; var shapeDrawingObject = (sel.elementType == "shape") && sel.isDrawingObject; fl.trace(shapeDrawingObject); See also document.crop(), document.deleteEnvelope(), document.intersect(), document.punch(), document.union(), shape.isGroup shape.
shape.vertices Availability Flash MX 2004. Usage shape.vertices Description Read-only property; an array of Vertex objects (see Vertex object). Example The following example stores the first selected item object in the someShape variable and then shows the number of vertices for that object in the Output panel: var someShape = fl.getDocumentDOM().selection[0]; fl.trace("The shape has " + someShape.vertices.length + " vertices.
CHAPTER 36 Objects SoundItem object Inheritance Item object > SoundItem object Availability Flash MX 2004. Description The SoundItem object is a subclass of the Item object. It represents a library item used to create a sound. See also frame.soundLibraryItem and Item object. Property summary for the SoundItem object In addition to the Item object properties, the following properties are available for the SoundItem object: Property Description soundItem.
Description Property; a string that specifies the bit rate of a sound in the library. This property is available only for the MP3 compression type. Acceptable values are "8 kbps", "16 kbps", "20 kbps", "24 kbps", "32 kbps", "48 kbps", "56 kbps", "64 kbps", "80 kbps", "112 kbps", "128 kbps", and "160 kbps". Stereo sounds exported at 8 or 16 kbps are converted to mono. The property is undefined for other compression types. N OT E If you want to specify a value for this property, set soundItem.
soundItem.compressionType Availability Flash MX 2004. Usage soundItem.compressionType Description Property; a string that specifies that compression type for a sound in the library. Acceptable values are "Default", "ADPCM", "MP3", "Raw", and "Speech". NO T E If you want to specify a value for this property, set soundItem.useImportedMP3Quality to false. Example The following example changes an item in the library to compression type Raw: fl.getDocumentDOM().library.items[0].
Example The following example converts an item in the library to mono, only if the item has MP3 or Raw compression type: fl.getDocumentDOM().library.items[0].convertStereoToMono = true; See also soundItem.compressionType soundItem.quality Availability Flash MX 2004. Usage soundItem.quality Description Property; a string that specifies the playback quality of a sound in the library. This property is available only for MP3 compression type. Acceptable values are "Fast", "Medium", and "Best".
Description Property; a string that specifies the sample rate for the audio clip. This property is available only for ADPCM, Raw, and Speech compression types. Acceptable values are "5 kHz", "11 kHz", "22 kHz", and "44 kHz". NO T E If you want to specify a value for this property, set soundItem.useImportedMP3Quality to false. Example The following example sets the sample rate of an item in the library to 5 kHz, if the item has ADPCM, Raw, or Speech compression type: fl.getDocumentDOM().library.items[0].
CHAPTER 37 Objects Stroke object Availability Flash MX 2004. Description The Stroke object contains all the settings for a stroke, including the custom settings. This object represents the information contained in the Property inspector. Using the Stroke object together with the document.setCustomStroke() method, you can change the stroke settings for the Tools panel, the Property inspector, and the current selection.
Property Description stroke.jiggle A string that specifies the jiggle property of a hatched line. stroke.joinType A string that specifies the type of join for the stroke. stroke.length A string that specifies the length of a hatch line. stroke.miterLimit A float value that specifies the angle above which the tip of the miter will be truncated by a segment. stroke.pattern A string that specifies the pattern of a ragged line. stroke.rotate A string that specifies the rotation of a hatch line.
Example The following example sets the breakAtCorners property to true: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.breakAtCorners = true; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.capType Availability Flash 8. Usage stroke.capType Description Property; a string that specifies the type of cap for the stroke. Acceptable values are "none", "round", and "square". Example The following example sets the stroke cap type to "round": var myStroke = fl.getDocumentDOM().
Example The following example sets the stroke color: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.color = "#000000"; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.curve Availability Flash MX 2004. Usage stroke.curve Description Property; a string that specifies type of hatching for the stroke. This property can be set only if the stroke.style property is "hatched" (see stroke.style). Acceptable values are "straight", "slight curve", "medium curve", and "very curved".
Description Property; an integer that specifies the lengths of the solid parts of a dashed line. This property is available only if the stroke.style property is set to "dashed" (see stroke.style). Example The following example sets the dash1 and dash2 properties for a stroke style of dashed: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "dashed"; myStroke.dash1 = 1; myStroke.dash2 = 2; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.dash2 Availability Flash MX 2004.
Example The following example sets the density property to "sparse" for the stroke style of stipple: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "stipple"; myStroke.dotSpace= 3; myStroke.variation = "random sizes"; myStroke.density = "sparse"; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.dotSize Availability Flash MX 2004. Usage stroke.dotSize Description Property; a string that specifies the dot size of a stippled line.
Example The following example sets the dotSpace property to 3 for a stroke style of dotted: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "dotted"; myStroke.dotSpace= 3; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.hatchThickness Availability Flash MX 2004. Usage stroke.hatchThickness Description Property; a string that specifies the thickness of a hatch line. This property is available only if the stroke.style property is set to "hatched" (see stroke.style).
Description Property; a string that specifies the jiggle property of a hatched line. This property is available only if the stroke.style property is set to "hatched" (see stroke.style). Acceptable values are "none", "bounce", "loose", and "wild". Example The following example sets the jiggle property to "wild" for a stroke style of hatched: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.curve = "straight"; myStroke.space = "close"; myStroke.
Description Property; a string that specifies the length of a hatch line. This property is available only if the stroke.style property is set to "hatched" (see stroke.style). Acceptable values are "equal", "slight", "variation", "medium variation", and "random". Example The following example sets the length property to "slight" for a stroke style of hatched: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.curve = "straight"; myStroke.space = "close"; myStroke.
stroke.pattern Availability Flash MX 2004. Usage stroke.pattern Description Property; a string that specifies the pattern of a ragged line. This property is available only if the stroke.style property is set to "ragged" (see stroke.style). Acceptable values are "solid", "simple", "random", "dotted", "random dotted", "triple dotted", and "random triple dotted". Example The following example sets the pattern property to "random" for a stroke style of ragged: var myStroke = fl.getDocumentDOM().
Example The following example sets the rotate property to "free" for a style stroke of hatched: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.curve = "straight"; myStroke.space = "close"; myStroke.jiggle = "wild"; myStroke.rotate = "free"; myStroke.length = "slight"; myStroke.hatchThickness = "thin"; stroke.scaleType Availability Flash 8. Usage stroke.scaleType Description Property; a string that specifies the type of scale to be applied to the stroke.
var fill = fl.getDocumentDOM().getCustomFill(); fill.linearGradient = true; fill.colorArray = [ 00ff00, ff0000, fffff ]; var stroke = fl.getDocumentDOM().getCustomStroke(); stroke.shapeFill = fill; fl.getDocumentDOM().setCustomStroke(stroke); stroke.space Availability Flash MX 2004. Usage stroke.space Description Property; a string that specifies the spacing of a hatched line. This property is available only if the stroke.style property is set to "hatched" (see stroke.style).
Example The following example enables stroke hinting for the stroke: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.strokeHinting = true; fl.getDocumentDOM().setCustomStroke(myStroke); stroke.style Availability Flash MX 2004. Usage stroke.style Description Property; a string that describes the stroke style. Acceptable values are "noStroke", "solid", "dashed", "dotted", "ragged", "stipple", and "hatched".
Usage stroke.thickness Description Property; an integer that specifies the stroke size. Example The following example sets the thickness property of the stroke to a value of 2: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.thickness = 2; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.variation Availability Flash MX 2004. Usage stroke.variation Description Property; a string that specifies the variation of a stippled line. This property is available only if the stroke.
Description Property; a string that specifies the wave height of a ragged line. This property is available only if the stroke.style property is set to "ragged" (see stroke.style). Acceptable values are "flat", "wavy", "very wavy", and "wild". Example The following example sets the waveHeight property to "flat" for a stroke style of ragged: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "ragged"; myStroke.pattern = "random"; myStroke.waveHeight = "flat"; myStroke.
CHAPTER 38 Objects SymbolInstance object Inheritance Element object > Instance object > SymbolInstance object Availability Flash MX 2004. Description SymbolInstance is a subclass of the Instance object and represents a symbol in a frame (see Instance object). Property summary for the SymbolInstance object In addition to the Instance object properties, the SymbolInstance object has the following properties: Property Description symbolInstance.
Property Description symbolInstance.colorBluePercent An integer that is part of the color transformation for the instance; equivalent to using the Color > Advanced setting in the instance Property inspector (the percentage controls on the left of the dialog box). symbolInstance.colorGreenAmount An integer that is part of the color transformation for the instance; equivalent to using the Color > Advanced setting in the instance Property inspector. Allowable values are from -255 to 255. symbolInstance.
Property Description symbolInstance.silent A Boolean value that enables or disables the accessibility of the object; equivalent to the inverse logic of the Make Object Accessible setting in the Accessibility panel. symbolInstance.symbolType A string that specifies the type of symbol; equivalent to the value for Behavior in the Create New Symbol and Convert To Symbol dialog boxes. symbolInstance.tabIndex An integer that is equivalent to the Tab index field in the Accessibility panel. symbolInstance.
symbolInstance.actionScript Availability Flash MX 2004. Usage symbolInstance.actionScript Description Property; a string that specifies the actions assigned to the symbol. This applies only to movie clip and button instances. For a graphic symbol instance, the value returns undefined. Example The following example assigns an onClipEvent action to the first item in the first frame of the first layer in the timeline: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].
symbolInstance.buttonTracking Availability Flash MX 2004. Usage symbolInstance.buttonTracking Description Property; a string that, for button symbols only, sets the same property as the pop-up menu for Track as Button or Track as Menu Item in the Property inspector. For other types of symbols, this property is ignored. Acceptable values are "button" or "menu".
symbolInstance.colorAlphaAmount Availability Flash MX 2004. Usage symbolInstance.colorAlphaAmount Description Property; an integer that is part of the color transformation for the instance, specifying the Advanced Effect Alpha settings. This property is equivalent to using the Color > Advanced setting in the Property inspector and adjusting the controls on the right of the dialog box. This value either reduces or increases the tint and alpha values by a constant amount.
symbolInstance.colorBlueAmount Availability Flash MX 2004. Usage symbolInstance.colorBlueAmount Description Property; an integer that is part of the color transformation for the instance. This property is equivalent to using the Color > Advanced setting in the instance Property inspector. Allowable values are from -255 to 255. symbolInstance.colorBluePercent Availability Flash MX 2004. Usage symbolInstance.
Description Property; an integer that is part of the color transformation for the instance. This property is equivalent to using the Color > Advanced setting in the instance Property inspector. Allowable values are from -255 to 255. symbolInstance.colorGreenPercent Availability Flash MX 2004. Usage symbolInstance.colorGreenPercent Description Property; part of the color transformation for the instance.
Example The following example changes the colorMode property of the first element in the first frame of the first layer in the timeline to "alpha": fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].colorMode = "alpha"; symbolInstance.colorRedAmount Availability Flash MX 2004. Usage symbolInstance.colorRedAmount Description Property; an integer that is part of the color transformation for the instance.
symbolInstance.description Availability Flash MX 2004. Usage symbolInstance.description Description Property; a string that is equivalent to the Description field in the Accessibility panel. The description is read by the screen reader. This property is not available for graphic symbols. Example The following example stores the value for the Accessibility panel description of the object in the theDescription variable: var theDescription = fl.getDocumentDOM().selection[0].
Example The following example traces the name of the filter at index 0. If it is a Glow filter, its blurX property is set to 100 and the new value is written to the filters array. var filterName = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].filter s[0].name; fl.trace(filterName); var filterArray = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].filter s; if (filterName == 'glowFilter'){ filterArray[0].blurX = 100; } fl.getDocumentDOM().getTimeline().layers[0].
symbolInstance.forceSimple Availability Flash MX 2004. Usage symbolInstance.forceSimple Description Property; a Boolean value that enables and disables the accessibility of the object’s children. This property is equivalent to the inverse logic of the Make Child Objects Accessible setting in the Accessibility panel. For example, if forceSimple is true, it is the same as the Make Child Object Accessible option being unchecked.
Example The following example sets the first symbol in the first frame of the first layer in the timeline to Single Frame (display one specified frame of the graphic timeline), as long as that symbol is a graphic: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].loop = 'single frame'; symbolInstance.shortcut Availability Flash MX 2004. Usage symbolInstance.shortcut Description Property; a string that is equivalent to the shortcut key associated with the symbol.
Description Property; a Boolean value that enables or disables the accessibility of the object. This property is equivalent to the inverse logic of the Make Object Accessible setting in the Accessibility panel. For example, if silent is true, it is the same as the Make Object Accessible option being unchecked. If silent is false, it is the same as the Make Object Accessible option being checked. This property is not available for graphic objects.
symbolInstance.tabIndex Availability Flash MX 2004. Usage symbolInstance.tabIndex Description Property; an integer that is equivalent to the Tab index field in the Accessibility panel. Creates a tab order in which objects are accessed when the user presses the Tab key. This property is not available for graphic symbols. Example The following example sets the tabIndex property of the mySymbol object to 3 and displays that value in the Output panel: var mySymbol = fl.getDocumentDOM().
CHAPTER 39 Objects SymbolItem object Inheritance Item object > SymbolItem object Availability Flash MX 2004. Description The SymbolItem object is a subclass of the Item object. Method summary for the SymbolItem object In addition to the Item object methods, you can use the following methods with the SymbolItem object: Method Description symbolItem.convertToCompiledClip() Converts a symbol item in the library to a compiled movie clip. symbolItem.exportSWC() Exports the symbol item to a SWC file.
Property Description symbolItem.symbolType A string that specifies the type of symbol. symbolItem.timeline Read-only; a Timeline object. symbolItem.convertToCompiledClip() Availability Flash MX 2004. Usage symbolItem.convertToCompiledClip() Parameters None. Returns Nothing. Description Method; converts a symbol item in the library to a compiled movie clip. Example The following example converts an item in the library to a compiled movie clip: fl.getDocumentDOM().library.items[3].
Returns Nothing. Description Method; exports the symbol item to a SWC file. Example The following example exports an item in the library to the SWC file named my.swc in the tests folder: fl.getDocumentDOM().library.items[0].exportSWC("file:///c|/tests/my.swc"); symbolItem.exportSWF() Availability Flash MX 2004. Usage symbolItem.exportSWF( outputURI ) Parameters A string, expressed as a file:/// URI, that specifies the SWF file to which the method will export the symbol.
symbolItem.scalingGrid Availability Flash 8. Usage symbolItem.scalingGrid Description Property; a Boolean value that specifies whether 9-slice scaling is enabled for the item. Example The following example enables 9-slice scaling for an item in the library: fl.getDocumentDOM().library.items[0].scalingGrid = true; See also symbolItem.scalingGridRect symbolItem.scalingGridRect Availability Flash 8. Usage symbolItem.
symbolItem.sourceAutoUpdate Availability Flash MX 2004. Usage symbolItem.sourceAutoUpdate Description Property; a Boolean value that specifies whether the item is updated when the FLA file is published. The default value is false. Used for shared library symbols. Example The following example sets the sourceAutoUpdate property for a library item: fl.getDocumentDOM().library.items[0].sourceAutoUpdate = true; symbolItem.sourceFilePath Availability Flash MX 2004. Usage symbolItem.
symbolItem.sourceLibraryName Availability Flash MX 2004. Usage symbolItem.sourceLibraryName Description Property; a string that specifies the name of the item in the source file library. It is used for shared library symbols. Example The following example shows the value of the sourceLibraryName property in the Output panel: fl.trace(fl.getDocumentDOM().library.items[0].sourceLibraryName); symbolItem.symbolType Availability Flash MX 2004. Usage symbolItem.
symbolItem.timeline Availability Flash MX 2004. Usage symbolItem.timeline Description Read-only property; a Timeline object. Example The following example obtains and shows the number of layers that the selected movie clip in the library contains: var tl = fl.getDocumentDOM().library.getSelectedItems()[0].timeline; alert(tl.
CHAPTER 40 Objects Text object Inheritance Element object > Text object Availability Flash MX 2004. Description The Text object represents a single text item in a document. All properties of the text pertain to the entire text block. To set properties of a text run within the text field, see “Property summary for the TextRun object” on page 466. To change properties of a selection within a text field, you can use document.setElementTextAttr() and specify a range of text, or use the current selection.
Property summary for the Text object In addition to the Element object properties, the following properties are available for the Text object: Property Description text.accName A string that is equivalent to the Name field in the Accessibility panel. text.antiAliasSharpness A float value that specifies the anti-aliasing sharpness of the text. text.antiAliasThickness A float value that specifies the anti-aliasing thickness of the text. text.
Property Description text.selectionEnd A zero-based integer that specifies the offset of the end of a text subselection. text.selectionStart A zero-based integer that specifies the offset of the beginning of a text subselection. text.shortcut A string that is equivalent to the Shortcut field in the Accessibility panel. text.silent A Boolean value that specifies whether the object is accessible. text.tabIndex An integer that is equivalent to the Tab Index field in the Accessibility panel. text.
text.antiAliasThickness Availability Flash 8. Usage text.antiAliasThickness Description Property; a float value that specifies the anti-aliasing thickness of the text. This property controls how thickly the text is drawn, with higher values specifying thicker text. A value of 0 specifies normal thickness. This property is available only if text.fontRenderingMode is set to "customThicknessSharpness". Example See text.fontRenderingMode. See also text.antiAliasSharpness, text.fontRenderingMode text.
text.autoExpand Availability Flash MX 2004. Usage text.autoExpand Description Property; a Boolean value. For static text fields, a value of true causes the bounding width to expand to show all text. For dynamic or input text fields, a value of true causes the bounding width and height to expand to show all text. Example The following example sets the autoExpand property to a value of true: fl.getDocumentDOM().selection[0].autoExpand = true; text.border Availability Flash MX 2004. Usage text.
Description Property; a string that is equivalent to the Description field in the Accessibility panel. The description is read by the screen reader. Example The following example retrieves the description of the object: var theDescription = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].descri ption; The following example sets the description of the object: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].descripti on= "Enter your name here"; text.
Description Property; a string that consists of delimited integers that correspond to the items that can be selected in the Character Options dialog box. This property works only with dynamic or input text; it is ignored if used with static text. NO T E This property corresponds to the XML file in the Configuration/Font Embedding folder. Example The following example sets the embedRanges property to "1|3|7": fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].
Property value How text is rendered advanced Renders text using the FlashType font rendering technology implemented in Flash 8, which produces better anti-aliasing and improves readability, especially for small text. customThicknessSharpness Lets you specify custom settings for the sharpness and thickness of the text when using the FlashType font rendering technology implemented in Flash 8.
Description Method; retrieves the attribute specified by the attrName parameter for the text identified by the optional startIndex and endIndex parameters. If the attribute is not consistent for the specified range, Flash returns undefined. If you omit the optional parameters startIndex and endIndex, the method uses the entire text range. If you specify only startIndex, the range used is a single character at that position.
Description Method; retrieves the specified range of text. If you omit the optional parameters startIndex and endIndex, the whole text string is returned. If you specify only startIndex, the method returns the string starting at the index location and ending at the end of the field. If you specify both startIndex and endIndex, the method returns the string starts from startIndex and goes up to, but does not include, endIndex.
Description Property; a string that sets the line type. Acceptable values are "single line", "multiline", "multiline no wrap", and "password". This property works only with dynamic or input text and generates a warning if used with static text. The "password" value works only for input text. Example The following example sets the lineType property to the value "multiline no wrap": fl.getDocumentDOM().selection[0].lineType = "multiline no wrap"; text.maxCharacters Availability Flash MX 2004. Usage text.
Description Property; a string that specifies the orientation of the text field. Acceptable values are "horizontal", "vertical left to right", and "vertical right to left". This property works only with static text; it generates a warning if used with other text types. Example The following example sets the orientation property to "vertical right to left": fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].orientati on = "vertical right to left"; text.
Description Property; a Boolean value. If the value is true, the text can be scrolled. This property works only with dynamic or input text; it generates a warning if used with static text. Example The following example sets the scrollable property to false: fl.getDocumentDOM().selection[0].scrollable = false; text.selectable Availability Flash MX 2004. Usage text.selectable Description Property; a Boolean value. If the value is true, the text can be selected. Input text is always selectable.
text.selectionStart Availability Flash MX 2004. Usage text.selectionStart Description Property; a zero-based integer that specifies the beginning of a text subselection. You can use this property with text.selectionEnd to select a range of characters. Characters up to, but not including, text.selectionEnd are selected. See text.selectionEnd. ■ If there is an insertion point or no selection, text.selectionEnd is equal to text.selectionStart. ■ If text.selectionStart is set to a value greater than text.
Parameters attrName A string that specifies the name of the TextAttrs object property to change. attrValue The value for the TextAttrs object property. N OT E For a list of possible values for attrName and attrValue, see “Property summary for the TextAttrs object” on page 456. startIndex An integer that is the index (zero-based) of the first character in the array. This parameter is optional.
text.setTextString() Availability Flash MX 2004. Usage text.setTextString(text [, startIndex [, endIndex]]) Parameters text A string that consists of the characters to be inserted into this text object. An integer that specifies the index (zero-based) of the character in the string where the text will be inserted. This parameter is optional. startIndex An integer that specifies the index of the end point in the selected text string.
text.shortcut Availability Flash MX 2004. Usage text.shortcut Description Property; a string that is equivalent to the Shortcut field in the Accessibility panel. The shortcut is read by the screen reader. This property cannot be used with dynamic text. Example The following example gets the shortcut key of the selected object and shows the value: var theShortcut = fl.getDocumentDOM().selection[0].shortcut; fl.trace(theShortcut); The following example sets the shortcut key of the selected object: fl.
Example The following example determines if the object is accessible (a value of false means that it is accessible): var isSilent = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].silent ; The following example sets the object to be accessible: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].silent = false; text.tabIndex Availability Flash MX 2004. Usage text.
Example The following example stores the value of the textRuns property in the myTextRuns variable: var myTextRuns = fl.getDocumentDOM().selection[0].textRuns; text.textType Availability Flash MX 2004. Usage text.textType Description Property; a string that specifies the type of text field. Acceptable values are "static", "dynamic", and "input". Example The following example sets the textType property to "input": fl.getDocumentDOM().selection[0].textType = "input"; text.
text.variableName Availability Flash MX 2004. Usage text.variableName Description Property; a string that contains the name of the variable associated with the text object. This property works only with dynamic or input text; it generates a warning if used with other text types.
CHAPTER 41 Objects TextAttrs object Availability Flash MX 2004. Description The TextAttrs object contains all the properties of text that can be applied to a subselection. This object is a property of the TextRun object (textRun.textAttrs). Property summary for the TextAttrs object The following properties are available for the TextAttrs object. Property Description textAttrs.
Property Description textAttrs.lineSpacing An integer that specifies the line spacing (leading) of the paragraph textAttrs.rightMargin An integer that specifies the paragraph’s right margin. textAttrs.rotation A Boolean value. A value of true causes Flash to rotate the characters of the text 90º. The default value is false. textAttrs.size An integer that specifies the size of the font. textAttrs.target A string that represents the target property of the text field. textAttrs.
Description Property; a string that specifies paragraph justification. Acceptable values are "left", "center", "right", and "justify". Example The following example sets the paragraphs that contain characters between index 0 up to, but not including, index 3 to justify. This can affect characters outside the specified range if they are in the same paragraph. fl.getDocumentDOM().setTextSelection(0, 3); fl.getDocumentDOM().setElementTextAttr('alignment', 'justify'); textAttrs.
Description Property; a Boolean value. A value of true causes text to appear with the bold version of the font. Example The following example selects the first character of the selected text object and sets the bold property to true: fl.getDocumentDOM().setTextSelection(0, 1); fl.getDocumentDOM().setElementTextAttr('bold', true); textAttrs.characterPosition Availability Flash MX 2004. Usage textAttrs.characterPosition Description Property; a string that determines the baseline for the text.
Description Property; an integer that represents the space between characters. Acceptable values are -60 through 60. This property applies only to static text; it generates a warning if used with other text types. Example The following example sets the character spacing of the selected text field to 10: fl.getDocumentDOM().setElementTextAttr("characterSpacing", 10); textAttrs.face Availability Flash MX 2004. Usage textAttrs.
Example The following example sets the color of the selected text field from the character at index 2 up to, but not including, the character at index 8 to red: fl.getDocumentDOM().selection[0].setTextAttr("fillColor", 0xff0000, 2, 8); textAttrs.indent Availability Flash MX 2004. Usage textAttrs.indent Description Property; an integer that specifies paragraph indentation. Acceptable values are -720 through 720.
textAttrs.leftMargin Availability Flash MX 2004. Usage textAttrs.leftMargin Description Property; an integer that specifies the paragraph’s left margin. Acceptable values are 0 through 720. Example The following example sets the leftMargin property of the selected text field from the character at index 2 up to, but not including, the character at index 8 to 100. This can affect characters outside the specified range if they are in the same paragraph. fl.getDocumentDOM().selection[0].
textAttrs.lineSpacing Availability Flash MX 2004. Usage textAttrs.lineSpacing Description Property; an integer that specifies the line spacing (leading) of the paragraph. Acceptable values are -360 through 720. Example The following example sets the selected text field’s lineSpacing property to 100: fl.getDocumentDOM().selection[0].setTextAttr("lineSpacing", 100); textAttrs.rightMargin Availability Flash MX 2004. Usage textAttrs.
textAttrs.rotation Availability Flash MX 2004. Usage textAttrs.rotation Description Property; a Boolean value. A value of true causes Flash to rotate the characters of the text 90º. The default value is false. This property applies only to static text with a vertical orientation; it generates a warning if used with other text types. Example The following example sets the rotation of the selected text field to true: fl.getDocumentDOM().setElementTextAttr("rotation", true); textAttrs.
textAttrs.target Availability Flash MX 2004. Usage textAttrs.target Description Property; a string that represents the target property of the text field. This property works only with static text. Example The following example gets the target property of the text field in the first frame of the top layer of the current scene and shows it in the Output panel: fl.outputPanel.trace(fl.getDocumentDOM().getTimeline().layers[0].frames[0]. elements[0].getTextAttr("target")); textAttrs.
CHAPTER 42 Objects TextRun object Availability Flash MX 2004. Description The TextRun object represents a run of characters that have attributes that match all of the properties in the TextAttrs object. This object is a property of the Text object (text.textRuns). Property summary for the TextRun object In addition to the properties available for use with the Text object, the TextRun object provides the following properties. Property Description textRun.
textRun.textAttrs Availability Flash MX 2004. Usage textRun.textAttrs Description Property; the TextAttrs object containing the attributes of the run of text. Example The following example displays the properties of the first run of characters in the selected text field in the Output panel. var curTextAttrs = fl.getDocumentDOM().selection[0].textRuns[0].textAttrs; for (var prop in curTextAttrs) { fl.
CHAPTER 43 Objects Timeline object Availability Flash MX 2004. Description The Timeline object represents the Flash timeline, which can be accessed for the current document by using fl.getDocumentDOM().getTimeline(). This method returns the timeline of the current scene or symbol that is being edited. When you work with scenes, each scene’s timeline has an index value, and can be accessed for the current document by fl.getDocumentDOM().timelines[i].
Method Description timeline.createMotionTween() Sets the frame.tweenType property to motion for each selected keyframe on the current layer, and converts each frame’s contents to a single symbol instance if necessary. timeline.cutFrames() Cuts a range of frames on the current layer from the timeline and saves them to the Clipboard. timeline.deleteLayer() Deletes a layer. timeline.expandFolder() Expands or collapses the specified folder or folders. timeline.
Method Description timeline.setSelectedFrames() Selects a range of frames in the current layer or sets the selected frames to the selection array passed into this method. timeline.setSelectedLayers() Sets the layer to be selected; also makes the specified layer the current layer. timeline.showLayerMasking() Shows the layer masking during authoring by locking the mask and masked layers. Property summary for the Timeline object The following methods are available for the Timeline object.
Returns An integer that represents the zero-based index of the newly added guide layer. If the current layer type is not of type “Normal”, Flash returns -1. Description Method; adds a motion guide layer above the current layer and attaches the current layer to the newly added guide layer, converting the current layer to a layer of type “Guided”. This method functions only on a layer of type “Normal”. It has no effect on a layer whose type is “Folder”, “Mask”, “Masked”, “Guide”, or “Guided”.
Example The following example adds a new layer to the timeline with a default name generated by Flash: fl.getDocumentDOM().getTimeline().addNewLayer(); The following example adds a new folder layer on top of the current layer and names it "Folder1": fl.getDocumentDOM().getTimeline().addNewLayer("Folder1", "folder", true); timeline.clearFrames() Availability Flash MX 2004. Usage timeline.
timeline.clearKeyframes() Availability Flash MX 2004. Usage timeline.clearKeyframes([startFrameIndex [, endFrameIndex]]) Parameters startFrameIndex A zero-based index that defines the beginning of the range of frames to clear. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. A zero-based index that defines the end of the range of frames to clear. The range goes up to, but does not include, endFrameIndex.
Parameters startFrameIndex A zero-based index that specifies the starting frame to convert to keyframes. If you omit startFrameIndex, the method converts the currently selected frames. This parameter is optional. A zero-based index that specifies the frame at which the conversion to keyframes will stop. The range of frames to convert goes up to, but does not include, endFrameIndex. If you specify only startFrameIndex, endFrameIndex defaults to the value of startFrameIndex. This parameter is optional.
Returns Nothing. Description Method; converts a range of frames to keyframes (or converts the selection if no frames are specified) on the current layer. Example The following example converts the selected frames to keyframes: fl.getDocumentDOM().getTimeline().convertToKeyframes(); The following example converts to keyframes the frames from Frame 2 up to, but not including, Frame 10 (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().
Description Method; copies a range of frames on the current layer to the Clipboard. Example The following example copies the selected frames to the Clipboard: fl.getDocumentDOM().getTimeline().copyFrames(); The following example copies Frame 2 up to, but not including, Frame 10, to the Clipboard (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().copyFrames(1, 9); The following example copies Frame 5 to the Clipboard: fl.getDocumentDOM().getTimeline().
Example The following example converts the shape in the first frame up to, but not including, Frame 10 to a graphic symbol instance and sets the frame.tweenType to motion (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().createMotionTween(0, 9); timeline.currentFrame Availability Flash MX 2004. Usage timeline.currentFrame Description Property; the zero-based index for the frame at the current playhead location.
Example The following example makes the top layer active: fl.getDocumentDOM().getTimeline().currentLayer = 0; The following example stores the index of the currently active layer in the curLayer variable: var curLayer = fl.getDocumentDOM().getTimeline().currentLayer; timeline.cutFrames() Availability Flash MX 2004. Usage timeline.cutFrames([startFrameIndex [, endFrameIndex]]) Parameters startFrameIndex A zero-based index that specifies the beginning of a range of frames to cut.
Example The following example cuts the selected frames from the timeline and saves them to the Clipboard: fl.getDocumentDOM().getTimeline().cutFrames(); The following example cuts Frame 2 up to, but not including, Frame 10 from the timeline and saves them to the Clipboard (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().cutFrames(1, 9); The following example cuts Frame 5 from the timeline and saves it to the Clipboard: fl.getDocumentDOM().
timeline.expandFolder() Availability Flash MX 2004. Usage timeline.expandFolder(bExpand [, bRecurseNestedParents [, index]]) Parameters A Boolean value that, if set to true, causes the method to expand the folder; causes the method to collapse the folder. bExpand false A Boolean value that, if set to true, causes all the layers within the specified folder to be opened or closed, based on the bExpand parameter. This parameter is optional.
timeline.findLayerIndex() Availability Flash MX 2004. Usage timeline.findLayerIndex(name) Parameters name A string that specifies the name of the layer to find. Returns An array of index values for the specified layer. If the specified layer is not found, Flash returns undefined. Description Method; finds an array of indexes for the layers with the given name. The layer index is flat, so folders are considered part of the main index.
Description Read-only property; an integer that represents the number of frames in this timeline’s longest layer. Example The following example uses a countNum variable to store the number of frames in the current document’s longest layer: var countNum = fl.getDocumentDOM().getTimeline().frameCount; timeline.getFrameProperty() Availability Flash MX 2004. Usage timeline.
Example The following example retrieves the name of the first frame in the current document’s top layer and displays the name in the Output panel: fl.getDocumentDOM().getTimeline().currentLayer = 0; fl.getDocumentDOM().getTimeline().setSelectedFrames(0, 0, true); var frameName = fl.getDocumentDOM().getTimeline().getFrameProperty("name"); fl.trace(frameName); timeline.getLayerProperty() Availability Flash MX 2004. Usage timeline.
Returns An array containing 3n integers, where n is the number of selected regions. The first integer in each group is the layer index, the second integer is the start frame of the beginning of the selection, and the third integer specifies the ending frame of that selection range. The ending frame is not included in the selection. Description Method; retrieves the currently selected frames in an array.
See also timeline.setSelectedLayers() timeline.insertBlankKeyframe() Availability Flash MX 2004. Usage timeline.insertBlankKeyframe([frameNumIndex]) Parameters A zero-based index that specifies the frame at which to insert the keyframe. If you omit frameNumIndex, the method uses the current playhead frame number. This parameter is optional. frameNumIndex If the specified or selected frame is a regular frame, the keyframe is inserted at the frame.
timeline.insertFrames() Availability Flash MX 2004. Usage timeline.insertFrames([numFrames [, bAllLayers [, frameNumIndex]]]) Parameters An integer that specifies the number of frames to insert. If you omit this parameter, the method inserts frames at the current selection in the current layer. This parameter is optional.
If the specified or selected frame is a regular frame, the frame is inserted at that frame. For example, if you have a span of 10 frames numbered 1-10 and you select Frame 5 (or pass a value of 4 for frameIndex), this method adds a frame at Frame 5, and the length of the frame span becomes 11 frames. If Frame 5 is selected and it is a keyframe, this method inserts a frame at Frame 6 regardless of whether the frame next to it is also a keyframe.
Description Method; inserts a keyframe at the specified frame. If you omit the parameter, the method inserts a keyframe using the playhead or selection location. This method works the same as timeline.insertBlankKeyframe() except that the inserted keyframe contains the contents of the frame it converted (that is, it’s not blank). Example The following example inserts a keyframe at the playhead or selected location: fl.getDocumentDOM().getTimeline().
Description Read-only property; an array of layer objects. Example The following example uses the currentLayers variable to store the array of layer objects in the current document: var currentLayers = fl.getDocumentDOM().getTimeline().layers; timeline.name Availability Flash MX 2004. Usage timeline.name Description Property; a string that specifies the name of the current timeline. This name is the name of the current scene, screen (slide or form), or symbol that is being edited.
Parameters startFrameIndex A zero-based index that specifies the beginning of a range of frames to paste. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. endFrameIndex A zero-based index that specifies the frame at which to stop pasting frames. The method pastes up to, but not including, endFrameIndex. If you specify only startFrameIndex, endFrameIndex defaults to the startFrameIndex value. This parameter is optional. Returns Nothing.
Parameters startFrameIndex A zero-based index that specifies the first frame at which to start removing frames. If you omit startFrameIndex, the method uses the current selection; if there is no selection, all frames at the current playhead on all layers are removed. This parameter is optional. A zero-based index that specifies the frame at which to stop removing frames; the range of frames goes up to, but does not include, endFrameIndex.
Parameters layerToMove A zero-based index that specifies which layer to move. layerToPutItBy A zero-based index that specifies which layer you want to move the layer next to. For example, if you specify 1 for layerToMove and 0 for layerToPutItBy, the second layer is placed next to the first layer. bAddBefore Specifies whether to move the layer before or after layerToPutItBy. If you specify false, the layer is moved after layerToPutItBy. The default value is true. This parameter is optional.
Returns Nothing. Description Method; reverses a range of frames. Example The following example reverses the positions of the currently selected frames: fl.getDocumentDOM().getTimeline().reverseFrames(); The following example reverses frames from Frame 10 up to, but not including, Frame 15 (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().reverseFrames(9, 14); timeline.selectAllFrames() Availability Flash MX 2004. Usage timeline.
timeline.setFrameProperty() Availability Flash MX 2004. Usage timeline.setFrameProperty(property, value [, startFrameIndex [, endFrameIndex]]) Parameters A string that specifies the name of the property to be modified. For a complete list of properties and values, see “Property summary for the Frame object” on page 273. property NO TE You can’t use this method to set values for read-only properties such as frame.duration and frame.elements. Specifies the value to which you want to set the property.
Example The following example assigns the ActionScript stop() command to the first frame of the top layer in the current document: fl.getDocumentDOM().getTimeline().currentLayer = 0; fl.getDocumentDOM().getTimeline().setSelectedFrames(0,0,true); fl.getDocumentDOM().getTimeline().setFrameProperty("actionScript", "stop();"); The following example sets a motion tween from Frame 2 up to, but not including, Frame 5, of the current layer (remember that index values are different from frame number values): fl.
Example The following example makes the selected layer(s) invisible: fl.getDocumentDOM().getTimeline().setLayerProperty("visible", false); The following example sets the name of the selected layer(s) to "selLayer": fl.getDocumentDOM().getTimeline().setLayerProperty("name", "selLayer"); timeline.setSelectedFrames() Availability Flash MX 2004. Usage timeline.setSelectedFrames(startFrameIndex, endFrameIndex [, bReplaceCurrentSelection]) timeline.
The following example first stores the array of selected frames in the savedSelectionList variable, and then uses the array later in the code to reselect those frames after a command or user interaction has changed the selection: var savedSelectionList = fl.getDocumentDOM().getTimeline().getSelectedFrames(); // Do something that changes the selection. fl.getDocumentDOM().getTimeline().
Example The following example selects the top layer: fl.getDocumentDOM().getTimeline().setSelectedLayers(0); The following example adds the next layer to the selection: fl.getDocumentDOM().getTimeline().setSelectedLayers(1, false); See also timeline.getSelectedLayers() timeline.showLayerMasking() Availability Flash MX 2004. Usage timeline.showLayerMasking([layer]) Parameters A zero-based index of a mask or masked layer to show masking during authoring. This parameter is optional.
CHAPTER 44 Objects ToolObj object Availability Flash MX 2004. Description A ToolObj object represents an individual tool in the Tools panel. To access a ToolObj object, use properties of the Tools object: either the tools.toolObjs array or tools.activeTool. Method summary for the ToolObj object The following methods are available for the ToolObj object. NO T E The following methods are used only when creating extensible tools. Method Description toolObj.
Property summary for the ToolObj object The following property is available for the ToolObj object: Property Description toolObj.depth An integer that specifies the depth of the tool in the pop-up menu in the Tools panel. toolObj.iconID An integer that specifies the resource ID of the tool. toolObj.position Read-only; an integer specifying the position of the tool in the Tools panel. toolObj.depth Availability Flash MX 2004. Usage toolObj.
Parameters control A string that specifies the name of the control to enable or disable. Legal values depend on the Property inspector invoked by this tool (see toolObj.setPI()).
toolObj.iconID Availability Flash MX 2004. Usage toolObj.iconID Description Read-only property; an integer with a value of -1. This property is used only when you create extensible tools. An iconID value of -1 means that Flash will not try find an icon for the tool. Instead, the script for the tool should specify the icon to display in the Tools panel; see toolObj.setIcon().
toolObj.setIcon() Availability Flash MX 2004. Usage toolObj.setIcon( file ) Parameters A string that specifies the name of the PNG file to use as the icon. The PNG file must be placed in the same folder as the JSFL file. file Returns Nothing. Description Method; identifies a PNG file to use as a tool icon in the Tools panel. This method is used only when you create extensible tools. Example The following example specifies that the image in the PolyStar.
Description Method; sets the string that appears in the pop-up menu as the name for the tool. This method is used only when you create extensible tools. Example The following example specifies that the tool named theTool should display the name “PolyStar Tool” in its pop-up menu. This code is taken from the sample PolyStar.jsfl file (see “Sample PolyStar tool” on page 20): theTool = fl.tools.activeTool; theTool.setMenuString("PolyStar Tool"); toolObj.setOptionsFile() Availability Flash MX 2004.
For example, the PolyStar.xml file specifies three options associated with the Polygon tool: Example The following example specifies that the file named PolyStar.
Description Method; specifies which Property inspector should be used when the tool is activated. This method is used only when you create extensible tools. Acceptable values are "shape" (the default), "text", and "movie". Example The following example specifies that the shape Property inspector should be used when the tool is activated. This code is taken from the sample PolyStar.jsfl file (see “Sample PolyStar tool” on page 20): theTool = fl.tools.activeTool; theTool.setPI( "shape" ); toolObj.
toolObj.setToolTip() Availability Flash MX 2004. Usage toolObj.setToolTip( toolTip ) Parameters toolTip A string that specifies the tooltip to use for the tool. Returns Nothing. Description Method; sets the tooltip that appears when the mouse is held over the tool icon. This method is used only when you create extensible tools. Example The following example specifies that the tooltip for the tool should be “PolyStar Tool.” This code is taken from the sample PolyStar.
A text Property inspector has the following controls: type font pointsize color bold italic direction alignLeft alignCenter alignRight alignJustify spacing position autoKern small rotation format lineType selectable html border deviceFonts varEdit options link maxChars target The movie Property inspector has the following controls: size publish background framerate player profile bShow A Boolean value that determines whether to show or hide the specified control (true shows
toolObj.showTransformHandles() Availability Flash MX 2004. Usage toolObj.showTransformHandles( bShow ) Parameters A Boolean value that determines whether to show or hide the free transform handles for the current tool (true shows the handles; false hides them). bShow Returns Nothing. Description Method; called in the configureTool() method of an extensible tool’s JavaScript file to indicate that the free transform handles should appear when the tool is active.
CHAPTER 45 Objects Tools object Availability Flash MX 2004. Description The Tools object is accessible from the flash object (fl.tools). The tools.toolObjs property contains an array of ToolObj objects, and the tools.activeTool property returns the ToolObj object for the currently active tool. (See also “ToolObj object” on page 499 and “Extensible tools” on page 24.) N OT E The following methods and properties are used only when creating extensible tools.
Property Description tools.penDownLoc Read-only; a point that represents the position of the last mousedown event on the Stage. tools.penLoc Read-only; a point that represents the current location of the mouse. tools.shiftIsDown Read-only; a Boolean value that identifies if the Shift key is being pressed. tools.toolObjs Read-only; an array of ToolObj objects. tools.activeTool Availability Flash MX 2004. Usage tools.
Description Read-only property; a Boolean value that identifies if the Alt key is being pressed. The value is true if the Alt key is pressed, and false otherwise. Example The following example determines whether the Alt key is being pressed. var isAltDown = fl.tools.altIsDown; tools.constrainPoint() Availability Flash MX 2004. Usage tools.constrainPoint(pt1, pt2) Parameters pt1 and pt2 specify the starting-click point and the drag-to point. Returns A new adjusted or constrained point.
tools.ctlIsDown Availability Flash MX 2004. Usage tools.ctlIsDown Description Read-only property; a Boolean value that is true if the Control key is pressed; false otherwise. Example The following example determines whether the Control key is being pressed. var isCtrldown = fl.tools.ctrlIsDown; tools.getKeyDown() Availability Flash MX 2004. Usage tools.getKeyDown() Parameters None. Returns The integer value of the key. Description Method; returns the most recently pressed key.
tools.mouseIsDown Availability Flash MX 2004. Usage tools.mouseIsDown Description Read-only property; a Boolean value that is true if the left mouse button is currently down; false otherwise. Example The following example determines whether the left mouse button is pressed. var isMouseDown = fl.tools.mouseIsDown; tools.penDownLoc Availability Flash MX 2004. Usage tools.penDownLoc Description Read-only property; a point that represents the position of the last mouse-down event on the Stage.
tools.penLoc Availability Flash MX 2004. Usage tools.penLoc Description Read-only property; a point that represents the current location of the mouse pointer. The tools.penLoc property comprises two properties, x and y, corresponding to the x,y location of the mouse pointer. Example The following example determines the current location of the mouse. var tempPt = fl.tools.penLoc; See also tools.penDownLoc tools.setCursor() Availability Flash MX 2004. Usage tools.
Returns Nothing. Description Method; sets the pointer to a specified appearance. Example The following example sets the pointer to a black arrow. fl.tools.setCursor(1); tools.shiftIsDown Availability Flash MX 2004. Usage tools.shiftIsDown Description Read-only property; a Boolean value that is true if the Shift key is pressed; false otherwise. Example The following example determines whether the Shift key is being pressed. var isShiftDown = fl.tools.shiftIsDown; tools.
Returns A new point that may be adjusted or snapped to the nearest geometric object. Description Method; takes a point as input and returns a new point that may be adjusted or snapped to the nearest geometric object. If snapping is disabled in the View menu in the Flash user interface, the point returned is the original point. Example The following example returns a new point that may be snapped to the nearest geometric object. var theSnapPoint = fl.tools.snapPoint(pt1); tools.
CHAPTER 46 Objects Vertex object Availability Flash MX 2004. Description The Vertex object is the part of the shape data structure that holds the coordinate data. Method summary for the Vertex object You can use the following methods with the Vertex object. Method Description vertex.getHalfEdge() Gets a HalfEdge object that shares this vertex. vertex.setLocation() Sets the location of the vertex.
Description Method; gets a HalfEdge object that shares this vertex. Example The following example shows how to get other half edges that share the same vertex. var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge(0); var theVertex = hEdge.getVertex(); var someHEdge = theVertex.getHalfEdge(); // Not necessarily the same half edge var theSameVertex = someHEdge.getVertex(); fl.trace('the same vertex: ' + theSameVertex); vertex.setLocation() Availability Flash MX 2004.
vertex.x Availability Flash MX 2004. Usage vertex.x Description Read-only property; the x location of the vertex in pixels. Example The following example displays the location of the x and y values of the vertex in the Output panel. var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge(0); var vertex = hEdge.getVertex(); fl.trace('x location of vertex is: ' + vertex.x); fl.trace('y location of vertex is: ' + vertex.y); vertex.y Availability Flash MX 2004. Usage vertex.
CHAPTER 47 Objects XMLUI object Availability Flash MX 2004. Description Flash 8 supports custom dialog boxes written in a subset of the XML User Interface Language (XUL). An XML User Interface (XMLUI) dialog box can be used by several Flash features, such as commands and behaviors, to provide a user interface for features that you build using extensibility. The XMLUI object provides the ability to get and set properties of an XMLUI dialog box, and accept or cancel out of one.
Method Description xmlui.setControlItemElements() Sets the label, value pairs of the current item. xmlui.setEnabled() Enables or disables (dims) a control. xmlui.setVisible() Shows or hides a control. xmlui.accept() Availability Flash MX 2004. Usage xmlui.accept() Parameters None. Returns Nothing. Description Method; closes the current XMLUI dialog box with an accept state, which is equivalent to the user clicking the OK button. See also fl.xmlui, document.xmlPanel(), xmlui.cancel() xmlui.
Description Method; closes the current XMLUI dialog box with a cancel state, which is equivalent to the user clicking the Cancel button. See also fl.xmlui, document.xmlPanel(), xmlui.accept() xmlui.get() Availability Flash MX 2004. Usage xmlui.get( controlPropertyName ) Parameters A string that specifies the name of the XMLUI property whose value you want to retrieve. controlPropertyName Returns A string that represents the value of the specified property.
Parameters controlPropertyName A string that specifies the property whose control item element you want to retrieve. Returns An object that represents the current control item for the control specified by controlPropertyName. Description Method; returns the label and value of the line selected in a ListBox or ComboBox control for the control specified by controlPropertyName.
Example The following example returns a value that indicates whether the control with the ID attribute myListBox is enabled: var isEnabled = fl.xmlui.getEnabled("myListBox"); fl.trace(isEnabled); See also fl.xmlui, document.xmlPanel(), xmlui.setEnabled() xmlui.getVisible() Availability Flash 8. Usage xmlui.getVisible(controlID) Parameters controlID A string that specifies the ID attribute of the control whose visibility status you want to retrieve.
xmlui.set() Availability Flash MX 2004. Usage xmlui.set( controlPropertyName, value ) Parameters controlPropertyName A string that specifies the name of XMLUI property to modify. A string that specifies the value to which you want to set the XMLUI property. value Returns Nothing. Description Method; modifies the value of the specified property of the current XMLUI dialog box. Example The following example sets the value of a property named "URL" to "www.macromedia.com": fl.xmlui.set("URL", "www.
Returns Nothing. Description Method; sets the label and value of the currently selected line in the ListBox or ComboBox control specified by controlPropertyName. Example The following example sets the label and value for the current item of the control property named "PhoneNumber": var elem = new Object(); elem.label = "Fax"; elem.value = "707-555-5555"; fl.xmlui.setControlItemElement("PhoneNumber",elem); See also fl.xmlui, document.xmlPanel(), xmlui.getControlItemElement(), xmlui.set(), xmlui.
Example The following example sets the label and value of items in the the control with the ID attribute myControlID to the label, value pairs specified: var nameArray = new Array("January", "February", "March"); var monthArray = new Array(); for (i=0;i
xmlui.setVisible() Availability Flash 8. Usage xmlui.setVisible(controlID, visible) Parameters controlID visible A string that specifies the ID attribute of the control you want to show or hide. A Boolean value of true if you want to show the control; false if you want to hide it. Returns Nothing. Description Method; shows or hides a control. Example The following example hides the control with the ID attribute myControl: fl.xmlui.setVisible("myControl", false); See also xmlui.
CHAPTER 48 Objects VideoItem object Inheritance Item object > VideoItem object Availability Flash MX 2004. Description The VideoItem object is a subclass of the Item object. Property summary for the VideoItem object In addition to the Item object properties, you can use the following properties with the VideoItem object: Property Description videoItem.sourceFilePath Read-only; a string that specifies the path to the video item. videoItem.
Example The following example displays the name and source file path of any items in the library that are of type "video": for ( idx in fl.getDocumentDOM().library.items ) { if ( fl.getDocumentDOM().library.items[idx].itemType == "video" ) { var myItem = fl.getDocumentDOM().library.items[idx]; fl.trace( myItem.name + " source is " + myItem.sourceFilePath ); } } See also library.items videoItem.videoType Availability Flash 8. Usage videoItem.
Objects
3 CHAPTER 3 C-Level Extensibility The C-level extensibility mechanism lets you implement Macromedia 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 Macromedia Flash JavaScript API.
Integrating C functions The C-level extensibility mechanism lets you implement Flash extensibility files using a combination of JavaScript and C code. The process for implementing this capability is summarized in the following steps: 1. Define functions using the C or C++ language. 2. Bundle them in a DLL file (Windows) or a shared library (Macintosh). 3.
To get a copy of the mm_jsapi.h file, extract it from the sample ZIP or SIT file (see “Sample DLL implementation” on page 540), or copy the following code into a file that you name mm_jsapi.
(mmEnv.valueToString short *)0) ? (*(mmEnv.valueToString))(c, v, l) : (unsigned /* unsigned char *JS_ValueToBytes(JSContext *cx, jsval v, unsigned int *pLength) */ #define JS_ValueToBytes(c, v, l) \ (mmEnv.valueToBytes ? (*(mmEnv.valueToBytes))(c, v, l) : (unsigned char *)0) /* JSBool JS_ValueToInteger(JSContext *cx, jsval v, long *lp); */ #define JS_ValueToInteger(c, v, l) \ (mmEnv.valueToInteger ? (*(mmEnv.
(mmEnv.objectType ? (*(mmEnv.objectType))(o) : (unsigned short *)0) /* JSObject *JS_NewArrayObject(JSContext *cx, unsigned int length, jsval *v) */ #define JS_NewArrayObject(c, l, v) \ (mmEnv.newArrayObject ? (*(mmEnv.newArrayObject))(c, l, v) : (JSObject *)0) /* long JS_GetArrayLength(JSContext *cx, JSObject *obj) */ #define JS_GetArrayLength(c, o) \ (mmEnv.getArrayLength ? (*(mmEnv.
unsigned short *(*valueToString)(JSContext *cx, jsval v, unsigned int *pLength); unsigned char *(*valueToBytes)(JSContext *cx, jsval v, unsigned int *pLength); JSBool (*valueToInteger)(JSContext *cx, jsval v, long *lp); JSBool (*valueToDouble)(JSContext *cx, jsval v, double *dp); JSBool (*valueToBoolean)(JSContext *cx, jsval v, JSBool *bp); JSBool (*valueToObject)(JSContext *cx, jsval v, JSObject **op); JSBool (*stringToValue)(JSContext *cx, unsigned short *b, unsigned int sz, jsval *vp); JSBool (*bytesToVa
/* Definitions of global variables */ \ MM_Environment mmEnv; void MM_InitWrapper(MM_Environment *env, unsigned int envSize) \ \ \ \ { \ \ \ extern void MM_Init(); char **envPtr = (char **)env; \ char **mmPtr = (char **)(&mmEnv); \ char **envEnd = (char **)((char *)envPtr + envSize); \ char **mmEnd = (char **)((char *)mmPtr + sizeof(MM_Environment)); \ \ /* Copy fields from env to mmEnv, one pointer at a time */ \ while (mmPtr < mmEnd && envPtr < envEnd) \ *mmPtr++ = *envPtr++; \ \ /* If env doesn't
Sample DLL implementation A sample DLL implementation is located in ZIP and SIT files in the ExtendingFlash/ dllSampleComputeSum folder (see “Sample implementations” on page 19). To see how the process works without actually building the DLL, you can do the following: ■ Store the Sample.jsfl file in the Commands directory (see “Saving JSFL files” on page 7). ■ Store the Sample.dll file in the External Libraries directory (see “Integrating C functions” on page 534).
After writing this code, build the DLL file or shared library, and store it in the appropriate External Libraries directory (see “Integrating C functions” on page 534). Then create a JSFL file with the following code, and store it in the Commands directory (see “Saving JSFL files” on page 7). // JSFL file to run C function defined above. var a = 5; var b = 10; var sum = Sample.computeSum(a, b); fl.
typedef enum { JS_FALSE = 0, JS_TRUE = 1 } JSBool A simple data type that stores a Boolean value.
typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) Description Method; describes C-level implementations of JavaScript functions in the following situations: ■ The cx pointer is a pointer to an opaque JSContext structure, which must be passed to some of the functions in the JavaScript API. This variable holds the interpreter’s execution context. ■ The obj pointer is a pointer to the object in whose context the script executes.
Arguments unsigned short *name, JSNative call, unsigned int nargs ■ The name argument is the name of the function as it is exposed to JavaScript. ■ The call argument is a pointer to a C-level function. The function must return a JSBool, which indicates success or failure. ■ The nargs argument is the number of arguments that the function expects to receive. Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure.
JSBool JS_ValueToInteger() Usage JSBool JS_ValueToInteger(JSContext *cx, jsval v, long *lp); Description Method; extracts a function argument from a jsval structure, converts it to an integer (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, long *lp ■ The cx argument is the opaque JSContext pointer that passes to the JavaScript function. ■ The v argument is the jsval structure from which the integer is to be extracted.
JSBool JS_ValueToBoolean() Usage JSBool JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); Description Method; extracts a function argument from a jsval structure, converts it to a Boolean value (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, JSBool *bp ■ The cx argument is the opaque JSContext pointer that passes to the JavaScript function. ■ The v argument is the jsval structure from which the Boolean value is to be extracted.
JSBool JS_StringToValue() Usage JSBool JS_StringToValue(JSContext *cx, unsigned short *bytes, uint sz, jsval *vp); Description Method; stores a string return value in a jsval structure. It allocates a new JavaScript string object. Arguments JSContext *cx, unsigned short *bytes, size_t sz, jsval *vp ■ The cx argument is the opaque JSContext pointer that passes to the JavaScript function. ■ The bytes argument is the string to be stored in the jsval structure.
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSVal JS_BooleanToValue() Usage jsval JS_BooleanToValue(JSBool bv); Description Method; stores a Boolean return value in a jsval structure. Arguments JSBool bv ■ The bv argument is a Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. Returns A JSVal structure that contains the Boolean value that passes to the function as an argument.
JSVal JS_IntegerToValue() Usage jsval JS_IntegerToValue(long lv); Description Method; converts a long integer value to JSVal structure. Arguments lv ■ The lv argument is the long integer value that you want to convert to a jsval structure. Returns A JSVal structure that contains the integer that passed to the function as an argument. JSVal JS_ObjectToValue() Usage jsval JS_ObjectToValue(JSObject *obj); Description Method; stores an object return value in a JSVal.
unsigned short *JS_ObjectType() Usage unsigned short *JS_ObjectType(JSObject *obj); Description Method; given an object reference, returns the class name of the object. For example, if the object is a DOM object, the function returns "Document". If the object is a node in the document, the function returns "Element". For an array object, the function returns "Array". NO TE Do not modify the returned buffer pointer, or you might corrupt the data structures of the JavaScript interpreter.
Arguments JSContext *cx, unsigned int length, jsval *v ■ The cx argument is the opaque JSContext pointer that passes to the JavaScript function. ■ The length argument is the number of elements that the array can hold. ■ The v argument is an optional pointer to the jsvals to be stored in the array. If the return value is not null, v is an array that contains length elements.
JSBool JS_GetElement() Usage JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) Description Method; reads a single element of an array object. Arguments JSContext *cx, JSObject *obj, unsigned int index, jsval *v ■ The cx argument is the opaque JSContext pointer that passes to the JavaScript function. ■ The obj argument is a pointer to an array object. ■ The index argument is an integer index into the array.
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ExecuteScript() Usage JS_ExecuteScript (JSContext *cx, JSObject *obj, unsigned short *script, unsigned int sz, jsval *rval) Description Method; compiles and executes a JavaScript string. If the script generates a return value, it returns in *rval.
C-Level Extensibility