MACROMEDIA FLASH 8-EXTENDING FLASH Manual

Extending flash

Advertisement

Quick Links

Extending Flash

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA FLASH 8-EXTENDING FLASH

  • Page 1 Extending Flash...
  • Page 2 If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
  • Page 3: Table Of Contents

    Introduction ..........5 Overview of the Macromedia Flash JavaScript API ....5 What’s new in the JavaScript API .
  • Page 4 outputPanel object ......... . .334 Parameter object .
  • Page 5: Introduction

    This chapter contains the following sections: Overview of the Macromedia Flash JavaScript API ......5 What’s new in the JavaScript API .
  • Page 6 Flash JavaScript interpreter. Creating JSFL files You can use Macromedia Flash 8 or your preferred text editor to write and edit Flash JavaScript (JSFL) files. If you use Flash, these files have a .jsfl extension by default. You can also create a JSFL file by selecting commands in the History panel and then clicking the Save button in the History panel or selecting Save As Command from the options pop-up menu.
  • Page 7: Overview Of The Macromedia Flash Javascript Api

    Tools panel and you then edit the script, you must either remove and then add the tool to the Tools panel again, or else close and restart Flash for the revised tool to be available. Overview of the Macromedia Flash JavaScript API...
  • Page 8 Settings\user\Local Settings\Application Data\Macromedia\ Flash 8\language\Configuration\Commands Mac OS X: Macintosh HD/Users/userName/Library/Application Support/Macromedia/Flash 8/ language/Configuration/Commands For scripts that will appear as extensible tools in the Tools panel, save the JSFL file in the Tools folder in the following location:...
  • Page 9 To issue a command from an ActionScript script: Use the following syntax (you can concatenate several commands into one string): MMExecute(Javascript command string); You can also run a script from the command line. Overview of the Macromedia Flash JavaScript API...
  • Page 10: What's New In The Javascript Api

    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"...
  • Page 11 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()
  • Page 12 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.miterLimit stroke.strokeHinting stroke.scaleType stroke.shapeFill symbolInstance.blendMode symbolInstance.cacheAsBitmap symbolInstance.filters symbolItem.scalingGrid Introduction...
  • Page 13 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.setSelectionBounds() document.setSelectionRect() instance.instanceType outputPanel.save() fl.openProject() (no longer apply only to text.border text.useDeviceFonts...
  • Page 14: The Flash Document Object Model

    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.
  • Page 15 The Document object An important property of the top-level flash object is the property. (See fl.documents property.) The property contains an array of Document fl.documents fl.documents 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.
  • Page 16 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.
  • Page 17 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.
  • Page 18 Instance object (abstract class, subclass of Element object) BitmapInstance object (subclass of Instance object) CompiledClipInstance object (subclass of Instance object) ComponentInstance object (subclass of SymbolInstance object) Parameter object componentInstance.parameters SymbolInstance object (subclass of Instance object) Text object (subclass of Element object) TextRun object array)
  • Page 19: Sample Implementations

    Samples/ExtendingFlash within the folder in which you installed Flash. For example, if you installed Flash using the default setting, the samples are placed in the following location: In Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ExtendingFlash On the Macintosh: Macintosh HD/Applications/Macromedia/Flash 8/Samples and...
  • Page 20 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: Copy the filtersGetSet.jsfl file to the Configuration/Commands folder (see “Saving JSFL...
  • Page 21 To remove the earlier version of the PolyStar.jsfl file that was installed with Flash: Select Edit > Customize Tools Panel (Windows) or Flash > Customize Tools Panel (Macintosh). In the Customize Tools Panel dialog box, click the Rectangle tool on the left side of the dialog box.
  • Page 22 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 function to call JavaScript commands from an ActionScript script.
  • Page 23: Chapter 1: Top-Level Functions And Methods

    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 The following lists summarize the areas in the authoring environment that relate to each function or method.
  • Page 24 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;...
  • Page 25 Example The following example sets the value of when the extensible tool is tools.activeTool 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 A string that specifies the message you want to display in the Alert dialog box.
  • Page 26 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.
  • Page 27 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;...
  • Page 28 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).
  • Page 29 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.
  • Page 30 Description Function; called when the extensible tool is active and the user presses a key. The script should call to determine which key was pressed. tools.getKeyDown() Example The following example displays information about which key was pressed when the extensible tool is active and the user presses a key.
  • Page 31 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.
  • Page 32 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. Returns Nothing.
  • Page 33 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.
  • Page 34 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.
  • Page 35 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 property to query the current values tools.activeTool 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.
  • Page 36 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()
  • Page 37 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 to specify the pointer to use.
  • Page 38 Top-Level Functions and Methods...
  • Page 39: Chapter 2: Objects

    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.
  • Page 40 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.
  • Page 41 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.
  • Page 42: Bitmapinstance Object

    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...
  • Page 43 Parameters None. Returns An object that contains , and, if the bitmap has a color table, width height depth bits properties. The element is an array of bytes. The element is an array of color cTab bits cTab values of the form .
  • Page 44 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.
  • Page 45 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...
  • Page 46: Bitmapitem Object

    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).
  • Page 47 Example The following code sets the property of the first item in the library of the allowSmoothing 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 .
  • Page 48 Example The following code sets the property of the first item in the library of the current quality 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 ) or not ( ).
  • Page 49: Compiledclipinstance Object

    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.) Property summary for the CompiledClipInstance...
  • Page 50 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.
  • Page 51 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 property: description // Get the description of the current selection.
  • Page 52 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 property: shortcut...
  • Page 53 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 property: tabIndex...
  • Page 54: Componentinstance Object

    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.) Property summary for the ComponentInstance object...
  • Page 55: Componentspanel 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 (See flash object (fl).) fl.componentsPanel. Method summary for the componentsPanel object You can use the following methods with the componentsPanel object: Method Description...
  • Page 56 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...
  • Page 57: Contour Object

    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 Returns a...
  • Page 58 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();...
  • Page 59 contour.interior Availability Flash MX 2004. Usage contour.interior Description Read-only property; the value is if the contour encloses an area; otherwise. true false Example This example traverses all the contours in the selected shape and shows the value of the property for each contour in the Output panel: interior var elt = fl.getDocumentDOM().selection[0];...
  • Page 60 Example The following example traverses all the contours of the selected shape and shows the value of property of each contour in the Output panel: orientation var elt = fl.getDocumentDOM().selection[0]; elt.beginEdit(); var contourArray = elt.contours; var contourCount = 0; for (i=0; i<contourArray.length;...
  • Page 61: Document Object

    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 Stores specified data with a document.
  • Page 62 Method Description Indicates whether Edit Symbols menu and document.canEditSymbol() functionality is enabled. Determines whether you can use the document.canRevert() method document.revert() fl.revertDocument() successfully. Determines whether you can use the document.canTestMovie() method successfully. document.testMovie() Determines whether you can use the document.canTestScene() method successfully.
  • Page 63 Method Description Performs a distribute-to-layers operation on the document.distributeToLayers() current selection; equivalent to selecting Distribute to Layers. Checks the document for persistent data with the document.documentHasData() specified name. Duplicates the currently active profile and gives the document.duplicatePublishProfile() duplicate version focus. Makes a copy of the currently selected scene, document.duplicateScene() giving the new scene a unique name and making it...
  • Page 64 Method Description Gets a specified property of the selected document.getElementTextAttr() TextAttrs text objects. Returns an array that contains the list of filters document.getFilters() applied to the currently selected object(s). Returns a string containing the XML metadata document.getMetadata() associated with the document. Gets the bounding rectangle of the current document.getSelectionRect() selection.
  • Page 65 Method Description Uses top selected drawing object to punch through document.punch() all selected drawing objects underneath it. Removes all filters from the selected object(s).< document.removeAllFilters() Removes persistent data with the specified name document.removeDataFromDocument() that has been attached to the document. Removes persistent data with the specified name document.removeDataFromSelection() that has been attached to the selection.
  • Page 66 Method Description Sets the blend mode for the selected objects. document.setBlendMode() Sets the fill settings for the Tools panel, Property document.setCustomFill() inspector, and any selected shapes. Sets the stroke settings for the Tools panel, document.setCustomStroke() Property inspector, and any selected shapes. Sets the specified property on selected document.setElementProperty()
  • Page 67 Method Description Sets the text selection of the currently selected text document.setTextSelection() field to the values specified by the startIndex values. endIndex Inserts a string of text. document.setTextString() Moves the transformation point of the current document.setTransformationPoint() selection. Skews the selection by a specified amount. document.skewSelection() Smooths the curve of each selected fill outline or document.smoothSelection()
  • Page 68 Property summary for the Document object You can use the following properties with the Document object. Property Description A string that is equivalent to the Name field in the document.accName Accessibility panel. A Boolean value that is equivalent to the Auto document.autoLabel Label check box in the Accessibility panel.
  • Page 69 Property Description Read-only; an array of Timeline objects (see document.timelines Timeline object). Read-only; a Matrix object. document.viewMatrix An integer that specifies the width of the document document.width (Stage) in pixels. Specifies the zoom percent of the Stage at author document.zoomFactor time.
  • Page 70 Parameters A string that specifies the name of the data to add. name A string that defines the type of data to add. Acceptable values are type type , and "integer" "integerArray" "double" "doubleArray" "string" "byteArray" the value to add. Valid types depend on the parameter.
  • Page 71 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);...
  • Page 72 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 position item. It uses the center of a symbol or the upper-left corner of a bitmap or video. An Item object that specifies the item to add and the library from which to add it (see item Item...
  • Page 73 document.addNewLine() Availability Flash MX 2004. Usage document.addNewLine( startPoint endpoint ) Parameters A pair of floating-point numbers that specify the x and y coordinates where the startpoint line starts. A pair of floating-point numbers that specify the x and y coordinates where the endpoint line ends.
  • Page 74 Parameters A rectangle that specifies the bounds of the oval to be added. For boundingRectangle information on the format of , see boundingRectangle document.addNewRectangle() A Boolean value that, if set to , causes the method to create the shape bSuppressFill true without a fill.
  • Page 75 document.addNewPublishProfile() Availability Flash MX 2004. Usage document.addNewPublishProfile( [profileName ] ) Parameters The unique name of the new profile. If you do not specify a name, a default profileName 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.
  • Page 76 Parameters A rectangle that specifies the bounds within which the new rectangle boundingRectangle is added, in the format . The {left:value1,top:value2,right:value3,bottom:value4} values specify the location of the upper-left corner (e.g., left left:0,top:0 represents the upper-left of the Stage), and the values specify location of right bottom...
  • Page 77 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}, The following example adds a new rectangle with no rounding on the corners and without a fill;...
  • Page 78 Example The following example adds a new scene named after the current scene in the myScene current document. The variable will be when the new scene is created; success true 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".
  • Page 79 document.align() Availability Flash MX 2004. Usage document.align( alignmode [, bUseDocumentBounds ] ) Parameters A string that specifies how to align the selection. Acceptable values are alignmode "left" , and "right" "top" "bottom" "vertical center" "horizontal center" A Boolean value that, if set to , causes the method to align to bUseDocumentBounds true...
  • Page 80 Returns A Boolean value: can be used safely; otherwise. true document.screenOutline false Description Method; use before using the property. If this method returns the document.screenOutline value , you can safely access ; Flash displays an error if you true document.screenOutline access in a document without screens.
  • Page 81 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.
  • Page 82 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();...
  • Page 83 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 is allowed. fl.getDocumentDOM().enterEditMode() Example The following example displays in the Output panel the state of the Edit Symbols menu and functionality: fl.trace("fl.getDocumentDOM().canEditSymbol() returns: "...
  • Page 84 document.canTestMovie() Availability Flash MX 2004. Usage document.canTestMovie() Parameters None. Returns A Boolean value: if you can use the method successfully: true document.testMovie() otherwise. false Description Method; determines whether you can use the method successfully. document.testMovie() Example The following example tests whether can be used.
  • Page 85 Returns A Boolean value: if you can use the method successfully; true document.testScene() otherwise. false Description Method; determines whether you can use the method successfully. document.testScene() Example The following example first tests whether can be used fl.getDocumentDOM().testScene() successfully. If so, it calls the method. if(fl.getDocumentDOM().canTestScene()){ fl.getDocumentDOM().testScene();...
  • Page 86 If you then issue the command fl.getDocumentDOM().changeFilterOrder(0, 2), 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);...
  • Page 87 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();...
  • Page 88 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.close( [bPromptToSaveChanges] ) Parameters A Boolean value that, when set to causes the method to bPromptToSaveChanges true,...
  • Page 89 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.convertToSymbol( type name registrationPoint ) Parameters...
  • Page 90 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");...
  • Page 91 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();...
  • Page 92 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();...
  • Page 93 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;...
  • Page 94 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.
  • Page 95 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";...
  • Page 96 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.disableFilter( filterIndex ) Parameters An integer representing the zero-based index of the filter in the Filter list. filterIndex Returns Nothing.
  • Page 97 document.disableOtherFilters() Availability Flash 8. Usage document.disableOtherFilters( enabledFilterIndex ) Parameters An integer representing the zero-based index of the filter that should enabledFilterIndex 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.getDocumentDom().disableOtherFilters(1);...
  • Page 98 Parameters A string that specifies where to distribute the selected object. Acceptable distributemode values are "left edge" "horizontal center" "right edge" "top edge" "vertical , and center" "bottom edge" A Boolean value that, when set to , distributes the selected bUseDocumentBounds true objects using the bounds of the document.
  • Page 99 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.
  • Page 100 document.duplicatePublishProfile() Availability Flash MX 2004. Usage document.duplicatePublishProfile( [profileName ] ) Parameters A string that specifies the unique name of the duplicated profile. If you do profileName 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.
  • Page 101 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. Example The following example duplicates the current selection, which is similar to Alt-clicking and then dragging an item:...
  • Page 102 Description Method; makes the specified scene the currently selected scene for editing. Example Assuming that there are three scenes ( , and ) in the current document, Scene0 Scene1 Scene2 the following example makes the current scene and then deletes it: Scene2 fl.getDocumentDOM().editScene(2);...
  • Page 103 document.enableFilter() Availability Flash 8. Usage document.enableFilter( filterIndex ) Parameters An integer specifying the zero-based index of the filter in the Filters list to filterIndex 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);...
  • Page 104 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().enterEditMode('inPlace');...
  • Page 105 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 fileURI file. If is an empty string or is not specified, Flash displays the Export Movie dialog fileURI box.
  • Page 106 document.exportPublishProfile() Availability Flash MX 2004. Usage document.exportPublishProfile( fileURI ) Parameters A string, expressed as a file:/// URI, that specifies the path of the XML file to fileURI 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:...
  • Page 107 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().exportSWF("", true);...
  • Page 108 Example The following example sets the variable to the value of the areChildrenAccessible property; a value of means the children are accessible: forceSimple false var areChildrenAccessible = fl.getDocumentDOM().forceSimple; The following example sets the property to allow the children of the document forceSimple to be accessible: fl.getDocumentDOM().forceSimple = false;...
  • Page 109 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() , and methods on the document. document.match() document.space() Example The following example retrieves the value of the To Stage button in the Align panel. If the return value is , the To Stage button is active;...
  • Page 110 document.getCustomFill() Availability Flash MX 2004. Usage document.getCustomFill( [ objectToFill ] ) Parameters A string that specifies the location of the fill object. The following values objectToFill are valid: returns the fill object of the Tools panel and Property inspector. "toolbar" returns the fill object of the selection.
  • Page 111 document.getCustomStroke() Availability Flash MX 2004. Usage document.getCustomStroke( [locationOfStroke] ) Parameters A string that specifies the location of the stroke object. The following locationOfStroke values are valid: , if set, returns the stroke object of the Tools panel and Property inspector. "toolbar"...
  • Page 112 document.getDataFromDocument() Availability Flash MX 2004. Usage document.getDataFromDocument( name ) Parameters A string that specifies the name of the data to return. name 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.
  • Page 113 Returns The value of the specified property. Returns if the property is an indeterminate state, as null when multiple elements are selected with different property values. Returns if the undefined property is not a valid property of the selected element. Description Method;...
  • Page 114 Returns If one text field is selected, the property is returned if there is only one value used within the text. Returns if there are several values used inside the text field. If several text undefined 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 .
  • Page 115 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 document.setFilters() See also...
  • Page 116 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.
  • Page 117 Parameters An integer that is an index of first character to get. This parameter is optional. startIndex An integer that is an index of last character to get. This parameter is optional. endIndex Returns A string that contains the selected text. Description Method;...
  • Page 118 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;...
  • Page 119 Example The following example gets the transformation point for the current selection. The property gives the x coordinate of the transformation point. The transPoint.x property gives the y coordinate of the transformation point: transPoint.y var transPoint = fl.getDocumentDOM().getTransformationPoint(); See also document.setTransformationPoint() document.group() Availability...
  • Page 120 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 A string, expressed as a file:/// URI, that specifies the path of the file to import.
  • Page 121 document.importPublishProfile() Availability Flash MX 2004. Usage document.importPublishProfile( fileURI ) Parameters A string, expressed as a file:/// URI, that specifies the path of the XML file fileURI 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.
  • Page 122 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 to import a SWF file (as well as other types of files). document.importFile() Example The following example imports the...
  • Page 123 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 , the following example fl.documents[1] gets the library for a non-focused library or for a library you opened using File >...
  • Page 124 document.match() Availability Flash MX 2004. Usage document.match( bWidth, bHeight [, bUseDocumentBounds] ) Parameters A Boolean value that, when set to , causes the method to make the widths of bWidth true the selected items the same. A Boolean value that, when set to , causes the method to make the heights of bHeight true...
  • Page 125 document.mouseClick() Availability Flash MX 2004. Usage document.mouseClick( position bToggleSel bShiftSel ) Parameters A pair of floating-point values that specify the x and y coordinates of the click position in pixels. A Boolean value that specifies the state of the Shift key: for pressed;...
  • Page 126 Parameters A pair of floating-point values that specify the x and y coordinates of the click position in pixels. A Boolean value that records whether the Alt key is down at the time of the bAltdown event: for pressed; for not pressed. true false A Boolean value that records whether the Shift key was down when the event...
  • Page 127 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});...
  • Page 128 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 to the filename of the first document in the fileName documents array: var fileName = flash.documents[0].name;...
  • Page 129 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);...
  • Page 130 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;...
  • Page 131 Description Method; uses top selected drawing object to punch through all selected drawing objects underneath it. This method returns if there are no drawing objects selected, or if any of false the selected items are not drawing objects. Example The following example punches through drawing objects underneath the selected drawing object: fl.getDocumentDOM().punch();...
  • Page 132 document.removeDataFromSelection() Availability Flash MX 2004. Usage document.removeDataFromSelection( name ) Parameters A string that specifies the name of the persistent data to remove. name Returns Nothing. Description Method; removes persistent data with the specified name that has been attached to the selection.
  • Page 133 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 filterIndex selected object(s).
  • Page 134 document.renamePublishProfile() Availability Flash MX 2004. Usage document.renamePublishProfile( [profileNewName ] ) Parameters An optional parameter that specifies the new name for the profile. The profileNewName new name must be unique. If the name is not specified, a default name is provided. Returns A Boolean value: if the name is changed successfully;...
  • Page 135 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 )
  • Page 136 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();...
  • Page 137 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.
  • Page 138 document.save() Availability Flash MX 2004. Usage document.save( [ bOkToSaveAs ] ) Parameters An optional parameter that specifies whether to open the Save As dialog box. bOkToSaveAs Returns A Boolean value: if the save operation completes successfully; otherwise. true false Description Method;...
  • Page 139 Parameters An optional parameter that, if or omitted and the file was never saved, bOkToSaveAs true opens the Save As dialog box. If and the file was never saved, the file is not saved. The false default value is true Returns A Boolean value: if the save-and-compact operation completes successfully;...
  • Page 140 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);...
  • Page 141 See also ScreenOutline object document.allowScreens() 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();...
  • Page 142 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() , or document.mouseDblClk() 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...
  • Page 143 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 in the first frame to the current selection: myMovieClip...
  • Page 144 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 A Boolean value that, if set to , aligns objects to the Stage.
  • Page 145 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. Acceptable mode values are , "...
  • Page 146 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.
  • Page 147 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.
  • Page 148 Description Method; sets the specified property on selected object(s) in the document. This Element 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);...
  • Page 149 Example The following examples set the text attributes for the fillColor, italic, and bold 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.setFillColor( color ) Parameters...
  • Page 150 document.setFilterProperty() Availability Flash 8. Usage document.setFilterProperty( property, filterIndex, value ) Parameters A string specifying the property to be set. Acceptable values are property "blurX" "blurY" "quality" angle" "distance" "strength" "knockout" "inner" , and "bevelType" "color" "shadowColor" "highlightColor". An integer specifying the zero-based index of the filter in the Filters list. filterIndex A number or string specifying the value to be set for the specified filter property.
  • Page 151 document.setFilters() Availability Flash 8. Usage document.setFilters( filterArray ) Parameters The array of filters currently specified. filterArray Returns Nothing. Description Method; applies filters to the selected objects. Use this method after calling and making any desired changes to the filters. document.getFilters() Example The following example gets the filters on the selected object and sets the property for...
  • Page 152 Parameters An integer between 0 (transparent) and 100 (completely saturated) that adjusts the opacity 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);...
  • Page 153 document.setInstanceTint() Availability Flash MX 2004. Usage document.setInstanceTint( color strength ) Parameters The color of the tint, in one of the following formats: color A string in the format "#RRGGBB" "#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.
  • Page 154 Returns A Boolean value: if successful; otherwise. true false Description Method; sets the XML metadata for the specified document, overwriting any existing metadata. The XML passed as is validated and may be rewritten before being strMetadata stored. If it cannot be validated as legal XML or violates specific rules, then the XML metadata is not set and is returned.
  • Page 155 In the second example, metadata is in tags, but with different schemas all in one tag. This example also includes comments, which will be ignored and rdf:Description discarded by the Document.setMetadata() <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!-- This is before the first rdf:Description tag --> <rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/1.1/'>...
  • Page 156 Parameters A rectangle that specifies the new location and size of the selection. boundingRectangle For information on the format of , see boundingRectangle document.addNewRectangle() A Boolean value that specifies whether the Contact bContactSensitiveSelection Sensitive selection mode is enabled ( ) or disabled ( ) during object selection.
  • Page 157 A Boolean value that specifies whether the method replaces bReplaceCurrentSelection the current selection ( ) or adds to the current selection ( ). The default value is true false true A Boolean value that specifies whether the Contact bContactSensitiveSelection Sensitive selection mode is enabled ( ) or disabled ( ) during object selection.
  • Page 158 document.setStroke() Availability Flash MX 2004. Usage document.setStroke( color size strokeType ) Parameters The color of the stroke, in one of the following formats: color A string in the format "#RRGGBB" "#RRGGBBAA" A hexadecimal number in the format 0xRRGGBB An integer that represents the decimal equivalent of a hexadecimal number A floating-point value that specifies the new stroke size for the selection.
  • Page 159 Parameters The color of the stroke, in one of the following formats: color A string in the format "#RRGGBB" "#RRGGBBAA" A hexadecimal number in the format 0xRRGGBB An integer that represents the decimal equivalent of a hexadecimal number Returns Nothing. Description Method;...
  • Page 160 Description Method; changes the stroke size of the selection to the specified size. For information on changing the stroke in the Tools panel and Property inspector, see document.setCustomStroke() Example The following example changes the stroke size for the selection to 5: fl.getDocumentDOM().setStrokeSize(5);...
  • Page 161 document.setTextRectangle() Availability Flash MX 2004. Usage document.setTextRectangle( boundingRectangle ) Parameters A text rectangle object that specifies the new size within which the boundingRectangle text item should flow. For information on the format of , see boundingRectangle document.addNewRectangle() Returns A Boolean value: if the size of at least one text field is changed;...
  • Page 162 document.setTextSelection() Availability Flash MX 2004. Usage document.setTextSelection( startIndex, endIndex ) Parameters An integer that specifies the position of the first character to select. The first startIndex character position is 0 (zero). An integer that specifies the end position of the selection up to, but not endIndex including, .
  • Page 163 Returns A Boolean value: if the text of at least one text string is set; otherwise. true false Description Method; inserts a string of text. If the optional parameters are not passed, the existing text selection is replaced; if the text object isn’t currently being edited, the whole text string is replaced.
  • Page 164 Text: is set relative to the text field. 0,0 is the upper-eft corner of transformationPoint text field. Bitmaps/videos: is set relative to bitmap/video. 0,0 is the upper- transformationPoint left corner of the bitmap or video. Groups: is set relative to document. 0,0 is the same as the Stage transformationPoint (upper-left corner).
  • Page 165 Example The following example sets the variable to the value of the property: isSilent silent var isSilent = fl.getDocumentDOM().silent; The following example sets the property to , indicating that the document is silent false accessible: fl.getDocumentDOM().silent = false; document.skewSelection() Availability Flash MX 2004.
  • Page 166 document.smoothSelection() Availability Flash MX 2004. Usage document.smoothSelection() Parameters None. Returns Nothing. Description Method; smooths the curve of each selected fill outline or curved line. This method performs the same action as the Smooth button in the Tools panel. Example The following example smooths the curve of the current selection: fl.getDocumentDOM().smoothSelection();...
  • Page 167 Description Method; spaces the objects in the selection evenly. Example The following example spaces the objects horizontally, relative to the Stage: fl.getDocumentDOM().space("horizontal",true); The following example spaces the objects horizontally, relative to each other: fl.getDocumentDOM().space("horizontal"); The following example spaces the objects horizontally, relative to each other, with expressly set to bUseDcoumentBounds false...
  • Page 168 document.swapElement() Availability Flash MX 2004. Usage document.swapElement( name ) Parameters A string that specifies the name of the library item to use. name Returns Nothing. Description Method; swaps the current selection with the specified one. The selection must contain a graphic, button, movie clip, video, or bitmap.
  • Page 169 Example The following example swaps the Stroke and Fill colors in the current document: fl.getDocumentDOM().swapStrokeAndFill(); document.testMovie() Availability Flash MX 2004. Usage document.testMovie() Parameters None. Returns Nothing. Description Method; executes a Test Movie operation on the document. Example The following example tests the movie for the current document: fl.getDocumentDOM().testMovie();...
  • Page 170 Returns Nothing. Description Method; executes a Test Scene operation on the current scene of the document. Example The following example tests the current scene in the document: fl.getDocumentDOM().testScene(); See also document.canTestScene() document.testMovie() document.timelines Availability Flash MX 2004. Usage document.timelines Description Read-only property;...
  • Page 171 document.traceBitmap() Availability Flash MX 2004. Usage document.traceBitmap( threshold minimumArea curveFit cornerThreshold ) Parameters An integer that controls the number of colors in your traced bitmap. Acceptable threshold values are integers between 0 and 500. An integer that specifies the radius measured in pixels. Acceptable values are minimumArea integers between 1 and 1000.
  • Page 172 Parameters A floating-point number that specifies the (0,0) element of the transformation matrix. A floating-point number that specifies the (0,1) element of the transformation matrix. A floating-point number that specifies the (1,0) element of the transformation matrix. A floating-point number that specifies the (1,1) element of the transformation matrix. Returns Nothing.
  • Page 173 document.union() Availability Flash 8. Usage document.union() Parameters None. Returns A Boolean value: if successful; otherwise. true false Description Method; combines all selected shapes into a drawing object. Example The following example combines all selected shapes into a drawing object: fl.getDocumentDOM().union(); See also document.crop() document.deleteEnvelope()
  • Page 174 Description Method; unlocks all locked elements on the currently selected frame. Example The following example unlocks all locked objects in the current frame: fl.getDocumentDOM().unlockAllElements(); See also element.locked document.viewMatrix Availability Flash MX 2004. Usage document.viewMatrix Description Read-only property; a Matrix object. The is used to transform from object space viewMatrix to document space when the document is in edit mode.
  • Page 175 document.width Availability Flash MX 2004. Usage document.width Description Property; an integer that specifies the width of the document (Stage) in pixels. Example The following example sets the width of the Stage to 400 pixels. fl.getDocumentDOM().width= 400; See also document.height document.xmlPanel() Availability Flash MX 2004.
  • Page 176 Description Method; posts an XMLUI dialog box. See fl.xmlui Example The following example loads the Test.xml file and displays each property contained within it: var obj = fl.getDocumentDOM().xmlPanel(fl.configURI + "Commands/Test.xml"); for (var prop in obj) { fl.trace("property " + prop + " = " + obj[prop]); document.zoomFactor Availability Flash 8.
  • Page 177: Drawinglayer Object

    CHAPTER 10 Objects drawingLayer object Availability Flash MX 2004. Description The drawingLayer object is accessible from JavaScript as a child of the flash object. The drawingLayer object is used for extensible tools when the user wants to temporarily draw while dragging—for example, when creating a selection marquee. You should call before you call any other drawingLayer methods.
  • Page 178 drawingLayer.beginDraw() Availability Flash MX 2004. Usage drawingLayer.beginDraw([persistentDraw]) Parameters A Boolean value (optional). If set to , it indicates that the drawing in persistentDraw true the last frame remains on the Stage until a new call is made. beginDraw() beginFrame() (In this context, frame refers to where you start and end drawing; it does not refer to timeline frames.) For example, when users draw a rectangle, they can preview the outline of the shape while dragging the mouse.
  • Page 179 Description Method; erases what was previously drawn using the drawingLayer and prepares for more drawing commands. Should be called after . Everything drawn drawingLayer.beginDraw() between and an remains on the drawingLayer.beginFrame() drawingLayer.endFrame() Stage until you call the next . (In this context, frame refers to beginFrame() endFrame() where you start and end drawing;...
  • Page 180 drawingLayer.curveTo() Availability Flash MX 2004. Usage drawingLayer.curveTo(xCtl yCtl xEnd yEnd) Parameters A floating-point value that is the x position of the control point. xCtl A floating-point value that is the y position of the control point. yCtl A floating-point value that is the x position of the end control point. xEnd A floating-point value that is the y position of the end control point.
  • Page 181 Description Method; draws the path specified by the parameter. You typically use this method only path when creating extensible tools. Example The following example draws a path specified by the Path object named gamePath fl.drawingLayer.drawPath(gamePath); drawingLayer.endDraw() Availability Flash MX 2004. Usage drawingLayer.endDraw() Parameters...
  • Page 182 Parameters None. Returns Nothing. Description Method; signals the end of a group of drawing commands. A group of drawing commands refers to everything drawn between drawingLayer.beginFrame() . The next call to will erase drawingLayer.endFrame() drawingLayer.beginFrame() whatever was drawn in this group of drawing commands. You typically use this method only when creating extensible tools.
  • Page 183 drawingLayer.moveTo() Availability Flash MX 2004. Usage drawingLayer.moveTo(x, y) Parameters A floating-point value that specifies the x coordinate of the position at which to start drawing. A floating-point value that specifies the y coordinate of the position at which to start drawing.
  • Page 184 Description Method; returns a new Path object. You typically use this method only when creating extensible tools. See Path object. Example The following example returns a new Path object: fl.drawingLayer.newPath(); drawingLayer.setColor() Availability Flash MX 2004. Usage drawingLayer.setColor(color) Parameters The color of subsequently drawn data, in one of the following formats: color A string in the format "#RRGGBB"...
  • Page 185: Edge Object

    CHAPTER 11 Objects Edge object Availability Flash MX 2004. Description The Edge object represents an edge of a shape on the Stage. Method summary for the Edge object The following methods are available for the Edge object: Method Description Gets a point object set to the location of the specified control point edge.getControl() of the edge.
  • Page 186 Parameters An integer that specifies which control point of the edge to return. Specify 0 for the first control point, 1 for the middle control point, or 2 for the end control point. If the property is , the middle control point is set to the midpoint of the segment edge.isLine true joining the beginning and ending control points.
  • Page 187 Example The following example stores the half edges of the specified edge in the hEdge0 hEdge1 variables: var shape = fl.getDocumentDOM().selection[0]; var edge = shape.edges[0]; var hEdge0 = edge.getHalfEdge(0); var hEdge1 = edge.getHalfEdge(1); edge.id Availability Flash MX 2004. Usage edge.id Description Read-only property;...
  • Page 188 Example The following example determines whether the specified edge is a straight line, and shows a value of 1 (it is a straight line) or 0 (it isn’t a straight line) in the Output panel: var shape = fl.getDocumentDOM().selection[0]; fl.trace(shape.edges[0].isLine); edge.setControl() Availability Flash MX 2004.
  • Page 189 edge.splitEdge() Availability Flash MX 2004. Usage edge.splitEdge( t ) Parameters A floating-point value between 0 and 1 that specifies where to split the edge. A value of 0 represents one end point, and 1 the other. For example, passing a value of 0.5 splits the edge in the middle, which, for a line is exactly in the center.
  • Page 190: Effect Object

    CHAPTER 12 Objects Effect object Availability Flash MX 2004. Description This is a single effect descriptor object. The and the fl.activeEffect fl.effects properties contain this type of object. The Effect object represents an instance of a timeline effect. See fl.activeEffect fl.effects Property summary for the Effect object In addition to the properties listed in the following table, Effect objects can also have user-...
  • Page 191 Description Read-only property; a string that appears in the Context menu for effects. Each effect must be uniquely named. Example The following example stores the name of the current effect in the variable: efName var efName = fl.activeEffect.effectName; effect.groupName Availability Flash MX 2004.
  • Page 192 Example The following example stores the name of the JSFL effect source file in the efSourceFile variable: var efSourceFile = fl.activeEffect.sourceFile effect.symbolType Availability Flash MX 2004. Usage effect.symbolType Description Read-only property; a string that specifies the type of symbol to create during the initial application of the effect.
  • Page 193: Element Object

    CHAPTER 13 Objects Element object Availability Flash MX 2004. Description Everything that appears on the Stage is of the type Element. The following code example lets you select an element: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0]; Method summary for the Element object The following methods are available for the Element object: Method Description Retrieves the value of the data specified by the...
  • Page 194 Property Description A Boolean value: if the element is locked; element.locked true false otherwise. Matrix object. The has properties element.matrix matrix a, b, c, d, tx are floating-point values; ty. a, b, c, d coordinates. A string that specifies the name of the element, normally element.name referred to as the Instance name.
  • Page 195 element.elementType Availability Flash MX 2004. Usage element.elementType Description Read-only property; a string that represents the type of the specified element. The value is one of the following: , or is created "shape" "text" "instance" "shapeObj" "shapeObj" with an extensible tool. Example The following example stores the type of the first element in the variable:...
  • Page 196 Returns The data specified by the parameter, or 0 if the data doesn’t exist. name Description Method; retrieves the value of the data specified by the parameter. The type of data name depends on the type of the data that was stored (see ).
  • Page 197 Example element.getPersistentData() element.height Availability Flash MX 2004. Usage element.height Description Property; a float value that specifies the height of the element in pixels. Do not use this property to resize a text field. Instead, select the text field and use .
  • Page 198 element.left Availability Flash MX 2004. Usage element.left Description Read-only property; a float value that represents the left side of the element. The value of is relative to the upper left of the Stage for elements that are in a scene, and is element.left relative to the symbol’s registration point if the element is stored within a symbol.Use to set this property.
  • Page 199 element.matrix Availability Flash MX 2004. Usage element.matrix Description Property; a Matrix object. A matrix has properties , and . The , and properties are floating-point values; the properties are coordinates. See Matrix object. Example The following example moves the specified element by 10 pixels in x and 20 pixels in y: var mat = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].matrix mat.tx += 10;...
  • Page 200 Example The following example sets the Instance name of the first element in Frame 1, top layer to "clip_mc": fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].name = "clip_mc"; See the example. element.elementType element.removePersistentData() Availability Flash MX 2004. Usage element.removePersistentData( name ) Parameters A string that specifies the name of the data to remove. name Returns Nothing.
  • Page 201 Example The following example selects the element: element.selected = true; element.setPersistentData() Availability Flash MX 2004. Usage element.setPersistentData( name, type, value ) Parameters A string that specifies the name to associate with the data. This name is used to name retrieve the data. A string that defines the type of the data.
  • Page 202 Description Read-only property; top side of the element. The value of is relative to the element.top upper left of the Stage for elements that are in a scene, and is relative to the symbol’s registration point if the element is stored within a symbol. Use to set this property.
  • Page 203: Fill Object

    CHAPTER 14 Objects Fill object Availability Flash MX 2004. Description This object contains all the properties of the Fill color setting of the Tools panel or of a selected shape. To retrieve a Fill object, use document.getCustomFill() Property summary for the Fill object The following properties are available for the Fill object: Property Description...
  • Page 204 fill.color Availability Flash MX 2004. Usage fill.color Description Property; the color of the fill, in one of the following formats: A string in the format "#RRGGBB" "#RRGGBBAA" A hexadecimal number in the format 0xRRGGBB An integer that represents the decimal equivalent of a hexadecimal number Example The following example sets the fill color of the current selection: var fill = fl.getDocumentDOM().getCustomFill();...
  • Page 205 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.
  • Page 206 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 , and ;...
  • Page 207 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 property is fill.style either "radialGradient" "linearGradient" Example The following example specifies the colors to use in a linear gradient for the current selection: var fill = fl.getDocumentDOM().getCustomFill();...
  • Page 208: Filter Object

    CHAPTER 15 Objects Filter object Availability Flash 8. Description This object contains all the properties for all filters. The property specifies the filter.name 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 .
  • Page 209 Property Description A Boolean value that specifies whether the filter is a filter.knockout knockout filter ( ) or not ( true false A string that specifies the type of filter (read-only filter.name property). A string that specifies the blur quality. filter.quality A float value that specifies the saturation value of the filter.saturation...
  • Page 210 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"...
  • Page 211 Example 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 for the property.
  • Page 212 Description Property; the color of the filter, in one of the following formats: A string in the format "#RRGGBB" "#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"...
  • Page 213 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;...
  • Page 214 filter.hideObject Availability Flash 8. Usage filter.hideObject Description Property; a Boolean value that specifies whether the source image is hidden ( ) or true displayed ( ). This property is defined for Filter objects with a value of false for the property.
  • Page 215 Example The following example sets the highlight color to for the Bevel filters on the "#ff00003e" 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;...
  • Page 216 filter.inner Availability Flash 8. Usage filter.inner Description Property; a Boolean value that specifies whether the shadow is an inner shadow ( ) or not true ). This property is defined for Filter objects with a value of false "dropShadowFilter" for the property.
  • Page 217 Example The following example sets the property to for the Glow filters on the selected knockout true 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...
  • Page 218 filter.quality Availability Flash 8. Usage filter.quality Description Property; a string that specifies the blur quality. Acceptable values are , and "low" "medium" is similar to a Gaussian blur). This property is defined for Filter objects with "high" "high" a value of "bevelFilter"...
  • Page 219 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.
  • Page 220 Example The following example sets the shadow color to for the Bevel filters on the "#ff00003e" 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.strength Description...
  • Page 221 filter.type Availability Flash 8. Usage filter.type Description Property; a string that specifies the type of bevel or glow. Acceptable values are "inner" , and . This property is defined for Filter objects with a value of "outer" "full" , or for the "bevelFilter"...
  • Page 222: Flash Object (Fl)

    CHAPTER 16 Objects flash object (fl) Availability Flash MX 2004. Description The flash object represents the Flash application. You can use to refer to this flash object. This documentation uses throughout. Method summary for the flash object The following methods can be used with the flash object. Method Description Opens a File Open or File Save system dialog box and lets the...
  • Page 223 Method Description Opens a Flash (FLA) document for editing in a new Flash fl.openDocument() Document window and gives it the focus. Opens a Flash Project (FLP) file in the Flash authoring tool for fl.openProject() editing. Opens a script (JSFL, AS, ASC) or other file (XML, TXT) in fl.openScript() the Flash text editor.
  • Page 224 Properties Description A Boolean value that specifies whether Contact Sensitive fl.contactSensitiveSelection selection mode is enabled. Read-only; an array of strings that represent the various fl.createNewDocList types of documents that can be created. Read-only; an array of strings that represent the file fl.createNewDocListType extensions of the types of documents that can be created.
  • Page 225 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 , see “Property summary for the Effect object” fl.activeEffect on page 190. Example The following example stores an object that represents the current effect in the variable.
  • Page 226 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 method can browse for any type of file, but fl.browseForFileURL() fl.openDocument()
  • Page 227 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 FLfile object fl.browseForFileURL() fl.closeAll() Availability Flash MX 2004. Usage fl.closeAll() Parameters...
  • Page 228 Parameters documentObject bPromptToSaveChanges Document object. If refers to the active document, documentObject documentObject the Document window might not close until the script that calls this method finishes executing. A Boolean value. If it is , the user is not prompted if the bPromptToSaveChanges false document contains unsaved changes;...
  • Page 229 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"));...
  • Page 230 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.
  • Page 231 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;...
  • Page 232 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.
  • Page 233 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.
  • Page 234 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.
  • Page 235 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 drawingLayer.setColor() fl.effects Availability Flash MX 2004. Usage fl.effects Description...
  • Page 236 Parameters A Boolean value that specifies whether to enable ( ) or disable bEnableUpdates true ) immediate visual updates of the timeline when executing effects. false Returns Nothing. Description Method; lets the script developer enable immediate visual updates of the timeline when executing effects.
  • Page 237 Example The following example displays in the Output panel for each specified file, true false 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 The document name for which you want to find the index. The document must be name open.
  • Page 238 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 memType acceptable values, see the following description. Returns An integer that represents the number of bytes being used in a specified area of Flash.exe memory.
  • Page 239 fl.getDocumentDOM() Availability Flash MX 2004. Usage fl.getDocumentDOM() Parameters None. Returns A Document object, or if no documents are open. null 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.
  • Page 240 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 Project object fl.createProject() fl.openProject() fl.mapPlayerURL() Availability Flash MX 2004.
  • Page 241 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;...
  • Page 242 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 property. fl.mruRecentFileList Example The following example displays the number of recently opened files, and the type of each file, in the Output panel.
  • Page 243 fl.openDocument() Availability Flash MX 2004. Usage fl.openDocument( fileURI ) Parameters A string, expressed as a file:/// URI, that specifies the name of the file to fileURI be opened. Returns 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.
  • Page 244 Parameters A string, expressed as a file:/// URI, that specifies the path of the Flash Project fileURI (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.
  • Page 245 fl.outputPanel Availability Flash MX 2004. Usage fl.outputPanel Description Read-only property; reference to the outputPanel object. Example outputPanel object. fl.quit() Availability Flash MX 2004. Usage fl.quit( [bPromptIfNeeded] ) Parameters A Boolean value that is (default) if you want the user to be bPromptIfNeeded true prompted to save any modified documents.
  • Page 246 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...
  • Page 247 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.
  • Page 248 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.
  • Page 249 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");...
  • Page 250 See also document.save() document.saveAndCompact() fl.saveDocument() fl.saveDocumentAs() fl.saveDocument() Availability Flash MX 2004. Usage fl.saveDocument( document [, fileURI] ) Parameters Document object that specifies the document to be saved. If document document null the active document is saved. A string, expressed as a file:/// URI, that specifies the name of the saved document. fileURI If the parameter is...
  • Page 251 fl.saveDocumentAs() Availability Flash MX 2004. Usage fl.saveDocumentAs( document ) Parameters Document object that specifies the document to save. If , the document document null active document is saved. Returns A Boolean value: if the Save As operation completes successfully; otherwise. true false Description...
  • Page 252 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]);...
  • Page 253 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 A string that appears in the Output panel. message Returns Nothing.
  • Page 254 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.
  • Page 255: Flfile Object

    The FLfile API is provided in the form of an extension to the JavaScript API. This extension is called a shared library and is located in the following folder: Windows 2000 or Windows XP: boot drive\Documents and Settings\user\Local Settings\Application Data\Macromedia\Flash 8\ language\Configuration\External Libraries\FLfile.dll Mac OS X: Macintosh HD/Users/userName/Library/Application Support/Macromedia/Flash 8/ language/Configuration/External Libraries/FLfile.dll Don't confuse the shared libraries that contain symbols in your Flash documents with the JavaScript API shared libraries.
  • Page 256 Method summary for the FLfile object The following methods can be used with the FLfile object. Method Description Copies a file. FLfile.copy() Creates one or more folders. FLfile.createFolder() Determines the existence of a file or folder. FLfile.exists() Finds out if a file is writable, read-only, hidden, visible, FLfile.getAttributes() or a system folder.
  • Page 257 Parameters A string, expressed as a file:/// URI, that specifies the file you want to copy. fileURI A string, expressed as a file:/// URI, that specifies the location and name of the copyURI copied file. Returns A Boolean value of if successful;...
  • Page 258 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.configURI+"folder01/subfolder01"));...
  • Page 259 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.
  • Page 260 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 to test for the existence of a file or folder before FLfile.exists() using this method.
  • Page 261 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" 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.
  • Page 262 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");...
  • Page 263 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.getModificationDate(file2) if(modificationTime1 >...
  • Page 264 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.getSize( fileURI ) Parameters...
  • Page 265 FLfile.listFolder() Availability Flash MX 2004 7.2. Usage FLfile.listFolder( folderURI [, filesOrDirectories ] ) Parameters A string, expressed as a file:/// URI, specifying the folder whose contents you folderURI want to retrieve. You can include a wildcard mask as part of .
  • Page 266 The following example uses a file mask in the specified to return the names of all folderURI 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 fileOrFolderURI attributes you want to retrieve.
  • Page 267 FLfile.remove() Availability Flash MX 2004 7.2. Usage FLfile.remove( fileOrFolderURI ) Parameters A string, expressed as a file:/// URI, specifying the file or folder you want fileOrFolderURI to remove (delete). Returns A Boolean value of if successful; otherwise. true false Description Method;...
  • Page 268 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 A string, expressed as a file:/// URI, specifying the file whose attributes you want fileURI to set.
  • Page 269 If you include both , the is ignored and the file is set as writable. strAttrs Similarly, if you pass , the 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 parameter before setting attributes.
  • Page 270 Returns A Boolean value of if successful; otherwise. true false 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.
  • Page 271: Folderitem Object

    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. folderItem object...
  • Page 272: Fontitem 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. Objects...
  • Page 273: Frame 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 Returns an array of JavaScript objects, each of which has frame.getCustomEase() an x and y property.
  • Page 274 Property Description An integer that specifies the number of times the tweened frame.motionTweenRotateTimes element rotates between the starting keyframe and the next keyframe. A Boolean value; specifies whether the tweened element frame.motionTweenScale scales to the size of the object in the following keyframe, increasing its size with each frame in the tween ( ) or true...
  • Page 275 Property Description A string that specifies the type of tween. frame.tweenType A Boolean value that specifies whether a single custom frame.useSingleEaseCurve 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"...
  • Page 276 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.
  • Page 277 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 property for the first position frame in the top layer: var theFrame = fl.getDocumentDOM().getTimeline().layers[0].frames[0] var easeArray = theFrame.getCustomEase( "position"...
  • Page 278 frame.labelType Availability Flash MX 2004. Usage frame.labelType Description Property; a string that specifies the type of Frame name. Acceptable values are "none" , and . Setting a label to clears the "name" "comment" "anchor" "none" frame.name property. Example The following example sets the name of the first frame in the top layer to "First Frame"...
  • Page 279 frame.motionTweenRotate Availability Flash MX 2004. Usage frame.motionTweenRotate Description Property; a string that specifies how the tweened element rotates. Acceptable values are , and . A value of means the "none" "auto" "clockwise" "counter-clockwise" "auto" object will rotate in the direction requiring the least motion to match the rotation of the object in the following keyframe.
  • Page 280 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 ( ) or true doesn’t scale ( false...
  • Page 281 Description Property; a Boolean value; if set to , synchronizes the animation of the tweened object true 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.
  • Page 282 Parameters A string that specifies the property the ease curve should be used for. Acceptable property values are , and "all" "position" "rotation" "scale" "color" "filters" An array of objects that defines the ease curve. Each array element must be a easeCurve JavaScript object with x and y properties.
  • Page 283 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 "distributive"...
  • Page 284 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 property soundLibraryItem 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];...
  • Page 285 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 ), as stored in the library.
  • Page 286 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, is the index of the first frame in the frame sequence. In stFrame this example, a frame sequence is spanning the six frames from Frame 5 to Frame 10. Therefore, the value of at any frame between Frame 5 and Frame 10 is 4 (remember stFrame...
  • Page 287 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"...
  • Page 288 frame.useSingleEaseCurve Availability Flash 8. Usage frame.useSingleEaseCurve Description Property; a Boolean value. If , a single custom ease curve is used for easing information true for all properties. If , each property has its own ease curve. false 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:...
  • Page 289: Halfedge Object

    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.
  • Page 290 Usage halfEdge.getEdge() Parameters None. Returns 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);...
  • Page 291 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.
  • Page 292 Returns A HalfEdge object. Description Method; gets the preceding HalfEdge object on the current contour. 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 variable: prevHalfEdge var shape = fl.getDocumentDOM().selection[0];...
  • Page 293 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.
  • Page 294: Instance Object

    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 Read-only;...
  • Page 295 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 instance to refer to a symbol bitmap).
  • Page 296: Item Object

    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 Adds specified data to a library item.
  • Page 297 Property Description A Boolean value. If , the item is imported for item.linkageImportForRS true runtime sharing. A string that specifies the URL where the SWF file item.linkageURL containing the shared asset is located. A string that specifies the name of the library item, item.name which includes the folder structure.
  • Page 298 item.getData() Availability Flash MX 2004. Usage item.getData( name ) Parameters A string that specifies the name of the data to retrieve. name Returns The data specified by the parameter. The type of data returned depends on the type of name stored data.
  • Page 299 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;...
  • Page 300 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 , the item is exported for ActionScript.
  • Page 301 Description Property; a Boolean value. If this property is , the item is exported for runtime sharing. true You can also set the item.linkageExportForAS item.linkageExportInFirstFrame properties to true If you set this property to true, the property must be set to item.linkageImportForRS .
  • Page 302 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 , and are set to .
  • Page 303 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 , and are set to . Conversely, item.linkageExportForAS item.linkageExportForRS false this property must be set when any of those properties are set to .
  • Page 304 item.removeData() Availability Flash MX 2004. Usage item.removeData( name ) Parameters pecifies the name of the data to remove from the library item. name S 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].removeData( "myData"...
  • Page 305: Layer Object

    CHAPTER 24 Objects Layer object Availability Flash MX 2004. Description The Layer object represents a layer in the timeline. The property contains timeline.layers 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...
  • Page 306 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" "#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.
  • Page 307 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 to the array of Frame objects for the frameArray frames in the current document: var frameArray = fl.getDocumentDOM().getTimeline().layers[0].frames; To determine if a frame is a keyframe, check whether the property frame.startFrame...
  • Page 308 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;...
  • Page 309 Example The following example stores the Boolean value for the status of the first layer in the variable: lockStatus 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.
  • Page 310 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 of the preceding or following layer.
  • Page 311: Library Object

    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 ) and can be accessed by document.library fl.getDocumentDOM().library The library object contains an array of items of different types, including symbols, bitmaps, sounds, and video.
  • Page 312 Method Description Creates a new folder with the specified name, or a default library.newFolder() name ( ) if no parameter is "untitled folder #" folderName provided, in the currently selected folder. Renames the currently selected library item in the Library library.renameItem() panel.
  • Page 313 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");...
  • Page 314 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, namePath you can specify its name and path using slash notation. If you pass a folder name, the folder and all its items are deleted.
  • Page 315 Returns A Boolean value: if the item is duplicated successfully; otherwise. If more than true false 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 ) and is set as the currently selected item.
  • Page 316 library.expandFolder() Availability Flash MX 2004. Usage library.expandFolder( bExpand [, bRecurseNestedParents [, namePath ] ] ) Parameters A Boolean value: if , the folder is expanded; if (the default), the folder bExpand true false is collapsed. A Boolean value: if , all the folders within the specified bRecurseNestedParents true folder are expanded or collapsed, based on the value of...
  • Page 317 Parameters A string that specifies the name of the item. If the item is in a folder, you can namePath specify its name and path using slash notation. 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.
  • Page 318 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 namePath name and path using slash notation. If is not specified, Flash provides the type of namePath the current selection.
  • Page 319 Example The following example stores the array of currently selected library items (in this case, several audio files) in the variable and then changes the property of the first selItems sampleRate audio file in the array to "11 kHz" var selItems = fl.getDocumentDOM().library.getSelectedItems(); selItems[0].sampleRate = "11 kHz";...
  • Page 320 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 namePath name and path using slash notation. Returns A Boolean value: if the specified item exists in the library; otherwise.
  • Page 321 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 folderPath "FolderName" . To move an item to the top level, specify an empty string ("") "FolderName/FolderName"...
  • Page 322 Parameters A string that specifies the name of the folder to be created. If it is specified as a folderPath path, and the path doesn’t exist, the path is created. This parameter is optional. Returns A Boolean value: if folder is created successfully; otherwise.
  • Page 323 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 bSelectAll library. Omit this parameter or use the default value of to select all the items in the true library;...
  • Page 324 Parameters A string that specifies the name of the item. If the item is in a folder, you can namePath specify its name and path using slash notation. A Boolean value that specifies whether to replace the current bReplaceCurrentSelection selection or add the item to the current selection. The default value is (replace current true selection).
  • Page 325 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 Property summary for the Item object and property summaries for its subclasses.
  • Page 326 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 namePath 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.
  • Page 327: Math Object

    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 . This fl.Math 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...
  • Page 328 Description Method; performs a matrix concatenation and returns the result. Example The following example stores the currently selected object in the variable, multiplies the object matrix by the view matrix, and stores that value in the variable: var elt = fl.getDocumentDOM().selection[0]; var mat = fl.Math.concatMatrix( elt.matrix , fl.getDocumentDOM().viewMatrix Math.invertMatrix() Availability...
  • Page 329 Math.pointDistance() Availability Flash MX 2004. Usage Math.pointDistance(pt1, pt2) Parameters 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 in the dist variable:...
  • Page 330: Matrix Object

    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 A floating-point value that specifies the (0,0) element in the transformation matrix.a matrix.
  • Page 331 Example 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;...
  • Page 332 Example In the following example, you can set 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 to 0.
  • Page 333 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 properties (see matrix.tx matrix.ty...
  • Page 334: Outputpanel Object

    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 ). See fl.outputPanel flash.outputPanel fl.outputPanel Method summary for the outputPanel object The outputPanel object uses the following methods.
  • Page 335 Example The following example clears the current contents of the Output panel: fl.outputPanel.clear(); outputPanel.save() Availability Flash MX 2004; parameter added in Flash 8. bUseSystemEncoding Usage outputPanel.save(fileURI [, bAppendToFile [ , bUseSystemEncoding ] ]) Parameters A string, expressed as a file:/// URI, that specifies the local file to contain the fileURI contents of the Output panel.
  • Page 336 outputPanel.trace() Availability Flash MX 2004. Usage outputPanel.trace(message) Parameters parameter is a string that contains the text to add to the Output panel. message 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.
  • Page 337: Parameter Object

    CHAPTER 29 Objects Parameter object Availability Flash MX 2004. Description The Parameter object type is accessed from the array (which screen.parameters corresponds to the screen Property inspector in the Flash authoring tool) or by the array (which corresponds to the component Property componentInstance.parameters inspector in the authoring tool).
  • Page 338 parameter.category Availability Flash MX 2004. Usage parameter.category Description Property; a string that specifies the property for the parameter or category screen parameter. This property provides an alternative way of presenting a list componentInstance of parameters. This functionality is not available through the Flash user interface. parameter.insertItem() Availability Flash MX 2004.
  • Page 339 Description Method; inserts an item in a list, object, or array. If a parameter is a list, object, or array, the property is an array. value Example The following example inserts the value of into the "New Value" labelPlacement parameter: // Select an instance of a Button component on the Stage.
  • Page 340 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;...
  • Page 341 Example The following example removes the element at index 1 from the parameter labelPlacement 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 = "...
  • Page 342 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 property is determined by the property for the parameter (see value valueType parameter.valueType...
  • Page 343: Path Object

    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();...
  • Page 344 path.addCubicCurve() Availability Flash MX 2004. Usage path.addCubicCurve(xAnchor, yAnchor, x2, y2, x3, y3, x4, y4) Parameters A floating-point number that specifies the x position of the first control point. xAnchor A floating-point number that specifies the y position of the first control point. yAnchor A floating-point number that specifies the x position of the second control point.
  • Page 345 Parameters A floating-point value that specifies the x position of the first control point. xAnchor A floating-point value that specifies the y position of the first control point. yAnchor A floating-point value that specifies the x position of the second control point. A floating-point value that specifies the y position of the second control point.
  • Page 346 Description Method; adds a point to the path. Example The following example creates a new path, stores it in the variable, and assigns the myPath new point to the path: var myPath = fl.drawingLayer.newPath(); myPath.addPoint(10, 100); path.clear() Availability Flash MX 2004. Usage path.clear() Parameters...
  • Page 347 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();...
  • Page 348 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, myPath.addPoint( 0, 30); myPath.addPoint(30, 30); myPath.addPoint(30, myPath.addPoint( 0, myPath.newContour();...
  • Page 349 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 variable: myPath...
  • Page 350: Project Object

    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()
  • Page 351 project.addFile() Availability Flash 8. Usage project.addFile( fileURI [ , autoCreateFolder ] ) Parameters A string specifying the file to be added to the project, expressed as a file:/// URI. fileURI An optional Boolean value specifying if folders should be automatically autoCreateFolder created in the Project panel to mirror the path in ;...
  • Page 352 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();...
  • Page 353 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!");...
  • Page 354 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.
  • Page 355 project.findProjectItem() Availability Flash 8. Usage project.findProjectItem( fileURI ) Parameters A string specifying the file to search for in the project, expressed as a file:/// URI. fileURI Returns A ProjectItem object for the item if successful; otherwise, returns . See ProjectItem false object.
  • Page 356 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 ProjectItem object fl.getProject() project.name Availability Flash 8. Usage project.name Description Property;...
  • Page 357 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;...
  • Page 358 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().testProject();...
  • Page 359: Projectitem Object

    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 ). You can use the following project.items commands to return a ProjectItem object.
  • Page 360 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.
  • Page 361 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.
  • Page 362 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.
  • Page 363 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...
  • Page 364 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 will fail.
  • Page 365 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...
  • Page 366: Screen Object

    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...
  • Page 367 Properties Description Property; equivalent to the Tab Index field in the Accessibility panel. screen.tabIndex Read-only; the Timeline object for the screen. See Timeline object. screen.timeline 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.
  • Page 368 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 variable and displays their names in the myChildren 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) {...
  • Page 369 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 , it is the same as the Make Child Object forceSimple true...
  • Page 370 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);...
  • Page 371 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 value of the first child screen in the array name to the...
  • Page 372 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.
  • Page 373 screen.parentScreen Availability Flash MX 2004. Usage screen.parentScreen Description Read-only property; an object that represents the parent screen. If , the parentScreen null screen is a top-level screen. Example The following example stores the values for the properties childScreens parentScreen in variables and then shows those values and their parent/child relationship in the Output panel: if(fl.getDocumentDOM().allowScreens) { var myCurrent =...
  • Page 374 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.
  • Page 375 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;...
  • Page 376: Screenoutline Object

    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 to verify that a Screens document document.allowScreens()
  • Page 377 Method Description Changes the screen with a specified name to a screenOutline.renameScreen() new name. Sets the current selection in the screen outline to screenOutline.setCurrentScreen() the specified screen. Lets the specified property with the specified value screenOutline.setScreenProperty() for the selected screens. Selects the specified screens in the Screen screenOutline.setSelectedScreens() Outline pane.
  • Page 378 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”...
  • Page 379 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.
  • Page 380 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 variable and displays myArray the screen names in the Output panel:...
  • Page 381 Parameters A string indicating the name of the new screen to insert. An empty name will insert a name screen with a default screen name, such as Slide or Form (where is the first available unique number). This parameter is optional. A string indicating the name of the screen into which the new screen is referenceScreen inserted as a child.
  • Page 382 Parameters A string indicating the name of the new screen to insert. If this parameter is omitted, name the method inserts a screen with a default screen name, such as Slide or Form (where the first available unique number). This parameter is optional. A string indicating the name of the screen before the new screen.
  • Page 383 Parameters A string that is the screen name to move. screenToMove A string that specifies the screen near which will referenceScreen screenToMove be placed. A string that specifies where to move the screen in relation to position referenceScreen Acceptable values are , and "before"...
  • Page 384 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 as a shortcut for screenOutline.rootScreen screenOutline.screens[0]...
  • Page 385 Example The following example stores the array of Screen objects in the variable and then myArray 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+".
  • Page 386 screenOutline.setScreenProperty() Availability Flash MX 2004. Usage screenOutline.setScreenProperty( property, value ) Parameters A string that specifies the property to set. property 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.
  • Page 387 screenOutline.setSelectedScreens() Availability Flash MX 2004. Usage screenOutline.setSelectedScreens ( selection [, bReplaceCurrentSelection ] Parameters An array of screen names to be selected in the screen outline. selection A Boolean value that, if , lets you deselect the current bReplaceCurrentSelection true selection. The default value is .
  • Page 388: Shape Object

    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.
  • Page 389 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:...
  • Page 390 Example The following example stores the first contour in the contours array in the variable and then stores the HalfEdge object of that contour in the variable: var c = fl.getDocumentDOM().selection[0].contours[0]; var he = c.getHalfEdge(); shape.deleteEdge() Availability Flash MX 2004. Usage shape.deleteEdge( index ) Parameters...
  • Page 391 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.
  • Page 392 Example The following example stores the first selected object in the variable and then uses item properties to determine if the element.elementType shape.isDrawingObject selected item is a drawing object. var sel = fl.getDocumentDOM().selection[0]; var shapeDrawingObject = (sel.elementType == "shape") && sel.isDrawingObject;...
  • Page 393 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 object in the variable and item someShape then shows the number of vertices for that object in the Output panel: var someShape = fl.getDocumentDOM().selection[0];...
  • Page 394: Sounditem Object

    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 Item object. frame.soundLibraryItem Property summary for the SoundItem object In addition to the...
  • Page 395 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"...
  • Page 396 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 , and "Default" "ADPCM" "MP3" "Raw" "Speech" If you want to specify a value for this property, set soundItem.useImportedMP3Quality false Example...
  • Page 397 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.
  • Page 398 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" , and "11 kHz" "22 kHz" "44 kHz" If you want to specify a value for this property, set soundItem.useImportedMP3Quality false Example...
  • Page 399: Stroke Object

    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 method, you can change the stroke settings document.setCustomStroke() for the Tools panel, the Property inspector, and the current selection.
  • Page 400 Property Description A string that specifies the jiggle property of a hatched line. stroke.jiggle A string that specifies the type of join for the stroke. stroke.joinType A string that specifies the length of a hatch line. stroke.length A float value that specifies the angle above which the tip of the stroke.miterLimit miter will be truncated by a segment.
  • Page 401 Example The following example sets the property to breakAtCorners 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"...
  • Page 402 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 property is (see ).
  • Page 403 Description Property; an integer that specifies the lengths of the solid parts of a dashed line. This property is available only if the property is set to stroke.style "dashed" (see stroke.style Example The following example sets the properties for a stroke style of dash1 dash2 dashed...
  • Page 404 Example The following example sets the density property to for the stroke style of "sparse" 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...
  • Page 405 Example The following example sets the property to for a stroke style of dotSpace 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 property is set to (see ).
  • Page 406 Description Property; a string that specifies the jiggle property of a hatched line. This property is available only if the property is set to (see ). Acceptable stroke.style "hatched" stroke.style values are , and "none" "bounce" "loose" "wild" Example The following example sets the property to for a stroke style of jiggle...
  • Page 407 Description Property; a string that specifies the length of a hatch line. This property is available only if the property is set to (see ). Acceptable values are stroke.style "hatched" stroke.style , and "equal" "slight" "variation" "medium variation" "random" Example The following example sets the property to for a stroke style of...
  • Page 408 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 property is set to (see ). Acceptable values are stroke.style "ragged" stroke.style , and "solid" "simple"...
  • Page 409 Example The following example sets the property to for a style stroke of rotate "free" 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.
  • Page 410 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 property is set to (see ).
  • Page 411 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" , and .
  • Page 412 Usage stroke.thickness Description Property; an integer that specifies the stroke size. Example The following example sets the property of the stroke to a value of thickness var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.thickness = 2; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.variation Availability Flash MX 2004. Usage stroke.variation Description...
  • Page 413 Description Property; a string that specifies the wave height of a ragged line. This property is available only if the property is set to (see ). Acceptable values are stroke.style "ragged" stroke.style , and "flat" "wavy" "very wavy" "wild" Example The following example sets the property to for a stroke style of...
  • Page 414: Symbolinstance Object

    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...
  • Page 415 Property Description An integer that is part of the color transformation for the symbolInstance.colorBluePercent instance; equivalent to using the Color > Advanced setting in the instance Property inspector (the percentage controls on the left of the dialog box). An integer that is part of the color transformation for the symbolInstance.colorGreenAmount instance;...
  • Page 416 Property Description A Boolean value that enables or disables the symbolInstance.silent accessibility of the object; equivalent to the inverse logic of the Make Object Accessible setting in the Accessibility panel. A string that specifies the type of symbol; equivalent to symbolInstance.symbolType the value for Behavior in the Create New Symbol and Convert To Symbol dialog boxes.
  • Page 417 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 action to the first item in the first frame of onClipEvent the first layer in the timeline:...
  • Page 418 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.
  • Page 419 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.
  • Page 420 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.
  • Page 421 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...
  • Page 422 Example The following example changes the property of the first element in the first frame colorMode 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. This property is equivalent to using the Color >...
  • Page 423 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 variable: theDescription var theDescription = fl.getDocumentDOM().selection[0].description;...
  • Page 424 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;...
  • Page 425 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 , it is the same as the Make forceSimple true...
  • Page 426 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';...
  • Page 427 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 , it is the same as the Make Object Accessible option silent true being unchecked.
  • Page 428 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.
  • Page 429: Symbolitem Object

    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...
  • Page 430 Property Description A string that specifies the type of symbol. symbolItem.symbolType Read-only; a Timeline object. symbolItem.timeline 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].convertToCompiledClip();...
  • Page 431 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 outputURI...
  • Page 432 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.
  • Page 433 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 . Used for shared library symbols. false Example The following example sets the property for a library item: sourceAutoUpdate fl.getDocumentDOM().library.items[0].sourceAutoUpdate = true;...
  • Page 434 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 property in the sourceLibraryName Output panel: fl.trace(fl.getDocumentDOM().library.items[0].sourceLibraryName);...
  • Page 435 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.layerCount); SymbolItem object...
  • Page 436: Text Object

    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”...
  • Page 437 Property summary for the Text object In addition to the Element object properties, the following properties are available for the Text object: Property Description A string that is equivalent to the Name field in the Accessibility text.accName panel. A float value that specifies the anti-aliasing sharpness of the text.antiAliasSharpness text.
  • Page 438 Property Description A zero-based integer that specifies the offset of the end of a text text.selectionEnd subselection. A zero-based integer that specifies the offset of the beginning text.selectionStart of a text subselection. A string that is equivalent to the Shortcut field in the text.shortcut Accessibility panel.
  • Page 439 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 is set text.fontRenderingMode "customThicknessSharpness"...
  • Page 440 text.autoExpand Availability Flash MX 2004. Usage text.autoExpand Description Property; a Boolean value. For static text fields, a value of causes the bounding width to true expand to show all text. For dynamic or input text fields, a value of causes the bounding true width and height to expand to show all text.
  • Page 441 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";...
  • Page 442 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. This property corresponds to the XML file in the Configuration/Font Embedding folder.
  • Page 443 Property value How text is rendered Renders text using the FlashType font rendering technology advanced implemented in Flash 8, which produces better anti-aliasing and improves readability, especially for small text. Lets you specify custom settings for the sharpness and customThicknessSharpness thickness of the text when using the FlashType font rendering technology implemented in Flash 8.
  • Page 444 Description Method; retrieves the attribute specified by the parameter for the text identified by attrName the optional parameters. If the attribute is not consistent for the startIndex endIndex specified range, Flash returns . If you omit the optional parameters undefined startIndex , the method uses the entire text range.
  • Page 445 Description Method; retrieves the specified range of text. If you omit the optional parameters startIndex , the whole text string is returned. If you specify only , the method endIndex startIndex returns the string starting at the index location and ending at the end of the field. If you specify both , the method returns the string starts from startIndex...
  • Page 446 Description Property; a string that sets the line type. Acceptable values are "single line" "multiline" , and "multiline no wrap" "password" This property works only with dynamic or input text and generates a warning if used with static text. The value works only for input text.
  • Page 447 Description Property; a string that specifies the orientation of the text field. Acceptable values are , and "horizontal" "vertical left to right" "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"...
  • Page 448 Description Property; a Boolean value. If the value is , the text can be scrolled. true This property works only with dynamic or input text; it generates a warning if used with static text. Example The following example sets the property to scrollable false...
  • Page 449 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 to select a range of characters. Characters up to, but text.selectionEnd not including, are selected. See text.selectionEnd text.selectionEnd If there is an insertion point or no selection,...
  • Page 450 Parameters A string that specifies the name of the TextAttrs object property to change. attrName The value for the TextAttrs object property. attrValue For a list of possible values for , see “Property summary for the attrName attrValue TextAttrs object” on page 456 An integer that is the index (zero-based) of the first character in the array.
  • Page 451 text.setTextString() Availability Flash MX 2004. Usage text.setTextString(text [, startIndex [, endIndex]]) Parameters A string that consists of the characters to be inserted into this text object. text An integer that specifies the index (zero-based) of the character in the string startIndex where the text will be inserted.
  • Page 452 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;...
  • Page 453 Example The following example determines if the object is accessible (a value of means that it is false 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.tabIndex Description...
  • Page 454 Example The following example stores the value of the property in the variable: textRuns myTextRuns 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"...
  • Page 455 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.
  • Page 456: Textattrs Object

    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.
  • Page 457 Property Description An integer that specifies the line spacing (leading) of the textAttrs.lineSpacing paragraph An integer that specifies the paragraph’s right margin. textAttrs.rightMargin A Boolean value. A value of causes Flash to rotate the textAttrs.rotation true characters of the text 90º. The default value is false An integer that specifies the size of the font.
  • Page 458 Description Property; a string that specifies paragraph justification. Acceptable values are "left" , and "center" "right" "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.
  • Page 459 Description Property; a Boolean value. A value of causes text to appear with the bold version of true 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);...
  • Page 460 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);...
  • Page 461 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;...
  • Page 462 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 property of the selected text field from the leftMargin 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.
  • Page 463 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 property to 100: lineSpacing fl.getDocumentDOM().selection[0].setTextAttr("lineSpacing", 100); textAttrs.rightMargin Availability Flash MX 2004.
  • Page 464 textAttrs.rotation Availability Flash MX 2004. Usage textAttrs.rotation Description Property; a Boolean value. A value of causes Flash to rotate the characters of the text 90º. true The default value is . This property applies only to static text with a vertical orientation; false it generates a warning if used with other text types.
  • Page 465 Usage textAttrs.url Description Property; a string that represents the property of the text field. This property works only with static text. Example The following example sets the URL of the selected text field to http:// www.macromedia.com: fl.getDocumentDOM().setElementTextAttr("url", "http://www.macromedia.com"); TextAttrs object...
  • Page 466: Textrun Object

    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...
  • Page 467 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;...
  • Page 468: Timeline Object

    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 . This method returns the fl.getDocumentDOM().getTimeline() 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 .
  • Page 469 Method Description Sets the property to for each timeline.createMotionTween() frame.tweenType motion selected keyframe on the current layer, and converts each frame’s contents to a single symbol instance if necessary. Cuts a range of frames on the current layer from the timeline.cutFrames() timeline and saves them to the Clipboard.
  • Page 470 Method Description Selects a range of frames in the current layer or sets timeline.setSelectedFrames() the selected frames to the selection array passed into this method. Sets the layer to be selected; also makes the specified timeline.setSelectedLayers() layer the current layer. Shows the layer masking during authoring by locking timeline.showLayerMasking() the mask and masked layers.
  • Page 471 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”.
  • Page 472 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.
  • Page 473 timeline.clearKeyframes() Availability Flash MX 2004. Usage timeline.clearKeyframes([startFrameIndex [, endFrameIndex]]) Parameters A zero-based index that defines the beginning of the range of frames to startFrameIndex clear. If you omit , the method uses the current selection. This parameter is startFrameIndex optional. A zero-based index that defines the end of the range of frames to clear.
  • Page 474 Parameters A zero-based index that specifies the starting frame to convert to startFrameIndex keyframes. If you omit , the method converts the currently selected frames. startFrameIndex This parameter is optional. A zero-based index that specifies the frame at which the conversion to endFrameIndex keyframes will stop.
  • Page 475 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().convertToKeyframes(1, 9);...
  • Page 476 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);...
  • Page 477 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 (remember that frame.tweenType motion index values are different from frame number values): fl.getDocumentDOM().getTimeline().createMotionTween(0, 9); timeline.currentFrame Availability Flash MX 2004.
  • Page 478 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 variable: curLayer var curLayer = fl.getDocumentDOM().getTimeline().currentLayer; timeline.cutFrames() Availability Flash MX 2004. Usage timeline.cutFrames([startFrameIndex [, endFrameIndex]]) Parameters A zero-based index that specifies the beginning of a range of frames to startFrameIndex...
  • Page 479 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);...
  • Page 480 timeline.expandFolder() Availability Flash MX 2004. Usage timeline.expandFolder(bExpand [, bRecurseNestedParents [, index]]) Parameters A Boolean value that, if set to , causes the method to expand the folder; bExpand true causes the method to collapse the folder. false A Boolean value that, if set to , causes all the layers within bRecurseNestedParents true...
  • Page 481 timeline.findLayerIndex() Availability Flash MX 2004. Usage timeline.findLayerIndex(name) Parameters A string that specifies the name of the layer to find. name Returns An array of index values for the specified layer. If the specified layer is not found, Flash returns undefined Description Method;...
  • Page 482 Description Read-only property; an integer that represents the number of frames in this timeline’s longest layer. Example The following example uses a variable to store the number of frames in the current countNum document’s longest layer: var countNum = fl.getDocumentDOM().getTimeline().frameCount; timeline.getFrameProperty() Availability Flash MX 2004.
  • Page 483 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.getLayerProperty(property) Parameters...
  • Page 484 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.
  • Page 485 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. frameNumIndex If you omit , the method uses the current playhead frame number. This frameNumIndex parameter is optional. If the specified or selected frame is a regular frame, the keyframe is inserted at the frame.
  • Page 486 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 numFrames parameter, the method inserts frames at the current selection in the current layer. This parameter is optional.
  • Page 487 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 ), this method adds a frame at Frame 5, and the length of the frame frameIndex span becomes 11 frames.
  • Page 488 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 except that the inserted timeline.insertBlankKeyframe() 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().insertKeyframe();...
  • Page 489 Description Read-only property; an array of layer objects. Example The following example uses the variable to store the array of layer objects in currentLayers 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.
  • Page 490 Parameters A zero-based index that specifies the beginning of a range of frames to startFrameIndex paste. If you omit , the method uses the current selection. This parameter startFrameIndex is optional. A zero-based index that specifies the frame at which to stop pasting frames. endFrameIndex The method pastes up to, but not including, .
  • Page 491 Parameters A zero-based index that specifies the first frame at which to start startFrameIndex removing frames. If you omit , the method uses the current selection; if startFrameIndex there is no selection, all frames at the current playhead on all layers are removed. This parameter is optional.
  • Page 492 Parameters A zero-based index that specifies which layer to move. layerToMove A zero-based index that specifies which layer you want to move the layer layerToPutItBy next to. For example, if you specify 1 for and 0 for , the layerToMove layerToPutItBy second layer is placed next to the first layer.
  • Page 493 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);...
  • Page 494 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 property list of properties and values, see “Property summary for the Frame object” on page 273.
  • Page 495 Example The following example assigns the ActionScript command to the first frame of the stop() 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.getDocumentDOM().getTimeline().setFrameProperty("tweenType","motion",1,4 timeline.setLayerProperty()
  • Page 496 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.setSelectedFrames(selectionList [, bReplaceCurrentSelection]) Parameters A zero-based index that specifies the beginning frame to set. startFrameIndex A zero-based index that specifies the end of the selection;...
  • Page 497 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();...
  • Page 498 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. layer This parameter is optional.
  • Page 499: Toolobj Object

    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 array or tools.toolObjs tools.activeTool Method summary for the ToolObj object The following methods are available for the ToolObj object.
  • Page 500 Property summary for the ToolObj object The following property is available for the ToolObj object: Property Description An integer that specifies the depth of the tool in the pop-up toolObj.depth menu in the Tools panel. An integer that specifies the resource ID of the tool. toolObj.iconID Read-only;...
  • Page 501 Parameters A string that specifies the name of the control to enable or disable. Legal values control depend on the Property inspector invoked by this tool (see toolObj.setPI() A shape Property inspector has the following controls: stroke fill A text Property inspector has the following controls: type font pointsize...
  • Page 502 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 value of -1 means that Flash will not try find an icon for the tool. iconID Instead, the script for the tool should specify the icon to display in the Tools panel;...
  • Page 503 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 file be placed in the same folder as the JSFL file. Returns Nothing.
  • Page 504 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 should display the name theTool “PolyStar Tool”...
  • Page 505 For example, the PolyStar.xml file specifies three options associated with the Polygon tool: <properties> <property name="Style" variable="style" list="polygon,star" defaultValue="0" type="Strings" /> <property name="Number of Sides" variable="nsides" min="3" max="32" defaultValue="5" type="Number" /> <property name="Star point size" variable="pointParam" min="0" max="1" defaultValue=".5" type="Double" />...
  • Page 506 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 (the "shape" default), , and "text" "movie" Example The following example specifies that the shape Property inspector should be used when the tool is activated.
  • Page 507 toolObj.setToolTip() Availability Flash MX 2004. Usage toolObj.setToolTip( toolTip ) Parameters A string that specifies the tooltip to use for the tool. toolTip 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.
  • Page 508 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...
  • Page 509 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 bShow for the current tool ( shows the handles; hides them). true false Returns Nothing. Description Method;...
  • Page 510: Tools Object

    CHAPTER 45 Objects Tools object Availability Flash MX 2004. Description The Tools object is accessible from the flash object ( ). The fl.tools tools.toolObjs property contains an array of ToolObj objects, and the property returns tools.activeTool the ToolObj object for the currently active tool. (See also “ToolObj object”...
  • Page 511 Property Description Read-only; a point that represents the position of the last mouse- tools.penDownLoc down event on the Stage. Read-only; a point that represents the current location of the tools.penLoc mouse. Read-only; a Boolean value that identifies if the Shift key is being tools.shiftIsDown pressed.
  • Page 512 Description Read-only property; a Boolean value that identifies if the Alt key is being pressed. The value is if the Alt key is pressed, and otherwise. true false Example The following example determines whether the Alt key is being pressed. var isAltDown = fl.tools.altIsDown;...
  • Page 513 tools.ctlIsDown Availability Flash MX 2004. Usage tools.ctlIsDown Description Read-only property; a Boolean value that is if the Control key is pressed; true otherwise. false Example The following example determines whether the Control key is being pressed. var isCtrldown = fl.tools.ctrlIsDown; tools.getKeyDown() Availability Flash MX 2004.
  • Page 514 tools.mouseIsDown Availability Flash MX 2004. Usage tools.mouseIsDown Description Read-only property; a Boolean value that is if the left mouse button is currently down; true otherwise. false Example The following example determines whether the left mouse button is pressed. var isMouseDown = fl.tools.mouseIsDown; tools.penDownLoc Availability Flash MX 2004.
  • Page 515 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 property comprises two properties, , corresponding to the location tools.penLoc of the mouse pointer. Example The following example determines the current location of the mouse. var tempPt = fl.tools.penLoc;...
  • Page 516 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 if the Shift key is pressed; otherwise.
  • Page 517 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.
  • Page 518: Vertex Object

    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 Gets a...
  • Page 519 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();...
  • Page 520 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 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();...
  • Page 521: Xmlui Object

    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.
  • Page 522 Method Description Sets the label, value pairs of the current item. xmlui.setControlItemElements() Enables or disables (dims) a control. xmlui.setEnabled() Shows or hides a control. xmlui.setVisible() 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.
  • Page 523 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 controlPropertyName value you want to retrieve.
  • Page 524 Parameters A string that specifies the property whose control item element you controlPropertyName 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...
  • Page 525 Example The following example returns a value that indicates whether the control with the ID attribute is enabled: myListBox 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 A string that specifies the ID attribute of the control whose visibility status you controlID want to retrieve.
  • Page 526 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.macromedia.com"); See also fl.xmlui document.xmlPanel() xmlui.get() xmlui.setControlItemElement() xmlui.setControlItemElements() xmlui.setControlItemElement()
  • Page 527 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"...
  • Page 528 Example The following example sets the label and value of items in the the control with the ID attribute to the pairs specified: myControlID label value var nameArray = new Array("January", "February", "March"); var monthArray = new Array(); for (i=0;i<nameArray.length;i++){ elem = new Object();...
  • Page 529 xmlui.setVisible() Availability Flash 8. Usage xmlui.setVisible(controlID, visible) Parameters A string that specifies the ID attribute of the control you want to show or hide. controlID A Boolean value of if you want to show the control; if you want to visible true false...
  • Page 530: Videoitem Object

    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...
  • Page 531 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 + "...
  • Page 532 Objects...
  • Page 533: Chapter 3: C-Level Extensibility

    JavaScript does, which improves performance, or when you want to create more advanced tools or effects. This extensibility mechanism is a subset of the Macromedia Dreamweaver API. If you are familiar with that API, you might recognize the functions in this API. However, this API differs from the Dreamweaver API in the following ways: This API does not contain all the commands in the Dreamweaver API.
  • Page 534: Integrating C Functions

    Bundle them in a DLL file (Windows) or a shared library (Macintosh). Save the DLL file or library in the appropriate location: Windows 2000 or Windows XP: boot drive\Documents and Settings\user\Local Settings\Application Data\Macromedia\ Flash 8\language\Configuration\External Libraries Macintosh OS X: Macintosh HD/Users/userName/Library/Application Support/Macromedia/Flash 8/ language/Configuration/External Libraries Create a JSFL file that calls the functions.
  • Page 535 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.h: #ifndef _MM_JSAPI_H_ #define _MM_JSAPI_H_ ************************************************************************ ***** * Public data types...
  • Page 536 (mmEnv.valueToString ? (*(mmEnv.valueToString))(c, v, l) : (unsigned short *)0) /* 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.valueToInteger))(c, v, l) : JS_FALSE) /* JSBool JS_ValueToDouble(JSContext *cx, jsval v, double *dp);...
  • Page 537 (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.getArrayLength))(c, o) : -1) /* JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) #define JS_GetElement(c, o, i, v) \...
  • Page 538 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);...
  • Page 539 /* 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 <...
  • Page 540 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”...
  • Page 541: Data Types

    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”...
  • Page 542: The C-Level Api

    typedef enum { JS_FALSE = 0, JS_TRUE = 1 } JSBool A simple data type that stores a Boolean value. The C-level API The C-level extensibility API consists of the function signature and the JSBool (*JSNative) following functions: JSBool JS_DefineFunction() unsigned short *JS_ValueToString() JSBool JS_ValueToInteger() JSBool JS_ValueToDouble()
  • Page 543 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: pointer is a pointer to an opaque structure, which must be passed to JSContext some of the functions in the JavaScript API. This variable holds the interpreter’s execution context.
  • Page 544 Arguments unsigned short *name JSNative call unsigned int nargs argument is the name of the function as it is exposed to JavaScript. name argument is a pointer to a C-level function. The function must return a call JSBool which indicates success or failure. argument is the number of arguments that the function expects to receive.
  • Page 545 JSBool JS_ValueToInteger() Usage JSBool JS_ValueToInteger(JSContext *cx, jsval v, long *lp); Description Method; extracts a function argument from a structure, converts it to an integer (if jsval possible), and passes the converted value back to the caller. Arguments JSContext *cx jsval v long *lp argument is the opaque pointer that passes to the JavaScript function.
  • Page 546 JSBool JS_ValueToBoolean() Usage JSBool JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); Description Method; extracts a function argument from a structure, converts it to a Boolean value jsval (if possible), and passes the converted value back to the caller. Arguments JSContext *cx jsval v JSBool *bp argument is the opaque...
  • Page 547 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 structure. It allocates a new JavaScript jsval string object. Arguments JSContext *cx unsigned short *bytes size_t sz jsval *vp argument is the opaque pointer that passes to the JavaScript function.
  • Page 548 Returns A Boolean value: indicates success; indicates failure. JS_TRUE JS_FALSE JSVal JS_BooleanToValue() Usage jsval JS_BooleanToValue(JSBool bv); Description Method; stores a Boolean return value in a structure. jsval Arguments JSBool bv argument is a Boolean value: indicates success; JS_TRUE JS_FALSE indicates failure. Returns structure that contains the Boolean value that passes to the function as an argument.
  • Page 549 JSVal JS_IntegerToValue() Usage jsval JS_IntegerToValue(long lv); Description Method; converts a long integer value to structure. JSVal Arguments argument is the long integer value that you want to convert to a structure. jsval Returns structure that contains the integer that passed to the function as an argument. JSVal JSVal JS_ObjectToValue() Usage...
  • Page 550 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 " ". If the object is a node in the Document document, the function returns "...
  • Page 551 Arguments JSContext *cx unsigned int length jsval *v argument is the opaque pointer that passes to the JavaScript function. JSContext argument is the number of elements that the array can hold. length argument is an optional pointer to the to be stored in the array. If the jsvals return value is not is an array that contains...
  • Page 552 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 argument is the opaque pointer that passes to the JavaScript function. JSContext argument is a pointer to an array object.
  • Page 553 Returns A Boolean value: indicates success; indicates failure. JS_TRUE JS_FALSE 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 Arguments...
  • Page 554 C-Level Extensibility...

This manual is also suitable for:

Flash 8

Table of Contents