Flash JavaScript Dictionary
Trademarks Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware, Authorware Star, Backstage, Bright Tiger, Clustercats, ColdFusion, Contribute, Design In Motion, Director, Dream Templates, Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, Flash Lite, Flex, Fontographer, FreeHand, Generator, HomeSite, JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live Effects, MacRec
CONTENTS CHAPTER 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Overview of the Macromedia Flash JavaScript API . . . . . . . . . . . . . . . . . . . . . . . . 17 The Flash Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 The Document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Specifying the target of an action . . . . . . . . . . . . . . . . . . .
Contour object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 contour.getHalfEdge() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 contour.interior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 contour.orientation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Document object. . . . . . . . . . . . . . . . . .
document.getAlignToDocument() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 document.getCustomFill() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 document.getCustomStroke(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 document.getDataFromDocument() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 document.getElementProperty(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
document.setSelectionBounds() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 document.setSelectionRect(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 document.setStroke() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 document.setStrokeColor(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 document.setStrokeSize() . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Effect object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 effect.effectName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 effect.groupName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 effect.sourceFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 effect.symbolType. . . . . . . . . . . . . . .
fl.openDocument(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 fl.openProject(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 fl.openScript() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 fl.outputPanel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 fl.quit(). . . . . . . . . . . . . . . . . . . . . .
Instance object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 instance.instanceType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 instance.libraryItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Item object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 item.addData() . . . . . . . . . . . . . . .
LinkedVideoInstance object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Math object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Math.concatMatrix() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Math.invertMatrix() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Math.pointDistance() . . . . . . . . . . . . . . . . . . .
ScreenOutline object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 screenOutline.copyScreenFromFile() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 screenOutline.currentScreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 screenOutline.deleteScreen(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 screenOutline.duplicateScreen() . . . . . . . . . . . . . . . . . . . . . . .
stroke.variation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 stroke.waveHeight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 stroke.waveLength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 SymbolInstance object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 symbolInstance.accName . . . . . . . . . . . . . . . . .
textAttrs.size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 textAttrs.target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 textAttrs.url . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Text object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 text.accName . . . . . . . . . . .
timeline.getLayerProperty() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 timeline.getSelectedFrames(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 timeline.getSelectedLayers() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 timeline.insertBlankKeyframe() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 timeline.insertFrames() . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XMLUI object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xmlui.accept(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xmlui.cancel(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xmlui.get() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xmlui.set() . . . . . . . . . . . . . . . . . . . . . . . .
Contents
CHAPTER 1 Introduction The documents on this site assume you are familiar with JavaScript or ActionScript syntax and with basic programming concepts such as functions, parameters, and data types. They also assume that you understand the concept of working with objects and properties. For a reference on JavaScript, see the Netscape JavaScript documentation. Netscape DevEdge Online has a JavaScript Developer Central site (http:// developer.netscape.com/tech/javascript/index.
You can use Macromedia Flash MX 2004 Professional or your preferred text editor to write or edit Flash JavaScript (JSFL) files. If you use Flash Professional, these files have a .jsfl extension by default.
You can embed individual JSAPI commands in ActionScript files by using the MMExecute() command, which is documented in the Flash MX 2004 ActionScript Language Reference. However, the MMExecute() command has an effect only when it is used in the context of a custom userinterface element, such as a component Property inspector, or a SWF panel within the authoring environment. Even if called from ActionScript, JSAPI commands have no effect in Flash Player or outside the authoring environment.
The flash object contains the following child objects: Object How to access componentsPanel object Use fl.componentsPanel to access the componentsPanel object. This object corresponds to the Components panel in the Flash authoring environment. Document object Use fl.documents to retrieve an array of all the open documents; use fl.documents[index] to access a particular document; use fl.getDocumentDOM() to access the current document (the one with focus). drawingLayer object Use fl.
All the objects in the DOM that aren’t listed in the previous table (see “The Flash Document Object Model” on page 19) are accessed from the Document object. For example, to access the library of a document, you use the library property of the Document object, which retrieves a library object: fl.getDocumentDOM().library To access the array of items in the library, you use the items property of the Library object; each element in the array is an Item object: fl.getDocumentDOM().library.
Summary of the DOM structure The following list displays the DOM structure in outline format. Numbers at the beginning of each line represent the level of an object. For example, an object preceded by “03” is a child of next highest “02” object, which, in turn, is a child of the next highest “01” object. In some cases, an object is available by specifying a property of its parent object. For example, the property contains an array of Timeline objects. These properties are noted in the following outline.
09 Vertex object 09 Edge object 07 Vertex object (shape.vertices array) 08 HalfEdge object 09 Vertex object 09 Edge object 03 ScreenOutline object 04 Screen object (screenOutline.screens array) 05 Parameter object (screen.parameters array) 02 drawingLayer object 03 Path object 04 Contour object 02 Effect object (fl.effects array) 02 Math object 02 outputPanel object 02 Tools object (fl.tools array) 03 ToolObj object (tools.
To install the updated PolyStar example files: 1. Copy the new PolyStar.jsfl file to the Tools folder. The PolyStar.xml and PolyStar.png files that you see in this folder are needed by the new PolyStar.jsfl file. 2. Restart Flash. 3. Select Edit > Customize Tools Panel (Windows) or Flash > Customize Tools Panel (Macintosh). You should see PolyStar tool in the available tools list. 4. Click the Rectangle tool at the left side of the Customize Tools Panel dialog box.
CHAPTER 2 Top-level functions This chapter describes the top-level functions that are available when creating extensible tools.
activate() Availability Flash MX 2004. Usage function activate() { // statements } Parameters None. Returns Nothing. Description This function is called when the extensible tool becomes active (that is, when the tool is selected in the Tools panel). Any setup the tool needs to do should be performed in this function. Example function activate() { fl.
configureEffect() Availability Flash MX 2004. Usage function configureEffect() { // statements } Parameters None. Returns Nothing. Description This function is called once at load time of Flash and is a good place for global initialization of your effect. The per instance parameter data for an effect cannot be accessed here.
configureTool() Availability Flash MX 2004. Usage function configureTool() { // statements } Parameters None. Returns Nothing. Description This function is called when Macromedia Flash opens and the tool is loaded. Use this function to set any information Flash needs to know about the tool. Example The following examples show two possible implementations of this function: function configureTool() { theTool = fl.tools.activeTool; theTool.setToolName("myTool"); theTool.setIcon("myTool.png"); theTool.
deactivate() Availability Flash MX 2004. Usage function deactivate() { // statements } Parameters None. Returns Nothing. Description This function is called when the tool becomes inactive (that is, when the active tool changes from this tool to another one). Use this function to perform any cleanup the tool needs. Example function deactivate() { fl.
executeEffect() Availability Flash MX 2004. Usage function executeEffect() { // statements } Parameters None. Returns Nothing. Description This function is called when the user first applies an effect or changes an effect's properties. The code contained in this function is responsible for modifying the original object(s) to accomplish the desired effect.
keyDown() Availability Flash MX 2004. Usage function keyDown() { // statements } Parameters None. Returns Nothing. Description This function is called when the tool is active and the user presses a key. The script should call tools.getKeyDown() to determine which key was pressed. Example function keyDown() { fl.trace("key " + fl.tools.
keyUp() Availability Flash MX 2004. Usage function keyUp() { // statements } Parameters None. Returns Nothing. Description This function is called when the tool is active and a key is released. Example function keyUp() { fl.
mouseDoubleClick() Availability Flash MX 2004. Usage function mouseDoubleClick() { // statements } Parameters None. Returns Nothing. Description This function is called when the mouse button is double-clicked on the Stage. Example function mouseDblClk() { fl.
mouseDown() Availability Flash MX 2004. Usage function mouseDown( [ pt ] ) { // statements } Parameters pt 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. Description This function is called whenever the tool is active and the mouse button is pressed while the pointer is over the Stage. Example function mouseDown() { fl.
mouseMove() Availability Flash MX 2004. Usage function mouseMove( [ pt ] ) { // statements } Parameters pt A point that specifies the current location of the mouse. It is passed to the function whenever the mouse moves, which tracks the mouse location. If the Stage is in edit or edit-in-place mode, the point coordinates are relative to the object being edited. Otherwise, the point coordinates are relative to the Stage. This parameter is optional. Returns Nothing.
mouseUp() Availability Flash MX 2004. Usage function mouseUp() { // statements } Parameters None. Returns Nothing. Description This function is called whenever the mouse button is released after being pressed on the Stage. Example function mouseUp() { fl.
notifySettingsChanged() Availability Flash MX 2004. Usage function notifySettingsChanged() { // statements } Parameters None. Returns Nothing. Description This function is called whenever a tool is active and the user changes its options in the Property inspector. You can use the tools.activeTool property to query the current values of the options. Example function notifySettingsChanged() { var theTool = fl.tools.activeTool; var newValue = theTool.
removeEffect() Availability Flash MX 2004. Usage function removeEffect() { // statements } Parameters None. Returns Nothing. Description This function is called when the user changes an effect's properties or uses the "remove effect" menu item. The code contained in this function is responsible for returning the object(s) to their original state.
setCursor() Availability Flash MX 2004. Usage function setCursor() { // statements } Parameters None. Returns Nothing. Description This function is called whenever the mouse moves, to allow the script to set custom pointers. The script should call tools.setCursor() to specify the pointer to use. For a list that shows which pointers correspond to which integer values, see tools.setCursor(). Example function setCursor() { fl.tools.
Chapter 2: Top-level functions
CHAPTER 3 Objects This chapter describes the Flash JSAPI objects, listed in alphabetical order. The objects are listed in the following table: Object Description BitmapInstance object The BitmapInstance object is a subclass of the Instance object and represents a bitmap in a frame. BitmapItem object A BitmapItem object refers to a bitmap in the library of a document. The BitmapItem object is a subclass of the Item object.
Object Description fontItem object The fontItem object is a subclass of the Item object. Frame object The Frame object represents frames in the layer. HalfEdge object Directed side of the edge of a Shape object. Instance object The Instance object is a subclass of the Element object. Item object The Item object is an abstract base class. Layer object The Layer object represents a layer in the Timeline. library object The library object represents the Library panel.
Object Description TextRun object The TextRun object represents a run of characters that have attributes that match all of the properties in the TextAttrs object. Timeline object The Timeline object represents the Flash Timeline, which can be accessed for the current document by fl.getDocumentDOM().getTimeline(). ToolObj object A ToolObj object represents an individual tool in the Tools panel. Tools object The Tools object is accessible from the Flash object (fl.tools).
bitmapInstance.getBits() Availability Flash MX 2004. Usage bitmapInstance.getBits() Parameters None. Returns An object that contains width, height, depth, bits, and, if the bitmap has a color table, cTab properties. The bits element is an array of bytes. The cTab element is an array of color values of the form "#rrggbb". The length of the array is the length of the color table. Note: The byte array is meaningful only when referenced by an external library.
var isBitmap = bmObj.instanceType; if(isBitmap == "bitmap"){ var numHorizontalPixels = bmObj.hPixels; } bitmapInstance.setBits() Availability Flash MX 2004. Usage bitmapInstance.setBits(bitmap) Parameters An object that contains height, width, depth, bits, and cTab properties. The and depth properties are integers. The bits property is a byte array. The cTab property is required only for bitmaps with a bit depth of 8 or less and is a string that represents a color value in the form "#rrggbb".
Example The following code gets the height of the bitmap in pixels: // get the number of pixels in the vertical dimension var bmObj = fl.getDocumentDOM().selection[0]; var isBitmap = bmObj.instanceType; if(isBitmap == "bitmap"){ var numVerticalPixels = bmObj.
CHAPTER 3 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. Property summary for the BitmapItem object In addition to the Item object properties, the BitmapItem object has following properties: Property Description bitmapItem.allowSmoothing Property; a Boolean value.
bitmapItem.compressionType Availability Flash MX 2004. Usage bitmapItem.compressionType Description Property; a string that determines the type of image compression applied to the bitmap. Acceptable values are "photo" or "lossless". If bitmapItem.useImportedJPEGQuality is false, "photo" corresponds to JPEG using a quality from 0 to 100; if bitmapItem.useImportedJPEGQuality is true, "photo" corresponds to JPEG using the default document quality value. The value "lossless" corresponds to GIF or PNG formats.
Description Property; a Boolean value. To use the default imported JPEG quality, specify true; false otherwise. Available only for JPEG compression. Example The following code sets the useImportedJPEGQuality property of the first item in the library of the current document to true: fl.getDocumentDOM().library.items[0].useImportedJPEGQuality = true; alert(fl.getDocumentDOM().library.items[0].
CompiledClipInstance object Inheritance CHAPTER 3 Objects 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.
Example // get the name of the object. var theName = fl.getDocumentDOM().selection[0].accName; // set the name of the object. fl.getDocumentDOM().selection[0].accName = 'Home Button'; compiledClipInstance.actionScript Availability Flash MX 2004. Usage compiledClipInstance.actionScript Description Property; a string that represents the ActionScript for this instance; equivalent to symbolInstance.actionScript.
compiledClipInstance.forceSimple Availability Flash MX 2004. Usage compiledClipInstance.forceSimple Description Property; a Boolean value that enables and disables the children of the object to be accessible. This is equivalent to the inverse logic of the Make Child Objects Accessible setting in the Accessibility panel. If forceSimple is true, it is the same as the Make Child Objects Accessible option being unchecked.
Description Property; a Boolean value that enables or disables the accessibility of the object; equivalent to the inverse logic of Make Object Accessible setting in the Accessibility panel. That is, if silent is true, then Make Object Accessible is unchecked. If silent is false, then Make Object Accessible is checked. Example The following example illustrates getting and setting the silent property: // query if the object is accessible var isSilent =fl.getDocumentDOM().selection[0].
ComponentInstance object Inheritance CHAPTER 3 Objects 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. Property summary for the ComponentInstance object In addition to all the properties of the SymbolInstance object, the ComponentInstance object has the following property: Property Description componentInstance.
CHAPTER 3 Objects componentsPanel object Availability Flash MX 2004. Description The componentsPanel object, which represents the Components panel, is a property of the flash object and can be accessed by fl.componentsPanel. Method summary for the ComponentsPanel object You can use the following method with the componentsPanel object: Property Description componentsPanel.addItemToDocument() Adds the specified component to the document at the specified position. componentsPanel.
CHAPTER 3 Objects Contour object Availability Flash MX 2004. Description A Contour object represents a closed path of half edges on the boundary of a shape. Method summary for the Contour object You can use the following method with the Contour object: Property Description contour.getHalfEdge() Method; returns a HalfEdge object on the contour of the selection. Property summary for the Contour object You can use the following properties with the Contour object: Property Description contour.
elt.beginEdit(); var contourArray = elt.contours; var contourCount = 0; for (i=0; i
} elt.endEdit(); contour.orientation Availability Flash MX 2004. Usage contour.orientation Description Read-only property: an integer indicating the orientation of the contour. The value of the integer is -1 if the orientation is counterclockwise, 1 if it is clockwise, and 0 if it is a contour with no area. Example The following example traverses all the contours of the selected shape and shows the value of the orientation property of each contour in the Output panel: var elt = fl.getDocumentDOM().
CHAPTER 3 Objects Document object Availability Flash MX 2004. Description The Document object represents the Stage. That is, only FLA files are considered documents. Method summary for the Document object You can use the following methods with the Document object. Method Description document.addDataToDocument() Stores specified data with a document. document.addDataToSelection() Stores specified data with the selected object(s). document.
Method Description document.clipCut() Cuts the current selection from the document and writes it to the Clipboard. document.clipPaste() Pastes the contents of the Clipboard into the document. document.close() Closes the specified document. document.convertLinesToFills() Converts lines to fills on the selected objects. document.convertToSymbol() Converts the selected Stage item(s) to a new symbol. document.
Method Description document.getElementProperty() Gets the specified Element property for the current selection. document.getElementTextAttr() Gets a specified TextAttrs property of the selected text objects. document.getSelectionRect() Gets the bounding rectangle of the current selection. document.getTextString() Gets the currently selected text. document.getTimeline() Retrieves the current Timeline object in the document. document.
Method Description document.rotateSelection() Rotates the selection by a specified amount. document.save() Saves the document in its default location; equivalent to selecting File > Save. document.saveAndCompact() Saves and compacts the file; equivalent to selecting File > Save and Compact. document.scaleSelection() Scales the selection by a specified amount; equivalent to using the Free Transform tool to scale the object. document.
Method Description document.setTextSelection() Sets the text selection of the currently selected text field to the values specified by the startIndex and endIndex values. document.setTextString() Inserts a string of text. document.setTransformationPoint() Moves the transformation point of the current selection. document.skewSelection() Skews the selection by a specified amount. document.smoothSelection() Smooths the curve of each selected fill outline or curved line. document.
Property Description document.description A string that is equivalent to the Description field in the Accessibility panel. document.forceSimple A Boolean value that specifies whether the children of the specified object are accessible. document.frameRate A float value that specifies the number of frames displayed per second when the SWF file plays; the default is 12. document.height An integer that specifies the height of the document (Stage) in pixels. document.
Example The following example sets the accessibility name of the document to "Main Movie": fl.getDocumentDOM().accName = "Main Movie"; The following example gets the accessibility name of the document: fl.trace(fl.getDocumentDOM().accName); document.addDataToDocument() Availability Flash MX 2004. Usage document.addDataToDocument( name, type, data ) Parameters name A string that specifies the name of the data to add. type A string that defines the type of data to add.
Parameters name A string that specifies the name of the persistent data. type Defines the type of data. The valid values for type are: "integer", "integerArray", and "byteArray". "double", "doubleArray", "string", data the value to add. Valid types depend on the type parameter. Returns Nothing. 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.
The following example adds the symbol myMovieClip from the current document’s library to the current document: var itemIndex = fl.getDocumentDOM().library.findItemIndex("myMovieClip"); var theItem = fl.getDocumentDOM().library.items[itemIndex]; fl.getDocumentDOM().addItem({x:0,y:0}, theItem); The following example adds the symbol myMovieClip from the second document in the documents array to the third document in the documents array: var itemIndex = fl.documents[1].library.
Parameters boundingRectangle A rectangle that specifies the bounds of the oval to be added. A Boolean value that, if set to true, causes the method to create the shape without a fill. The default value is false. This parameter is optional. bSuppressFill bSuppressStroke A Boolean value that, if set to true, causes the method to create the shape without a stroke. The default value is false. This parameter is optional. Returns Nothing.
Description Method; adds a new publish profile and makes it the current one. See document.deletePublishProfile(). Example The following example adds a new publish profile with a default name and then displays the name of the profile in the Output panel: fl.getDocumentDOM().addNewPublishProfile(); fl.outputPanel.trace(fl.getDocumentDOM().currentPublishProfile); The following example adds a new publish profile with the name "my profile": fl.getDocumentDOM().addNewPublishProfile("my profile"); document.
Example The following example adds a new rectangle with no round corners within the specified coordinates. flash.getDocumentDOM().addNewRectangle({left:0,top:0,right:100,bottom:100},0); The following example adds a new rectangle with no round corners and without a fill. flash.getDocumentDOM().addNewRectangle({left:0,top:0,right:100,bottom:100},0, true); The following example add a new rectangle no round corners and without a stroke. flash.getDocumentDOM().
document.addNewText() Availability Flash MX 2004. Usage document.addNewText( boundingRectangle ) Parameters boundingRectangle Specifies the size and location of the text field by providing locations in pixels for left, top, right, and bottom. The method applies the current text attributes. It should be followed by calling setTextString() to populate the new text box. Returns Nothing. Description Method; inserts a new empty text field. See document.setTextString().
Example The following example aligns objects to left and to the Stage. This is equivalent to turning on the To Stage setting in the Align panel and clicking the Align to Left button: fl.getDocumentDOM().align("left", true); document.allowScreens() Availability Flash MX 2004. Usage document.allowScreens() Parameters None. Returns Returns a Boolean value: true if dom.screenOutline can be used safely; false otherwise. Description Method; Used before using the document.screenOutline property.
Returns Nothing. Description Method; arranges the selection on the Stage. This method applies only to non-shape objects. 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.
document.breakApart() Availability Flash MX 2004. Usage document.breakApart() Parameters None. Returns Nothing. Description Method; performs a break-apart operation on the current selection. Example The following example breaks apart the current selection: fl.getDocumentDOM().breakApart(); document.canEditSymbol() Availability Flash MX 2004. Usage document.canEditSymbol() Parameters None.
document.canRevert() Availability Flash MX 2004. Usage document.canRevert() Parameters None. Returns A Boolean value: true if you can use the document.revert() or fl.revertDocument() methods successfully; false otherwise. Description Method; determines whether you can use the document.revert() or fl.revertDocument() method successfully. Example The following example checks whether the current document can revert to the previously saved version. If so, fl.getDocumentDOM().
Example The following example tests whether fl.getDocumentDOM().testMovie() can be used. If so, it calls the method. if(fl.getDocumentDOM().canTestMovie()){ fl.getDocumentDOM().testMovie(); } document.canTestScene() Availability Flash MX 2004. Usage document.canTestScene() Parameters None. Returns A Boolean value: true if you can use the document.testScene() method successfully; false otherwise. Description Method; determines whether you can use the document.testScene() method successfully.
Description Method; copies the current selection from the document to the Clipboard. Example The following example copies the current selection from the document to the Clipboard: fl.getDocumentDOM().clipCopy(); 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 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 true, causes the method to prompt the user with a dialog box if there are unsaved changes in the document.
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 type A string that specifies the type of symbol to create. Valid values for type are "movie and "graphic".
document.currentPublishProfile Availability Flash MX 2004. Usage document.currentPublishProfile Description Property; a string that specifies the name of the active publish profile for the specified document. Example The following example adds a new publish profile with the default name and then displays the name of the profile in the Output panel: fl.getDocumentDOM().addNewPublishProfile(); fl.outputPanel.trace(fl.getDocumentDOM().
++i; } document.deletePublishProfile() Availability Flash MX 2004. Usage document.deletePublishProfile() Parameters None. Returns An integer that is the index of the new current profile. If a new profile is not available, the method leaves the current profile unchanged and returns its index. Description Method; deletes the currently active profile, if there is more than one. There must be at least one profile left. See document.addNewPublishProfile().
Example Assuming there are three scenes (Scene0, Scene1, and Scene2) in the current document, the following example makes Scene2 the current scene and then deletes it: fl.getDocumentDOM().editScene(2); var success = fl.getDocumentDOM().deleteScene(); document.deleteSelection() Availability Flash MX 2004. Usage document.deleteSelection() Parameters None. Returns Nothing. Description Method; deletes the current selection on the Stage. Displays an error message if there is no selection.
document.distribute() Availability Flash MX 2004. Usage document.distribute( distributemode [, bUseDocumentBounds ] ) Parameters A string that specifies where to distribute the selected object. Valid values for are "left edge", "horizontal center", "right edge", "top edge", "vertical center", and "bottom edge". distributemode distributeMode bUseDocumentBounds A Boolean value that, when set to true, distributes the selected objects using the bounds of the document.
Returns Nothing. Description Method; performs a distribute-to-layers operation on the current selection—equivalent to selecting Distribute to Layers. This method displays an error if there is no selection. Example The following example distributes the current selection to layers: fl.getDocumentDOM().distributeToLayers(); document.documentHasData() Availability Flash MX 2004. Usage document.documentHasData( name ) Parameters name A string that specifies the name of the data to check.
Returns An integer that is the index of the new profile in the profile list. Returns -1 if the profile cannot be duplicated. Description Method; duplicates the currently active profile and gives the duplicate version focus. Example The following example duplicates the currently active profile and displays the index of the new profile in the Output panel: fl.trace(fl.getDocumentDOM().duplicatePublishProfile("dup profile")); document.duplicateScene() Availability Flash MX 2004. Usage document.
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: fl.getDocumentDOM().duplicateSelection(); document.editScene() Availability Flash MX 2004. Usage document.editScene( index ) Parameters index A zero-based integer that specifies which scene to edit. Returns Nothing. Description Method; makes the specified scene the currently selected scene for editing.
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. See document.exitEditMode(). Example The following example puts Flash in edit-in-place mode for the currently selected symbol: fl.getDocumentDOM().
Parameters fileURI A string, expressed as a file://URL, that specifies the path of the XML file to which the profile is exported. Returns Nothing. Description Method; exports the currently active profile to a file. Example The following example exports the currently active profile to the file named profile.xml in the folder /Documents and Settings/username/Desktop on the C drive: fl.getDocumentDOM().exportPublishProfile('file:///C|/Documents and Settings/ username/Desktop/profile.xml'); document.
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); The following example displays the Export Movie dialog box and then exports the document with specified settings: fl.getDocumentDOM().exportSWF(); document.forceSimple Availability Flash MX 2004. Usage document.
Example The following example sets the frame rate to 25.5 frames per second: fl.getDocumentDOM().frameRate = 25.5; document.getAlignToDocument() Availability Flash MX 2004. Usage document.getAlignToDocument() Parameters None. Returns A Boolean value: true if the preference is set to align the objects to the Stage; false otherwise. 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.
Returns The Fill object specified by the objectToFill parameter, if successful; otherwise, it returns undefined. Description Method; retrieves the fill object of the selected shape or, if specified, of the toolbar and Property inspector. See document.setCustomFill(). Example The following example gets the fill object of the selection and then changes the selection’s color to white: var fill = fl.getDocumentDOM().getCustomFill(); fill.color = '#FFFFFF'; fill.style = "solid"; fl.getDocumentDOM().
Description Returns the stroke object of the selected shape or, if specified, of the toolbar and Property inspector. See document.setCustomStroke(). Example The following example returns the current stroke settings of the selection and changes the stroke thickness to 2: var stroke = fl.getDocumentDOM().getCustomStroke("selection"); stroke.thickness = 2; fl.getDocumentDOM().
document.getElementProperty() Availability Flash MX 2004. Usage document.getElementProperty( propertyName ) Parameters The name of the Element property for which to retrieve the value. Returns The value of the specified property. Returns null if the property is an indeterminate state, as when multiple elements are selected with different property values. Returns undefined if the property is not a valid property of the selected element.
Returns If one text field is selected, the property is returned if there is only one value used within the text. Returns undefined if there are several values used inside the text field. If several text fields are selected, and all the text alignment values are equal, the method returns this value. If several text fields are selected, but all the text alignment values are not equal, the method returns undefined.
Example The following example gets the bounding rectangle for the current selection and then displays its properties: var newRect = fl.getDocumentDOM().getSelectionRect(); var outputStr = "left: " + newRect.left + " top: " + newRect.top + " right: " + newRect.right + " bottom: " + newRect.bottom; alert(outputStr); document.getTextString() Availability Flash MX 2004. Usage document.
document.getTimeline() Availability Flash MX 2004. Usage document.getTimeline() Parameters None. 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. See document.currentTimeline, document.timelines, and symbolItem.timeline.
Description Method; gets the location of the transformation point of the current selection. You can use the transformation point for commutations such as rotate and skew. See document.setTransformationPoint(). Example The following example gets the transformation point for the current selection. The transPoint.x property gives the x coordinate of the transformation point. The transPoint.y property gives the y coordinate of the transformation point: var transPoint = fl.getDocumentDOM().
Example The following example sets the height of the Stage to 400 pixels: fl.getDocumentDOM().height = 400; document.importPublishProfile() Availability Flash MX 2004. Usage document.importPublishProfile( fileURI ) Parameters fileURI A string that specifies the path, expressed as a file://URL, of the XML file defining the profile to import. Returns An integer that is the index of the imported profile in the profiles list. Returns -1 if the profile cannot be imported.
Example The following example imports the "mySwf.swf" file from the Flash Configuration folder: fl.getDocumentDOM().importSWF(fl.configURI+"mySwf.swf"); document.library Availability Flash MX 2004. Usage document.library Description Read-only property; the library object for a document. Example The following example gets the library for the currently focused document: var myCurrentLib = fl.getDocumentDOM().library; Assuming the currently focused document is not fl.
document.match() Availability Flash MX 2004. Usage document.match( bWidth, bHeight [, bUseDocumentBounds] ) Parameters A Boolean value that, when set to true, causes the method to make the widths of the selected items the same. bWidth A Boolean value that, when set to true, causes the method to make the heights of the selected items the same. bHeight bUseDocumentBounds A Boolean value that, when set to true, causes the method to match the size of the objects to the bounds of the document.
A Boolean value that specifies the state of the Shift key: true for pressed; false for not pressed. bToggleSel A Boolean value that specifies the state of the application preference Shift select: for on; false for off. bShiftSel true Returns Nothing. Description Method; performs a mouse click from the arrow tool. See document.mouseDblClk(). Example The following example performs a mouse click at the specified location: fl.getDocumentDOM().mouseClick({x:300, y:200}, false, false); document.
document.moveSelectedBezierPointsBy() Availability Flash MX 2004. Usage document.moveSelectedBezierPointsBy( delta ) Parameters A pair of floating point values that specify the x and y coordinates in pixels by which the selected Bézier points are moved. For example, passing ({x:1,y:2}) specifies a location that is to the right by one pixel and down by two pixels from the current location. delta Returns Nothing.
For information on making a selection, see document.setSelectionRect(), document.mouseClick(), document.mouseDblClk(), and the Element object. Example The following example moves the selected item 62 pixels to the right and 84 pixels down: flash.getDocumentDOM().moveSelectionBy({x:62, y:84}); document.name Availability Flash MX 2004. Usage document.name Description Read-only property; a string that represents the name of a document (FLA file).
Description Method; optimizes smoothing for the current selection, allowing multiple passes, if specified, for optimal smoothing. This method is equivalent to selecting Modify > Shape > Optimize. Example The following example optimizes the curve of the current selection to 50º of smoothing with multiple passes: fl.getDocumentDOM().optimizeCurves(50, true); document.path Availability Flash MX 2004. Usage document.path Description Read-only property; a string that represents the path of the document.
Example The following example publishes the current document: fl.getDocumentDOM().publish(); document.publishProfiles Availability Flash MX 2004. Usage document.publishProfiles Description Read-only property; an array of the publish profile names for the document. Example The following example displays the names of the publish profiles for the document: var myPubProfiles = fl.getDocumentDOM().publishProfiles; for (var i=0; i < myPubProfiles.length; i++){ fl.trace(myPubProfiles[i]); } document.
document.removeDataFromSelection() Availability Flash MX 2004. Usage document.removeDataFromSelection( name ) Parameters name A string that specifies the name of the persistent data to remove. Returns Nothing. Description Method; removes persistent data with the specified name that has been attached to the selection. See document.addDataToSelection(). Example The following example removes from the selection the persistent data named "myData": fl.getDocumentDOM().
document.renameScene() Availability Flash MX 2004. Usage document.renameScene( name ) Parameters name A string that specifies the new name of the scene. Returns A Boolean value: true if the name is changed successfully; false otherwise. If the new name is not unique, for example, the method returns false. 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 moves the second scene to before the first scene: fl.getDocumentDOM().reorderScene(1, 0); 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().
Example The following example reverts the current document to the previously saved version: fl.getDocumentDOM().revert(); document.rotateSelection() Availability Flash MX 2004. Usage document.rotateSelection( angle [, rotationPoint] ) Parameters angle A floating point value that specifies the angle of the rotation. A string that specifies which side of the bounding box to rotate.
Returns A Boolean value: true if the save operation completes successfully; false otherwise. Description Method; saves the document in its default location. This method is equivalent to selecting File > Save. See document.saveAndCompact(), fl.saveDocumentAs(), fl.saveDocument(), and fl.saveAll(). Example The following example saves the current document in its default location: fl.getDocumentDOM().save(); document.saveAndCompact() Availability Flash MX 2004. Usage document.
Parameters xScale A floating point value that specifies the amount of x by which to scale. yScale A floating point value that specifies the amount of y by which to scale. whichCorner A string value that specifies the edge about which the transformation occurs. If omitted, scaling occurs about the transformation point. Acceptable values are: "bottom left", "bottom right", "top right", "top left", "top center", "right center", "bottom center", and "left center". This parameter is optional.
myArray.push(" "+i+" : "+fl.getDocumentDOM().screenOutline[i]) ; } fl.trace("Here is the property dump for screenOutline:: "+myArray); 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. See document.selectNone() and document.selection.
• Use one of the methods of the Timeline object to select a frame or frames, such as timeline.getSelectedFrames(), timeline.setSelectedFrames(), or timeline.selectAllFrames(). • Specify a particular element in a particular frame. For example, the following code specifies and selects an element: fl.getDocumentDOM().getTimeline().layers[0].frames[0].
//begin loop through the elements on a layer for(var c=0; c < theElems.length; c++){ //checks to see if the element is of type "instance" if(theElems[c].elementType == "instance"){ //if the element is an instance, it checks if it is an instance of "myMovieClip" if(theElems[c].libraryItem.
document.setAlignToDocument() Availability Flash MX 2004. Usage document.setAlignToDocument( bToStage ) Parameters bToStage A Boolean value that, if set to true, aligns objects to the Stage. If set to false, it does not. Returns Nothing. Description Method; sets the preferences for document.align(), document.distribute(), document.match(), and document.space() to act on the document. This method is equivalent to enabling the To Stage button in the Align panel. See document.getAlignToDocument().
Example The following example changes the color of the fill color swatch in the toolbar, Property inspector, and any selected shapes to white: var fill = fl.getDocumentDOM().getCustomFill(); fill.color = '#FFFFFF'; fill.style = "solid"; fl.getDocumentDOM().setCustomFill(fill); document.setCustomStroke() Availability Flash MX 2004. Usage document.setCustomStroke( stroke ) Parameters stroke A Stroke object. Returns Nothing.
Note: You can’t use this method to set values for read-only properties, such as element.elementType, element.top, and element.left. value Specifies the value to set in the specified Element property. Returns Nothing. Description Method; sets the specified Element property on selected object(s) in the document. This method does nothing if there is no selection. Example The following example sets the width of all selected objects to 100 and the height to 50: fl.getDocumentDOM().
Example The following examples set the fillColor, italic, and bold text attributes for the selected text items: var success = fl.getDocumentDOM().setElementTextAttr("fillColor", "#00ff00"); var pass = fl.getDocumentDOM().setElementTextAttr("italic", true, 10); var ok = fl.getDocumentDOM().setElementTextAttr("bold", true, 5, 15); document.setFillColor() Availability Flash MX 2004. Usage document.
Returns Nothing. Description Methods; sets the opacity of the instance. Example The following example sets the opacity of the tint to a value of 50: fl.getDocumentDOM().setInstanceAlpha(50); document.setInstanceBrightness() Availability Flash MX 2004. Usage document.setInstanceBrightness( brightness ) Parameters brightness An integer that specifies brightness as a value from -100 (black) to 100 (white). Returns Nothing. Description Method; sets the brightness for the instance.
Returns Nothing. Description Method; sets the tint for the instance. Example The following example sets the tint for the selected instance to red with an opacity value of 50: fl.getDocumentDOM().setInstanceTint(0xff0000, 50); document.setSelectionBounds() Availability Flash MX 2004. Usage document.setSelectionBounds( boundingRectangle ) Parameters A rectangle that specifies the new location and size of the selection.
A Boolean value, that if set to true, replaces the current selection. If it is false, the method adds to the current selection. The default value, if not set, is true. bReplaceCurrentSelection Returns Nothing. Description Method; draws a rectangular selection marquee relative to the Stage, using the specified coordinates. This is unlike document.getSelectionRect(), in which the rectangle is relative to the object being edited. This method is equivalent to dragging a rectangle with the arrow tool.
Returns Nothing. Description Method; sets the color, width, and style of the selected strokes. For information on changing the stroke in the toolbar and Property inspector, see document.setCustomStroke(). Example The following example sets the color of the stroke to red, the size to 3.25, and the type to dashed: fl.getDocumentDOM().setStroke("#ff0000", 3.25, "dashed"); document.setStrokeColor() Availability Flash MX 2004. Usage document.
Parameters size A floating point value from 0.25 to 10 that specifies the stroke size. The method ignores precision greater than two decimal places. Returns Nothing. Description Method; changes the stroke size of the selection to the specified size. For information on changing the stroke in the toolbar and Property inspector, see document.setCustomStroke(). Example The following example changes the stroke size for the selection to 5: fl.getDocumentDOM().setStrokeSize(5); document.
Parameters boundingRectangle A text rectangle object that specifies the new size within which the text item should flow. Returns A Boolean value: true if the size of at least one text field is changed; false otherwise. Description Method; changes the bounding rectangle for the selected text item to the specified size. This method causes the text to reflow inside the new rectangle; the text item is not scaled or transformed.
document.setTextString() Availability Flash MX 2004. Usage document.setTextString( text [, startIndex [, endIndex]] ) Parameters text A string of the characters to insert in the text field. An integer that specifies first character to replace. The first character position is 0 (zero). This parameter is optional. startIndex endIndex An integer that specifies the last character to replace. The first character position is 0 (zero). This parameter is optional.
Parameters transformationPoint A pair of floating point numbers that specifies values for each of the following elements: • Shapes: transformationPoint is set relative to document. 0,0 is the same as the Stage (upper left corner). • Symbols: transformationPoint is set relative to the symbol’s registration point. 0,0 is located at the registration point. • Text: transformationPoint is set relative to the text field. 0,0 is the upper left corner of text field.
The following example sets the silent property to false, indicating that the document is accessible: fl.getDocumentDOM().silent = false; document.skewSelection() Availability Flash MX 2004. Usage document.skewSelection( xSkew, ySkew [, whichEdge] ) Parameters xSkew A floating point number that specifies the amount of x by which to skew, measured in degrees. ySkew A floating point number that specifies the amount of y by which to skew, measured in degrees.
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(); document.space() Availability Flash MX 2004. Usage document.space( direction [, bUseDocumentBounds] ) Parameters direction A string that specifies the direction in which to space the objects in the selection.
document.straightenSelection() Availability Flash MX 2004. Usage document.straightenSelection() Parameters None. Returns Nothing. Description Method; straightens the currently selected strokes. This method is equivalent to using the Straighten button in the Tools panel. Example The following example straightens the curve of the current selection: fl.getDocumentDOM().straightenSelection(); document.swapElement() Availability Flash MX 2004. Usage document.
document.testMovie() Availability Flash MX 2004. Usage document.testMovie() Parameters None. Returns Nothing. Description Method; executes a Test Movie operation on the document. See document.canTestMovie() and document.testScene(). Example The following example tests the movie for the current document: fl.getDocumentDOM().testMovie(); document.testScene() Availability Flash MX 2004. Usage document.testScene() Parameters None. Returns Nothing.
document.timelines Availability Flash MX 2004. Usage document.timelines Description Read-only property; an array of Timeline objects (see Timeline object). See document.getTimeline() and document.currentTimeline. Example The following example gets the array of current Timelines in the active document and displays their names in the Output panel: var i = 0; var curTimelines = fl.getDocumentDOM().timelines; while(i < fl.getDocumentDOM().timelines.length){ alert(curTimelines[i].name); ++i; } document.
Example The following example traces the selected bitmap, using the specified parameters: fl.getDocumentDOM().traceBitmap(0, 500, 'normal', 'normal'); document.transformSelection() Availability Flash MX 2004. Usage document.transformSelection( a, b, c, d) Parameters a A floating point number that specifies the (0,0) element of the transformation matrix. b A floating point number that specifies the (0,1) element of the transformation matrix.
Example The following example ungroups the elements in the current selection: fl.getDocumentDOM().unGroup(); document.unlockAllElements() Availability Flash MX 2004. Usage document.unlockAllElements() Parameters None. Returns Nothing. Description Method; unlocks all locked elements on the currently selected frame. See element.locked. Example The following example unlocks all locked objects in the current frame: fl.getDocumentDOM().unlockAllElements(); document.viewMatrix Availability Flash MX 2004.
document.width Availability Flash MX 2004. Usage document.width Description Property; an integer that specifies the width of the document (Stage) in pixels. See document.height. Example The following example sets the width of the Stage to 400 pixels. fl.getDocumentDOM().width= 400; document.xmlPanel() Availability Flash MX 2004. Usage document.xmlPanel( fileURI ) Parameters fileURI A string that specifies the path, expressed as a file://URL, to the XML file defining the controls in the panel.
CHAPTER 3 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 drawingLayer.beginFrame() before you call any other drawingLayer methods.
Parameters persistentDraw A Boolean value (optional). If set to true, it indicates that the drawing in the last frame remains on the Stage until a new beginDraw() or beginFrame() call is made. (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.
drawingLayer.cubicCurveTo() Availability Flash MX 2004. Usage drawingLayer.cubicCurveTo(x1Ctrl, y1Ctrl, x2Ctl, y2Ctl, xEnd, yEnd) Parameters x1Ctl A floating-point value that is the x location of the first control point. y1Ctl A floating-point value that is the y location of the first control point. x2Ctl A floating-point value that is the x position of the middle control point. y2Ctl A floating-point value that is the y position of the middle control point.
Description Method; draws a quadratic curve segment starting at the current drawing position and ending at a specified point. You typically use this method only when creating extensible tools. Example The following example draws a quadratic curve using the specified control points: fl.drawingLayer.curveTo(0, 0, 2, 0); drawingLayer.drawPath() Availability Flash MX 2004. Usage drawingLayer.drawPath(path) Parameters path A Path object to draw. Returns Nothing.
Example The following example exits drawing mode: fl.drawingLayer.endDraw(); drawingLayer.endFrame() Availability Flash MX 2004. Usage drawingLayer.endFrame() 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() and drawingLayer.endFrame(). The next call to drawingLayer.beginFrame() will erase whatever was drawn in this group of drawing commands.
drawingLayer.moveTo() Availability Flash MX 2004. Usage drawingLayer.moveTo(x, y) Parameters x 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. y Returns Nothing. Description Method; sets the current drawing position. You typically use this method only when creating extensible tools.
drawingLayer.setColor() Availability Flash MX 2004. Usage drawingLayer.setColor(color) Parameters color A color that is specified by a string, integer, or hexadecimal value. Returns Nothing. Description Method; sets the color of subsequently drawn data. Applies only to persistent data. To use this method, the parameter passed to drawingLayer.beginDraw() must be set to true. You typically use this method only when creating extensible tools.
CHAPTER 3 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 edge.getControl() Method; gets a point object set to the location of the specified control point of the edge. edge.getHalfEdge() Method; returns a HalfEdge object. edge.setControl() Method; sets the position of the control point of the edge. edge.
Example The following example stores the first control point of the specified shape in the pt variable: var shape = fl.getDocumentDOM().selection[0]; var pt = shape.edges[0].getControl(0); edge.getHalfEdge() Availability Flash MX 2004. Usage edge.getHalfEdge(index) Parameters An integer that specifies which half edge to return. The value of index must be either 0 for the first half edge or 1 for the second half edge. index Returns A HalfEdge object. Description Method; returns a HalfEdge object.
edge.isLine Availability Flash MX 2004. Usage edge.isLine Description Read-only property; an integer with a value of 0 or 1. A value of 1 indicates that the edge is a straight line. In that case, the middle control point bisects the line joining the two end points. 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.
Example The following example sets the beginning control point of the specified edge to the (0, 1) coordinates: x = 0; y = 1; var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit(); shape.edges[0].setControl(0, x, y); shape.endEdit(); edge.splitEdge() Availability Flash MX 2004. Usage edge.splitEdge( t ) Parameters t 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.
CHAPTER 3 Objects Effect object Availability Flash MX 2004. Description This is a single effect descriptor object. The fl.activeEffect and the fl.effects properties contain this type of object. The Effect object represents an instance of a Timeline effect. Property summary for the Effect object In addition to the properties listed in the following table, Effect objects can also have user-defined parameters, which must be specified in the same XML file that specifies the effect.effectName and effect.
effect.groupName Availability Flash MX 2004. Usage effect.groupName Description Read-only property; a string that represents the name of the effect group used for the hierarchical Context menu for effects. If this value is an empty string, the effect appears ungrouped at the top level of the Context menu. The group name and effect name are specified in the XML file for the effect. Example The following example stores the group name of the current effect in the efGroupName variable: var efGroupName = fl.
Description Read-only property; a string that specifies the type of symbol to create during the initial application of the effect. The supported types are: "graphic", "movie clip", and "button". If a symbol type was not specified when the effect was created, the default value is "graphic". Example The following example stores the symbol type for the current effect in the efType variable: var efType = fl.activeEffect.symbolType; effect.useXMLToUI Availability Flash MX 2004. Usage effect.
CHAPTER 3 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().frames[0].layers[0].elements[0]; Method summary for the Element object The following methods are available for the Element object: Method Description element.getPersistentData() Retrieves the value of the data specified by the name parameter. element.
element.depth Availability Flash MX 2004. Usage element.depth Description Read-only property; an integer that has a value greater than 0 for the depth of the object in the view. The drawing order of objects on the Stage specifies which one is on top of the others. Object order can also be managed with the Modify > Arrange menu item. Example The following example displays the depth of the specified element in the Output panel: // select an object then run this script fl.
var elt = elts[x]; fl.trace("Element "+ x +" Name = " + elt.name + " Type = " + elt.elementType + " location = " + elt.left + "," + elt.top + " Depth = " + elt.depth); } element.getPersistentData() Availability Flash MX 2004. Usage element.getPersistentData( name ) Parameters name A string that identifies the data to be returned. Returns The data specified by the name parameter, or 0 if the data doesn’t exist. Description Method; retrieves the value of the data specified by the name parameter.
Returns A Boolean value: true if the specified data is attached to the object; false otherwise. Description Method; determines whether the specified data has been attached to the specified element. Only symbols and bitmaps support persistent data. Example See 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. Note: Do not use this property to resize a text field.
fl.trace("Left (before) = " + sel.left); fl.getDocumentDOM().moveSelectionBy({x:100, y:0}); fl.trace("Left (after) = " + sel.left); See the element.elementType example. element.locked Availability Flash MX 2004. Usage element.locked Description Property; a Boolean value: true if the element is locked; false otherwise. If the value of element.elementType is "shape", this property is ignored.
element.name Availability Flash MX 2004. Usage element.name Description Property; a string that specifies the name of the element, normally referred to as the Instance name. If the value of element.elementType is "shape", this property is ignored. 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 element.elementType example. element.
Parameters name A string that specifies the name to associate with the data. This name is used to retrieve the data. type A string that defines the type of the data. The allowable values are "integer", and "byteArray". "integerArray", "double", "doubleArray", "string", value Specifies the value to associate with the object. The data type of value depends on the value of the type parameter. The specified value should be appropriate to the data type specified by the type parameter. Returns Nothing.
element.width Availability Flash MX 2004. Usage element.width Description Property; a float value that specifies the width of the element in pixels. Note: Do not use this property to resize a text field. Instead, select the text field and use document.setTextRectangle(). Using this property with a text field scales the text. Example The following example sets the width of the specified element to 100: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].
EmbeddedVideoInstance object Inheritance CHAPTER 3 Objects Element object > Instance object > EmbeddedVideoInstance object Availability Flash MX 2004. Description The EmbeddedVideoInstance object is a subclass of Instance object. There are no unique methods or properties of EmbeddedVideoInstance.
CHAPTER 3 Objects Fill object Availability Flash MX 2004. Description This object contains all the properties of the Fill color setting of the toolbar 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 fill.color A color string in hexadecimal format, such as #rrggbb, or an integer containing the color value. fill.colorArray An array of colors in gradient.
fill.colorArray Availability Flash MX 2004. Usage fill.colorArray Description Property; an array of colors in gradient. This property is available only if the value of the fill.style property is either "radialGradient" or "linearGradient". Example The following example displays the color array of the current selection, if appropriate, in the Output panel. var fill = fl.getDocumentDOM().getCustomFill(); if(fill.style == "linearGradient" || fill.style == "radialGradient") alert(fill.colorArray); fill.
fill.posArray = [0, 100, 200]; fl.getDocumentDOM().setCustomFill( fill ); fill.style Availability Flash MX 2004. Usage fill.style Description Property; a string that specifies the fill style. Valid values are: "solid", "linearGradient", "radialGradient", and "noFill". If an object has no fill, this property has a value of "noFill". If this value is "linearGradient" or "radialGradient", the properties fill.colorArray and are also available. fill.
CHAPTER 3 Objects flash object Availability Flash MX 2004. Description The flash object represents the Flash application. Method summary for the flash object The following methods can be used with the flash object. Method Description fl.browseForFileURL() Opens a File Open or File Save system dialog box and lets the user specify a file to be opened or saved. fl.closeAll() Closes all open documents, displaying the Save As dialog box for any documents that were not previously saved. fl.
Method Description fl.saveDocumentAs() Displays the Save As dialog box for the specified document. fl.setActiveWindow() Sets the active window to be the specified document. fl.trace() Sends a text string to the Output panel. Property summary for the flash object The following properties can be used with the flash object. 162 Properties Description fl.activeEffect Read-only; the Effect object for the current effect being applied. fl.
fl.activeEffect Availability Flash MX 2004. Usage fl.activeEffect Description Read-only property; the Effect object for the current effect being applied. For a list of properties available to fl.activeEffect, see “Property summary for the Effect object” on page 146. Example The following example stores an object that represents the current effect in the ef variable. var ef = fl.activeEffect; fl.browseForFileURL() Availability Flash MX 2004. Usage fl.
var fileURL = fl.browseForFileURL("open", "Select file"); var doc = fl.openDocument(fileURL); fl.closeAll() Availability Flash MX 2004. Usage fl.closeAll() Parameters None. Returns Nothing. Description Method; closes all open documents, displaying the Save As dialog box for any documents that were not previously saved. The method prompts the user, if necessary, but does not terminate the application. See also fl.closeDocument(). Example The following code closes all open documents. fl.closeAll(); fl.
Description Method; closes the specified document. See also fl.closeAll(). Example The following example illustrates two ways of closing a document. //closes the specified document and prompts to save changes fl.closeDocument(fl.documents[0]); fl.closeDocument(fl.documents[0] , true); //use of true is optional //closes the specified document without prompting to save changes fl.closeDocument(fl.documents[0], false); fl.componentsPanel Availability Flash MX 2004. Usage fl.
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 in a URI format (file:///). See also fl.configDirectory. Example The following example runs a specified script. Using fl.configURI lets you specify the location of the script without knowing which platform the script is running on. // to run a command in your commands menu change "Test.
//create a Form Application document fl.createDocument("application"); fl.createNewDocList Availability Flash MX 2004. Usage fl.createNewDocList Description Read-only property; an array of strings that represent the various types of documents that can be created. Example The following example displays the types of documents that can be created in the Output panel. fl.trace("Number of choices " + fl.createNewDocList.length); for (i = 0; i < fl.createNewDocList.length; i++) fl.trace("choice: " + fl.
Description Read-only property; an array of strings that represent the various types of templates that can be created. Example The following example displays the types of templates that can be created in the Output panel. fl.trace("Number of template types: " + fl.createNewTemplateList.length); for (i = 0; i < fl.createNewTemplateList.length; i++) fl.trace("type: " + fl.createNewTemplateList[i]); fl.documents Availability Flash MX 2004. Usage fl.
fl.effects Availability Flash MX 2004. Usage fl.effects Description Read-only property; an array of Effect objects, based on XML parameter file. These are not effects, but a description of effects. The array length corresponds to the number of effects (based on the XML parameter definition files, not the number of JSFL implementation files) registered when the program opens. Example To return the first registered effect, use the following: ef = fl.effects[0] fl.
fl.fileExists() Availability Flash MX 2004. Usage fl.fileExists( fileURI ) Parameters fileURI A string that contains the path to the file. Returns A Boolean value: true if the file exists on disk; false otherwise. Description Method; checks whether a file already exists on disk. Example The following example outputs true or false to the Output panel for each specified file, depending on whether the file exists. alert(fl.fileExists("file:///C|/example.fla")); alert(fl.fileExists("file:///C|/example.
fl.getDocumentDOM() Availability Flash MX 2004. Usage fl.getDocumentDOM() Parameters None. Returns A Document object, or null if no documents are open. Description Method; retrieves the DOM (Document object) of the currently active document (FLA file). If one or more documents are open but a document is not currently focused (for example, a JSFL file is focused) , retrieves the DOM of the most recently active document.
Example The following example converts a URL to UTF-8 so the player can load it. var url = MMExecute( "fl.mapPlayerURL(" + myURL + ", false);" ); mc.loadMovie( url); fl.Math Availability Flash MX 2004. Usage fl.Math Description Read-only property; the Math object provides methods for matrix and point operations. Example The following shows the transformation matrix of the selected object, and its inverse. //Select an element on the stage, then run this script var mat =fl.getDocumentDOM().selection[0].
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 authoring tool manages. This array corresponds to the array in the fl.mruRecentFileList property. Example The following example displays the number of recently opened files, and the type of each file, in the Output panel. fl.trace("Number of recently opened files: " + fl.mruRecentFileListType.length); for (i = 0; i < fl.
Example The following example opens a file named Document.fla that is stored in the root directory of the C drive, stores a Document object representing that document in the doc variable, and sets the document to be the currently selected document. That is, until focus is changed, fl.getDocumentDOM() refers to this document. var doc = fl.openDocument("file:///c|/Document.fla"); fl.openProject() Availability Flash MX 2004. Usage fl.
Description Method; opens a script (JSFL, AS, ASC) or other file (XML, TXT) in the Flash text editor. Example The following example opens a file named my_test.jsfl that is stored in the /temp directory of the C drive. fl.openScript("file:///c|/temp/my_test.jsfl"); fl.outputPanel Availability Flash MX 2004. Usage fl.outputPanel Description Read-only property; reference to the outputPanel object. Example See outputPanel object. fl.quit() Availability Flash MX 2004. Usage fl.
fl.quit(true); // true is optional //quit without saving any files fl.quit(false); fl.reloadEffects() Availability Flash MX 2004. Usage fl.reloadEffects() Parameters None. Returns Nothing. Description Method; reloads all effects descriptors defined in the user’s Configuration Effects folder. This permits you to rapidly change the scripts during development, and it provides a mechanism to improve the effects without relaunching the application.
Example The following example is a one-line script that you can place in the Commands folder. When you need to reload the toolbar, go to the Commands menu and execute the script. fl.reloadTools(); fl.revertDocument() Availability Flash MX 2004. Usage fl.revertDocument( documentObject ) Parameters documentObject A Document object. If documentObject refers to the active document, the Document window might not revert until the script that calls this method finishes executing.
Returns If funcName is specified, returns the function's result as a string. Otherwise, nothing is returned. Description Method; executes a JavaScript file. If a function is specified as one of the arguments, it runs the function and also any code in the script that is not within the function. The rest of the code in the script runs before the function is run. Example Suppose there is a script file named testScript.jsfl in drive C: and its contents are as follows: function testFunct(num, minNum) { fl.
Description Method; saves all open documents, displaying the Save As dialog box for any documents that were not previously saved. See also fl.saveDocumentAs(), fl.saveDocument(), document.save(), and document.saveAndCompact(). Example The following example saves all open documents. fl.saveAll(); fl.saveDocument() Availability Flash MX 2004. Usage fl.saveDocument( document [, fileURI] ) Parameters A Document object that specifies the document to be saved.
Parameters A Document object that specifies the document to save. If document is null, the active document is saved. document Returns A Boolean value: true if the Save As operation completes successfully; false otherwise. Description Method; displays the Save As dialog box for the specified document. See also fl.saveDocument(), fl.saveAll(), document.save(), and document.saveAndCompact().
fl.tools Availability Flash MX 2004. Usage fl.tools Description Read-only property; an array of Tools objects (see Tools object). This property is used only when creating extensible tools. fl.trace() Availability Flash MX 2004. Usage fl.trace( message ) Parameters message A string that appears in the Output panel. Returns Nothing. Description Method; sends a text string to the Output panel. This method works in the same way as outputPanel.trace() and the trace() statement in ActionScript.
Example The following example displays the version of the authoring tool in the Output panel. alert( fl.version ); // e.g. WIN 7,0,0,380 fl.xmlui Availability Flash MX 2004. Usage fl.xmlui Description Read-only property; an XMLUI object. This property lets you get and set XMLUI properties in a XMLUI dialog box and lets you accept or cancel the dialog box programmatically. Example See XMLUI object.
folderItem object Inheritance CHAPTER 3 Objects 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.
fontItem object Inheritance CHAPTER 3 Objects 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.
CHAPTER 3 Objects Frame object Availability Flash MX 2004. Description The Frame object represents frames in the layer. Property summary for the Frame object The following properties can be used with the Frame object: Property Description frame.actionScript Property; a string representing ActionScript code. frame.duration Read-only; an integer that represents the number of frames in a frame sequence. frame.elements Read-only; an array of Element objects (see Element object). frame.
Property Description frame.soundLibraryItem Property; a library item (see SoundItem object) used to create a sound. frame.soundLoop Property; an integer value that specifies the number of times a sound that is attached directly to a frame (frame.soundLibraryItem) plays. frame.soundLoopMode Property; a string that specifies whether a sound that is attached directly to a frame (frame.soundLibraryItem) should play a specific number of times or loop indefinitely. frame.
Description Read-only property; an integer that represents the number of frames in a frame sequence. Example The following example stores the number of frames in a frame sequence that starts at first frame in the top layer in the frameSpan variable: var frameSpan = fl.getDocumentDOM().getTimeline().layers[0].frames[0].duration; frame.elements Availability Flash MX 2004. Usage frame.elements Description Read-only property; an array of Element objects (see Element object).
Example The following example sets the name of the first frame in the top layer to "First Frame" and then sets its label to "comment": fl.getDocumentDOM().getTimeline().layers[0].frames[0].name = 'First Frame'; fl.getDocumentDOM().getTimeline().layers[0].frames[0].labelType = 'comment'; frame.motionTweenOrientToPath Availability Flash MX 2004. Usage frame.
frame.motionTweenRotateTimes Availability Flash MX 2004. Usage frame.motionTweenRotateTimes Description Property; an integer that specifies the number of times the tweened element rotates between the starting keyframe and the next keyframe. Example The following example rotates the element in this frame counter-clockwise three times by the time it reaches the next keyframe: fl.getDocumentDOM().getTimeline().layers[0].frames[0].motionTweenRotate = "counter-clockwise"; fl.getDocumentDOM().getTimeline().
frame.motionTweenSync Availability Flash MX 2004. Usage frame.motionTweenSync Description Property; a Boolean value; if set to true, synchronizes the animation of the tweened object with the main Timeline. Example The following example specifies that tweened object should be synchronized with the Timeline: fl.getDocumentDOM().getTimeline().layers[0].frames[0].motionTweenSync = true; frame.name Availability Flash MX 2004. Usage frame.
frame.soundEffect Availability Flash MX 2004. Usage frame.soundEffect Description Property; a string that specifies effects for a sound that is attached directly to a frame (frame.soundLibraryItem). Acceptable values are "none", "left channel", "right channel", "fade left to right", "fade right to left", "fade in", "fade out", and "custom". Example The following example specifies that the sound attached to the first frame should fade in: fl.getDocumentDOM().getTimeline().layers[0].frames[0].
Description Property; an integer value that specifies the number of times a sound that is attached directly to a frame (frame.soundLibraryItem) plays. If you want to specify a value for this property, set frame.soundLoopMode to "repeat". Example See frame.soundLoopMode. frame.soundLoopMode Availability Flash MX 2004. Usage frame.soundLoopMode Description Property; a string that specifies whether a sound that is attached directly to a frame (frame.
frame.soundSync Availability Flash MX 2004. Usage frame.soundSync Description Property; a string that specifies the sync behavior of a sound that is attached directly to a frame (frame.soundLibraryItem). Acceptable values are "event", "stop", "start", and "stream". Example The following example specifies that a sound should stream: fl.getDocumentDOM().getTimeline().layers[0].frames[0].soundSync = 'stream'; frame.startFrame Availability Flash MX 2004. Usage frame.
Description Property; an integer that specifies the amount of easing that should be applied to the tweened object. Valid values are -100 to 100. To begin the motion tween slowly and accelerate the tween toward the end of the animation, use a value between -1 and -100. To begin the motion tween rapidly and decelerate the tween toward the end of the animation, use a positive value between 1 and 100.
CHAPTER 3 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 visit all the half edges around a contour of a shape, and return to the original half edge. Half edges are ordered.
Description Method; gets the Edge object for the halfEdge object. Example The following example illustrates getting an edge and a half edge for the specified shape. var shape = fl.getDocumentDOM().selection[0]; var halfEdge = shape.edges[0].getHalfEdge(0); var edge = halfEdge.getEdge(); halfEdge.getNext() Availability Flash MX 2004. Usage halfEdge.getNext() Parameters None. Returns A halfEdge object. Description Method; gets the next half edge on the current contour.
Description Method; gets the halfEdge object on the other side of the edge. Example The following example stores the half edge opposite hEdge in the otherHalfEdge variable: var shape = fl.getDocumentDOM().selection[0]; var hEdge = shape.edges[0].getHalfEdge(0); var otherHalfEdge = hEdge.getOppositeHalfEdge(); halfEdge.getPrev() Availability Flash MX 2004. Usage halfEdge.getPrev() Parameters None. Returns A halfEdge object. Description Method; gets the preceding halfEdge object on the current contour.
Description Method; gets the Vertex object at the head of the halfEdge object. Example The following example stores the Vertex object at the head of hEdge in the vertex variable: var var var var shape = fl.getDocumentDOM().selection[0]; edge = shape.edges[0]; hEdge = edge.getHalfEdge(0); vertex = hEdge.getVertex(); halfEdge.id Availability Flash MX 2004. Usage halfEdge.id Description Read-only property; a unique integer identifier for the halfEdge object.
CHAPTER 3 Objects Instance object Inheritance Element object > Instance object Availability Flash MX 2004. Description Instance is a subclass of the Element object. Property summary for the Instance object In addition to all of the Element object properties, Instance has the following properties: Property Description instance.instanceType Read-only; a string that represents the type of Instance. instance.libraryItem Library item used to instantiate this instance. instance.
Example The following example changes the selected symbol to refer to the first item in the library: fl.getDocumentDOM().selection[0].libraryItem = fl.getDocumentDOM().library.
CHAPTER 3 Objects Item object Availability Flash MX 2004. Description The Item object is an abstract base class. Anything in the library derives from Item. See also library object. Method summary for the Item object The following methods are available for the Item object. Method Description item.addData() Method; adds specified data to a library item. item.getData() Method; retrieves the value of the specified data. item.hasData() Method; determines whether the library item has the named data.
item.addData() Availability Flash MX 2004. Usage item.addData( name, type, data ) Parameters name A string that specifies the name of the data. type A string that specifies the type of data. Valid types are "integer", "integerArray", and "byteArray". "double", "doubleArray", "string", The data to add to the specified library item. The type of data depends on the value of the type parameter. For example, if type is "integer", the value of data must be an integer, and so on. data Returns Nothing.
Example The following example gets the value of the data named myData from the first item in the library and stores it in the variable libData. var libData = fl.getDocumentDOM().library.items[0].getData( "myData" ); item.hasData() Availability Flash MX 2004. Usage item.hasData( name ) Parameters name A string that specifies the name of the data to check for in the library item. Returns A Boolean value: true if the specified data exists; false otherwise.
item.linkageClassName Availability Flash MX 2004. Usage item.linkageClassName Description Property; a string that specifies the ActionScript 2.0 class that will be associated with the symbol. For this property to be defined, the item.linkageExportForAS and/or item.linkageExportForRS properties must be set to true, and the item.linkageImportForRS property must be set to false. Example The following example specifies that the ActionScript 2.
Description Property; a Boolean value. If true, the item is exported for runtime sharing. This property can be set to true only if item.linkageImportForRS is set to false. Also, the properties item.linkageIdentifier and item.linkageURL must be defined. Example The following example sets this property for the specified library item: fl.getDocumentDOM().library.items[0].linkageExportForRS = true; item.linkageExportInFirstFrame Availability Flash MX 2004. Usage item.
item.linkageImportForRS Availability Flash MX 2004. Usage item.linkageImportForRS Description Property; a Boolean value: if true, the item is imported for runtime sharing. If this property is set to true, both item.linkageExportForAS and item.linkageExportForRS must be set to false. Also, you must specify an identif1ier (item.linkageIdentifier) and a URL (item.linkageURL). Example The following example sets this property to true for the specified library item: fl.getDocumentDOM().library.items[0].
Description Method; a string that specifies the name of the library item, which includes the folder structure. For example, if Symbol_1 is inside a folder called Folder_1, the name property of Symbol_1 is "Folder_1/Symbol_1". Example The following example shows the name of the specified library item in the Output panel: fl.trace(fl.getDocumentDOM().library.items[0].name); item.removeData() Availability Flash MX 2004. Usage item.
CHAPTER 3 Objects Layer object Availability Flash MX 2004. Description The Layer object represents a layer in the Timeline. The timeline.layers property contains an array of Layer objects, which can be accessed by fl.getDocumentDOM().getTimeline().layers. Property summary for the Layer object The following properties are available for the Layer object: Property Description layer.color Property; a string that specifies the color assigned to outline the layer. layer.
Example The following example stores the value of the first layer in the colorValue variable: var colorValue = fl.getDocumentDOM().getTimeline().layers[0].color; The following example shows three ways to set the color of the first layer to red: fl.getDocumentDOM().getTimeline().layers[0].color=16711680; fl.getDocumentDOM().getTimeline().layers[0].color="#ff0000"; fl.getDocumentDOM().getTimeline().layers[0].color=0xFF0000; layer.frameCount Availability Flash MX 2004. Usage layer.
} } layer.height Availability Flash MX 2004. Usage layer.height Description Property; an integer that specifies the percentage layer height; equivalent to the Layer height value in the Layer Properties dialog box. Acceptable values represent percentages of the default height: 100, 200, or 300. Example The following example stores the percentage value of the first layer’s height setting: var layerHeight = fl.getDocumentDOM().getTimeline().layers[0].
Description Property; a Boolean value that specifies the locked status of the layer. If set to true, the layer is locked. The default value is false. Example The following example stores the Boolean value for the status of the first layer in the lockStatus variable: var lockStatus = fl.getDocumentDOM().getTimeline().layers[0].locked; The following example sets the status of the first layer to unlocked: fl.getDocumentDOM().getTimeline().layers[0].locked = false; layer.name Availability Flash MX 2004.
layer.parentLayer Availability Flash MX 2004. Usage layer.parentLayer Description Property; a Layer object that represents the layer’s containing folder, guiding, or masking layer. Acceptable values for the parent layer are a folder, guide, or mask layer that precedes the layer, or the parentLayer of the preceding or following layer. Setting the layer’s parentLayer does not move the layer’s position in the list; trying to set a layer’s parentLayer to a layer that would require moving it has no effect.
CHAPTER 3 Objects library object Availability Flash MX 2004. Description The library object represents the Library panel. It is a property of the Document object (see document.library) and can be accessed by fl.getDocumentDOM().library. The library object contains an array of items of different types, including symbols, bitmaps, sounds, and video. Method summary for the library object The following methods are available for the library object: Method Description library.
Method Description library.selectAll() Method; selects or deselects all items in the library. library.selectItem() Method; selects a specified library item. library.selectNone() Method; deselects all the library items. library.setItemProperty() Method; sets the property for all selected library items (ignoring folders). library.updateItem() Method; updates the specified item. Property summary for the library object The following property is available for the library object.
library.addNewItem() Availability Flash MX 2004. Usage library.addNewItem( type [, namePath] ) Parameters type A string that specifies the type of item to create. The only acceptable values for type are "video", "movie clip", "button", "graphic", "bitmap", and "folder" (so, for example, you cannot add a sound to the library with this method). Specifying a folder path is the same as using before calling this method. library.newFolder() A string that specifies the name of the item to be added.
Description Method; deletes the current items or a specified item from the Library panel. This method can affect multiple items if several are selected. Example The following example deletes the currently selected item: fl.getDocumentDOM().library.deleteItem(); The following example deletes the item Symbol_1 from the library folder Folder_1: fl.getDocumentDOM().library.deleteItem("Folder_1/Symbol_1"); library.duplicateItem() Availability Flash MX 2004. Usage library.
Parameters A string that specifies the name of the item. If the item is in a folder, you can specify its name and path using slash notation. If namePath is not specified, the single selected library item opens in Edit mode. If none or more than one item in the library is currently selected, the first scene in the main Timeline appears for editing. This parameter is optional. namePath Returns A Boolean value: true if the specified item exists and can be edited; false otherwise.
library.findItemIndex() Availability Flash MX 2004. Usage library.findItemIndex( namePath ) Parameters A string that specifies the name of the item. If the item is in a folder, you can specify its name and path using slash notation. namePath Returns An integer value representing the item’s zero-based index value. Description Method; returns the library item’s index value (zero-based). The library index is flat, so folders are considered part of the main index.
library.getItemType() Availability Flash MX 2004. Usage library.getItemType( [ namePath ] ) Parameters A string that specifies the name of the item. If the item is in a folder, specify its name and path using slash notation. If namePath is not specified, Flash provides the type of the current selection. If more than one item is currently selected and no namePath is provided, Flash ignores the command. This parameter is optional. namePath Returns A string value specifying the type of object.
var selItems = fl.getDocumentDOM().library.getSelectedItems(); selItems[0].sampleRate = "11 kHz"; library.importEmbeddedSWF() Availability Flash MX 2004. Usage library.importEmbeddedSWF( linkageName, swfData [, libName] ) Parameters linkageName swfData A string that provides the name of the SWF linkage of the root movie clip. An array of binary SWF data, which comes from an external library or DLL. libName A string that specifies the library name for the created item.
Description Method; checks to see if a specified item exists in the library. Example The following example displays true or false in a dialog box, depending on whether the item Symbol_1 exists in the Folder_1 library folder: alert(fl.getDocumentDOM().library.itemExists('Folder_1/Symbol_1')); library.items Availability Flash MX 2004. Usage library.items Description Property; an array of item objects in the library.
Description Method; moves the currently selected or specified library item to a specified folder. If the folderPath parameter is empty, the items move to the top level. Example The following example moves the item Symbol_1 to the library folder new and replaces the item in that folder with the same name: fl.getDocumentDOM().library.moveToFolder("new", "Symbol_1", true); library.newFolder() Availability Flash MX 2004. Usage library.
Returns A Boolean value: true if the name of the item changes successfully. If multiple items are selected, no names are changed, and the return value is false (to match UI behavior). Description Method; renames the currently selected library item in the Library panel. Example The following example renames the currently selected library item to new name: fl.getDocumentDOM().library.renameItem("new name"); library.selectAll() Availability Flash MX 2004. Usage library.
Parameters A string that specifies the name of the item. If the item is in a folder, you can specify its name and path using slash notation. namePath bReplaceCurrentSelection A Boolean value that specifies whether to replace the current selection or add the item to the current selection. The default value is true (replace current selection). This parameter is optional. bSelect A Boolean value that specifies whether to select or deselect an item. The default value is true (select).
Example The following examples deselect all the items in the library: fl.getDocumentDOM().library.selectNone(); fl.getDocumentDOM().library.selectAll(false); library.setItemProperty() Availability Flash MX 2004. Usage library.setItemProperty( property, value ) Parameters A string that is the name of the property to set. For a list of properties, see the Property summary for the Item object and property summaries for its subclasses.
Returns A Boolean value: true if Flash updated the item successfully; false otherwise. Description Method; updates the specified item. Example The following example displays a dialog box that shows whether the currently selected item is updated (true) or not (false): alert(fl.getDocumentDOM().library.
CHAPTER 3 Objects LinkedVideoInstance object Inheritance Element object > Instance object > LinkedVideoInstance object Availability Flash MX 2004. Description The LinkedVideoInstance object is a subclass of the Instance object. There are no unique methods or properties of LinkedVideoInstance.
CHAPTER 3 Objects Math object Availability Flash MX 2004. Description The Math object is available as a read-only property of the flash object; see fl.Math. This object provides methods that perform common mathematical operations. Method summary for the Math object The following methods are available for the Math object: Method Description Math.concatMatrix() Performs a matrix concatenation and returns the result. Math.invertMatrix() Returns the inverse of the specified matrix. Math.
Math.invertMatrix() Availability Flash MX 2004. Usage Math.invertMatrix(mat) Parameters mat Indicates the Matrix object to invert. It must have the following fields: a, b, c, d, tx, and ty. Returns A Matrix object that is the inverse of the original matrix. Description Method; returns the inverse of the specified matrix.
CHAPTER 3 Objects Matrix object Availability Flash MX 2004. Description The Matrix object represents a transformation matrix. Property summary for the Matrix object The following properties are available for the Matrix object: Property Description matrix.a Property; a floating-point value that specifies the (0,0) element in the transformation matrix. matrix.b Property; a floating-point value that specifies the (0,1) element in the matrix. matrix.
You can rotate an object by setting the a, b, c, and d matrix properties relative to one another, where a = d and b = -c. For example, values of 0.5, 0.8, -0.8, and 0.5 rotate the object 60º: var mat = fl.getDocumentDOM().selection[0].matrix; mat.a = 0.5; mat.b = 0.8; mat.c = 0.8*(-1); mat.d = 0.5; fl.getDocumentDOM().selection[0].matrix = mat; You can set a = d = 1 and c = b = 0 to reset the object back to its original shape. matrix.b Availability Flash MX 2004. Usage matrix.
Example See the matrix.b example. matrix.d Availability Flash MX 2004. Usage matrix.d Description Property; a floating-point value that specifies the (1,1) element in the matrix. This value represents the scale factor of the object’s y-axis. Example See matrix.a. 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.
Description Property; a floating-point value that specifies the y-axis location of a symbol’s registration point or the center of a shape. It defines the y translation of the transformation. You can move an object by setting the matrix.tx and matrix.ty properties. Example See the matrix.tx example.
CHAPTER 3 Objects outputPanel object Availability Flash MX 2004. Description This object represents the Output panel, which displays troubleshooting information such as syntax errors. To access this object, use fl.outputPanel (or flash.outputPanel). Method summary for the outputPanel object The outputPanel object uses the following methods. Method Description outputPanel.clear() Method; clears the contents of the Output panel. outputPanel.
outputPanel.save() Availability Flash MX 2004. Usage outputPanel.save(fileURI [, bAppendToFile]) Parameters fileURI A string that specifies the local file to contain the Output panel’s contents. optional parameter, if it has a value of true, appends the Output panel’s contents to the output file. If bAppendToFile is false, the method overwrites the output file if it already exists. The default value is false. bAppendToFile Returns Nothing.
Description Method; adds a line to the contents of the Output panel, terminated by a new line. This method shows the Output panel if it is not already visible. The outputPanel.trace() method duplicates the functionality of fl.trace(). Example The following example writes "hello world" to the Output panel: fl.outputPanel.
CHAPTER 3 Objects Parameter object Availability Flash MX 2004. Description The Parameter object type is accessed from the screen.parameters array (which corresponds to the screen Property inspector in the Flash authoring tool) or by the componentInstance.parameters array (which corresponds to the component Property inspector in the authoring tool). Method summary for the Parameter object The following methods are available for the Parameter object: Method Description parameter.
Description Property; a string that specifies the category property for the screen parameter or componentInstance parameter. This property provides an alternative way of presenting a list of parameters. This functionality is not available through the Flash user interface. parameter.insertItem() Availability Flash MX 2004. Usage parameter.insertItem(index, name, value, type) Parameters index A zero-based integer index that indicates where the item will be inserted in the list, object, or array.
Description Property; the value of the selected list item. This property is valid only if the valueType parameter is "List". Example The following example sets the first parameter for a Slide, which is the autoKeyNav parameter. To set the parameter to one of its acceptable values (true, false, or inherit) parameter.listIndex is set to the index of the item in the list (0 for true, 1 for false, 2 for inherit). var parms = fl.getDocumentDOM().screenOutline.screens[1].parameters; parms[0].
Description Method; removes an element of the list, object, or array type of a screen or component parameter. Example The following example removes the element at index 1 from the labelPlacement parameter of a component: // select an instance of a Button component on the Stage var parms = fl.getDocumentDOM().selection[0].parameters; var values = parms[2].value; fl.trace("--Original--"); for(var prop in values){ fl.trace("labelPlacement value = " + values[prop].value); } parms[2].
Description Property; corresponds to the Value field in the Parameters tab of the Component Inspector panel, in the component Property inspector, or in the screen Property inspector. The type of the value property is determined by the valueType property for the parameter (see parameter.valueType). parameter.valueType Availability Flash MX 2004. Usage parameter.valueType Description Read-only property; a string that indicates the type of the screen or component parameter.
CHAPTER 3 Objects Path object Availability Flash MX 2004. Description The Path object defines a sequence of line segments (straight, curved, or both), which you typically use when creating extensible tools. The following example shows an instance of a Path object being returned from the flash object: path = fl.drawingLayer.newPath(); See also the drawingLayer object. Method summary for the Path object The following methods are available for the Path object: Method Description path.
yAnchor A floating-point number that specifies the y position of the first control point. x2 A floating-point number that specifies the x position of the second control point. y2 A floating-point number that specifies the y position of the second control point. x3 A floating-point number that specifies the x position of the third control point. y3 A floating-point number that specifies the y position of the third control point.
Example The following example creates a new path, stores it in the myPath variable, and assigns the curve to the path: var myPath = fl.drawingLayer.newPath(); myPath.addCurve(0, 0, 10, 20, 20, 0); path.addPoint() Availability Flash MX 2004. Usage path.addPoint(x, y) Parameters x A floating-point value that specifies the x position of the point. y A floating-point value that specifies the y position of the point. Returns Nothing. Description Method; adds a point to the path.
Example The following example removes all points from a path stored in the myPath variable: var myPath = fl.drawingLayer.newPath(); myPath.clear(); path.close() Availability Flash MX 2004. Usage path.close() Parameters None. 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.
Description Method; creates a shape on the Stage by using the current stroke and fill settings. The path is cleared after the shape is created. This method has two optional parameters for suppressing the fill and stroke of the resulting shape object. If you omit these parameters or set them to false, the current values for fill and stroke are used. Example The following example creates a shape with the current fill and no stroke: var myPath = fl.drawingLayer.newPath(); myPath.
path.nPts Availability Flash MX 2004. Usage path.nPts Description Read-only property; an integer representing the number of points in the path. A new path has 0 points. Example The following example uses the Output panel to show the number of points in the path referenced by the myPath variable: var myPath = fl.drawingLayer.newPath(); var numOfPoints = myPath.nPts; fl.
CHAPTER 3 Objects Screen object Availability Flash MX 2004. Description The Screen object represents a single screen in a slide or form document. This object contains properties related to the slide or form. For access to the array of all Screen objects in the document, use the following code: fl.getDocumentDOM().screenOutline.screens Property summary for the Screen object The Screen object has the following properties: 248 Properties Description screen.
screen.accName Availability Flash MX 2004. Usage screen.accName Description Property; a string that is equivalent to the Name field in the Accessibility panel. Screen readers identify objects by reading the name aloud. Example The following example stores the value of the name of the object in the theName variable: var theName = fl.getDocumentDOM().screenOutline.screens[1].accName; The following example sets the name of the object to "Home Button": fl.getDocumentDOM().screenOutline.screens[1].
screen.description Availability Flash MX 2004. Usage screen.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 gets the description of the object and stores it in the theDescription variable: var theDescription = fl.getDocumentDOM().screenOutline.screens[1].description; The following example sets the description of the object to "This is Screen 1": fl.
screen.hidden Availability Flash MX 2004. Usage screen.hidden Description Property; a Boolean value that specifies whether the screen is visible. A screen with the hidden property set to true is not visible in any other screen. 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.
screen.name Availability Flash MX 2004. Usage screen.name Description Read-only property; a string that represents the name of the screen. Example The following example checks to see if the current document allows screens (because it is a slide or form document). Then, it assigns the name value of the first child screen in the array to the myName variable and opens the Output panel to show the name of the screen: var myChildren = new Array(); if(fl.getDocumentDOM().allowScreens) { var myName = fl.
screen.parameters Availability Flash MX 2004. Usage screen.parameters Description Read-only property; an array of ActionScript properties that are accessible from the screen Property inspector. Example The following example stores the parameters for the second screen in the outline to the parms variable and then assigns the "some value" value to the first property: var parms = fl.getDocumentDOM().screenOutline.screens[1].parameters; parms[0].value = "some value"; screen.
screen.prevScreen Availability Flash MX 2004. Usage screen.prevScreen Description Read-only property; an object that represents the previous peer screen in the parent’s childScreens array. If there isn’t a peer screen, the value is null. See also screen.nextScreen. 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().
screen.tabIndex Availability Flash MX 2004. Usage screen.tabIndex Description Property; equivalent to the Tab Index field in the Accessibility panel. This value lets you determine the order in which objects are accessed when the user presses the Tab key. Example The following example gets the tab index of the object: var theTabIndex = fl.getDocumentDOM().screenOutline.screens[1].tabIndex; The following example sets the tab index of the object to 1: fl.getDocumentDOM().screenOutline.screens[1].
CHAPTER 3 Objects ScreenOutline object Availability Flash MX 2004. Description The ScreenOutline object represents the group of screens in a slide or form document. The object is accessed by using fl.getDocumentDOM().screenOutline. The ScreenOutline object exists only if the document is a slide or form document, so before accessing the property, use document.allowScreens() to verify that a Screens document exists, as shown in the following example: if(fl.getDocumentDOM().allowScreens) { var myName = fl.
Method Description screenOutline.setScreenProperty() Method; lets the specified property with the specified value for the selected screens. screenOutline.setSelectedScreens() Method; selects the specified screens in the Screen Outline pane. Property summary for the ScreenOutline object You can use the following properties with the ScreenOutline object: Property Description screenOutline.currentScreen Property; a Screen object; the currently selected screen. screenOutline.
screenOutline.currentScreen Availability Flash MX 2004. Usage screenOutline.currentScreen Description Property; a Screen object, the currently selected screen. Example The following example stores the currentScreen object in the myScreen variable and then displays the name of that screen in the Output panel: var myScreen = fl.getDocumentDOM().screenOutline.currentScreen; fl.trace(myScreen.name); screenOutline.deleteScreen() Availability Flash MX 2004. Usage screenOutline.
screenOutline.duplicateScreen() Availability Flash MX 2004. Usage screenOutline.duplicateScreen( [screenName] ) Parameters screenName A string value that specifies the screen name to duplicate. If you don’t pass a value for screenName, the currently selected screen(s) are duplicated. This parameter is optional. Returns A Boolean value: true if the screen is successfully duplicated; false otherwise. Description Method; duplicates the currently selected screen(s) or a specified screen.
fl.trace(myArray[i].name) } screenOutline.insertNestedScreen() Availability Flash MX 2004. Usage screenOutline.insertNestedScreen( [ name [, referenceScreen [, screenTypeName ] ] ]) Parameters A string indicating the name of the new screen to insert. An empty name will insert a screen with a default screen name, such as Slide n or Form n (where n is the first available unique number). This parameter is optional.
referenceScreen A string indicating the name of the screen before the new screen. If this parameter is omitted, the new screen is inserted after the currently selected screen. If the referenceScreen parameter identifies a child screen, the new screen will be a peer of the child screen, and a child screen of the same parent. This parameter is optional. A string that specifies the screen type to attach to the new screen. The screen type and classname are set for this screen.
Example The following example moves screen slide1 to be the first child of slide2: fl.getDocumentDOM().screenOutline.moveScreen("slide1", "slide2", "firstChild"); screenOutline.renameScreen() Availability Flash MX 2004. Usage screenOutline.renameScreen( newScreenName [, oldScreenName [, bDisplayError] ] ) Parameters newScreenName A string that specifies the new name of the screen A string that specifies the name of the existing screen to change.
Example The following example displays the name of the first child of the first screen in the screen outline: fl.trace(fl.getDocumentDOM().screenOutline.rootScreen.childScreens[0].name); screenOutline.screens Availability Flash MX 2004. Usage screenOutline.screens Description Read-only property; the array of top level Screen objects contained in the document (see Screen object).
Example The following example sets the current screen to the screen named ChildOfSlide_1: fl.getDocumentDOM().screenOutline.setCurrentScreen("ChildOfSlide_1"); screenOutline.setScreenProperty() Availability Flash MX 2004. Usage screenOutline.setScreenProperty( property, value ) Parameters property value A string that specifies the property to set. The new value for the property. The type of value depends on the property being set.
Description Method; selects the specified screens in the screen outline. If multiple screens are specified, the screen with the last index value of the selection array is focused on the Stage. Example The following example deselects any currently selected screens, and then selects screens slide1, slide2, slide3, and slide4 in the screen outline: myArray = new Array("slide1", "slide2", "slide3", "slide4"); fl.getDocumentDOM().screenOutline.
CHAPTER 3 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. All Shape methods and properties that change a shape or any of its subordinate parts must be placed between shape.
Returns Nothing. Description Method; defines the start of an edit session. You must use this method before issuing any commands that change the Shape object or any of its subordinate parts. Example The following example takes the currently selected shape and removes the first edge in the edge array from it: var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit(); shape.deleteEdge(0); shape.endEdit(); shape.contours Availability Flash MX 2004. Usage shape.
Description Method; deletes the specified edge. You must call shape.beginEdit() before using this method. Example The following example takes the currently selected shape and removes the first edge in the edge array: var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit(); shape.deleteEdge(0); shape.endEdit(); shape.edges Availability Flash MX 2004. Usage shape.edges Description Read-only property; an array of Edge objects (see Edge object). shape.endEdit() Availability Flash MX 2004.
shape.isGroup Availability Flash MX 2004. Usage shape.isGroup Description Read-only property; if true, the shape is a group. Example The following example stores the first selected item object in the sel variable and then uses the element.elementType and shape.isGroup properties to test if the selected item is a group: var sel = fl.getDocumentDOM().selection[0]; var theShapeIsReallyAGroup = (sel.elementType == "shape") && sel.isGroup; shape.vertices Availability Flash MX 2004. Usage shape.
CHAPTER 3 Objects SoundItem object Inheritance Item object > SoundItem object Availability Flash MX 2004. Description The SoundItem object is a subclass of the Item object. It represents a library item used to create a sound. See also frame.soundLibraryItem. Property summary for the SoundItem object In addition to the Item object properties, the following properties are available for the SoundItem object: Property Description soundItem.
Description Property; a string that specifies the bit rate of a sound in the library. This property is available only for the MP3 compression type. Acceptable values are "8kbps", "16kbps", "20kbps", "24kbps", "32kbps", "48kbps", "56kbps", "64kbps", "80kbps", "112kbps", "128kbps", and "160kbps". The property is undefined for other compression types. Note: When an MP3 is imported to the library, the Use imported MP3 quality Export setting is checked by default.
The following example changes a selected item’s compression type to Speech: fl.getDocumentDOM().library.getSelectedItems()[0].compressionType = "Speech"; soundItem.convertStereoToMono Availability Flash MX 2004. Usage soundItem.convertStereoToMono Description Property; a Boolean value available only for MP3 and Raw compression types. Setting this to true converts a stereo sound to mono; false leaves it as stereo. For MP3 compression type, if soundItem.
Description Property; available only for ADPCM, Raw, and Speech compression types. This value sets the sample rate for the audio clip. Acceptable values are "5 kHz", "11 kHz", "22 kHz", and "44 kHz". Note: When an MP3 is imported to the library, the Use imported MP3 quality Export setting is checked by default. The sampleRate property cannot be set with this setting checked.
CHAPTER 3 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 Stroke Properties inspector. Using the Stroke object together with the document.setCustomStroke() method, you can change the stroke settings for the toolbar, the Properties Inspector, and the current selection.
Property Description stroke.waveHeight A string that specifies the wave height of a ragged line. stroke.waveLength A string that specifies the wave length of a ragged line. stroke.breakAtCorners Availability Flash MX 2004. Usage stroke.breakAtCorners Description Property; a Boolean value. This property is the same as the Sharp Corners setting in the custom Stroke Style dialog box. Example The following example sets the breakAtCorners property to true: var myStroke = fl.getDocumentDOM().
Description Property; a string that specifies type of hatching for the stroke. This property can be set only if stroke.style property is "hatched". Acceptable values are "straight", "slight curve", "medium curve", and "very curved". Example The following example sets the curve property, as well as others, for a stroke having the "hatched" style: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.curve = "straight"; myStroke.space = "close"; myStroke.
Description Property; an integer that specifies the lengths of the blank parts of a dashed line. This property is available only if the stroke.style property is set to "dashed". Example See stroke.dash1. stroke.density Availability Flash MX 2004. Usage stroke.density Description Property; a string that specifies the density of a stippled line. This property is available only if the stroke.style property is set to "stipple". Acceptable values are "very dense", "dense", "sparse", and "very sparse".
myStroke.density = "sparse"; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.dotSpace Availability Flash MX 2004. Usage stroke.dotSpace Description Property; an integer that specifies the spacing between dots in a dotted line. This property is available only if the stroke.style property is set to "dotted". Example The following example sets the dotSpace property to 3 for a stroke style of dotted: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "dotted"; myStroke.
stroke.jiggle Availability Flash MX 2004. Usage stroke.jiggle Description Property; a string that specifies the jiggle property of a hatched line. This property is available only if the stroke.style property is set to "hatched". Acceptable values are "none", "bounce", "loose", and "wild". Example The following example sets the jiggle property to "wild" for a stroke style of hatched: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.curve = "straight"; myStroke.
stroke.pattern Availability Flash MX 2004. Usage stroke.pattern Description Property; a string that specifies the pattern of a ragged line. This property is available only if the stroke.style property is set to "ragged". Acceptable values are "solid", "simple", "random", "dotted", "random dotted", "triple dotted", and "random triple dotted". Example The following example sets the pattern property to "random" for a stroke style of ragged: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.
stroke.space Availability Flash MX 2004. Usage stroke.space Description Property; a string that specifies the spacing of a hatched line. This property is available only if the stroke.style property is set to "hatched". Acceptable values are "very close", "close", "distant", and "very distant". Example The following example sets the space property to "close" for a stroke style of hatched: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "hatched"; myStroke.
Example The following example sets the stroke style to "ragged": var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "ragged"; fl.getDocumentDOM().setCustomStroke( myStroke ); stroke.thickness Availability Flash MX 2004. Usage stroke.thickness Description Property; an integer that specifies the stroke size. Example The following example sets the thickness property of the stroke to a value of 2: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.thickness = 2; fl.
stroke.waveHeight Availability Flash MX 2004. Usage stroke.waveHeight Description Property; a string that specifies the wave height of a ragged line. This property is available only if the stroke.style property is set to "ragged". Acceptable values are "flat", "wavy", "very wavy", and "wild". Example The following example sets the waveHeight property to "flat" for a stroke style of ragged: var myStroke = fl.getDocumentDOM().getCustomStroke(); myStroke.style = "ragged"; myStroke.
CHAPTER 3 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. Property summary for the SymbolInstance object In addition to the Instance object properties, the SymbolInstance object has the following properties: Property Description symbolInstance.accName A string that is equivalent to the Name field in the Accessibility panel.
Property Description symbolInstance.colorMode A string that specifies the color mode as identified in the symbol Property inspector Color pop-up menu. symbolInstance.colorRedAmount An integer that is part of the color transformation for the instance, equivalent to using the Color > Advanced setting in the Instance Property inspector. symbolInstance.
Example The following example stores the value for the Accessibility panel name of the object in the theName variable: var theName = fl.getDocumentDOM().selection[0].accName; The following example sets the value for the Accessibility panel name of the object to "Home Button": fl.getDocumentDOM().selection[0].accName = "Home Button"; symbolInstance.actionScript Availability Flash MX 2004. Usage symbolInstance.actionScript Description Property; a string that specifies the actions assigned to the symbol.
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.
Description Property; an integer that is part of the color transformation for the instance. This property is equivalent to using the Color > Advanced setting in the Instance Property inspector. Allowable values are from -255 to 255. symbolInstance.colorBluePercent Availability Flash MX 2004. Usage symbolInstance.colorBluePercent Description Property; an integer that is part of the color transformation for the instance.
Description Property; part of the color transformation for the instance. This property is equivalent to using the Color > Advanced setting in the Instance Property inspector (the percentage controls on the left of the dialog box). This value sets the green values by a specified percentage. Allowable values are from -100 to 100. Example The following example sets the colorGreenPercent of the selected symbol instance to 70: fl.getDocumentDOM().selection[0].colorGreenPercent = 70; symbolInstance.
symbolInstance.colorRedPercent Availability Flash MX 2004. Usage symbolInstance.colorRedPercent Description Property; part of the color transformation for the instance. This property is equivalent to using the Color > Advanced setting in the Instance Property inspector (the percentage controls on the left of the dialog box). This value sets the red values to a specified percentage. Allowable values are from -100 to 100.
Description Property; a zero-based integer that specifies the first frame to appear in the Timeline of the graphic. This property applies only to graphic symbols and sets the same property as the First field in the Property inspector. For other types of symbols, this property is undefined. Example The following example specifies that Frame 11 should be the first frame to appear in the Timeline of the specified element: fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].
Description Property; a string that, for graphic symbols, sets the same property as the Loop pop-up menu in the Property inspector. For other types of symbols, this property is undefined. Acceptable values are "loop", "play once", and "single frame" to set the graphic’s animation accordingly.
This property is not available for graphic objects. Example The following example checks to see if the object is accessible; a return value of false means the object is accessible: var isSilent = fl.getDocumentDOM().selection[0].silent; The following example sets the object to be accessible: fl.getDocumentDOM().selection[0].silent = false; symbolInstance.symbolType Availability Flash MX 2004. Usage symbolInstance.symbolType Description Property; a string that specifies the type of symbol.
CHAPTER 3 Objects SymbolItem object Inheritance Item object > SymbolItem object Availability Flash MX 2004. Description The SymbolItem object is a subclass of the Item object. Method summary for the SymbolItem object In addition to the Item object methods, you can use the following methods with the SymbolItem object: Method Description symbolItem.convertToCompiledClip() Method; converts a symbol item in the library to a compiled movie clip. symbolItem.
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(); symbolItem.exportSWC() Availability Flash MX 2004. Usage symbolItem.exportSWC( outputURI ) Parameters The outputURI parameter is a string that specifies the URI for the SWC file to which the method will export the symbol.
Parameters The outputURI parameter is a string that specifies the URI for the SWF file to which the method will export the symbol. This URI must reference a local file. Flash will not create a folder if the specified path doesn’t exist. Returns Nothing. Description Method; exports the symbol item to a SWF file specified by a URI. Example The following example exports an item in the library to the my.swf file in the tests folder: fl.getDocumentDOM().library.items[0].exportSWF("file:///c|/tests/my.
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. Used for Shared Library symbols. Example The following example shows the value of the sourceLibraryName property in the Output panel: fl.trace(fl.getDocumentDOM().library.items[0].sourceLibraryName); symbolItem.symbolType Availability Flash MX 2004. Usage symbolItem.
Example The following example obtains and shows the number of layers that the selected movie clip in the library contains: var tl = fl.getDocumentDOM().library.getSelectedItems()[0].timeline; alert(tl.
CHAPTER 3 Objects TextAttrs object Availability Flash MX 2004. Description The TextAttrs object contains all the properties of text that can be applied to a subselection. This object is a property of the TextRun object (textRun.textAttrs). Property summary for the TextAttrs object The following properties are available for the TextAttrs object. Property Description textAttrs.
textAttrs.aliasText Availability Flash MX 2004. Usage textAttrs.aliasText Description Property; a Boolean value that specifies that Flash should draw the text using a method optimized for increasing the legibility of small text. Example The following example sets the aliasText property to true for all the text in the currently selected text field: fl.getDocumentDOM().setElementTextAttr('aliasText', true); textAttrs.alignment Availability Flash MX 2004. Usage textAttrs.
This property applies only to static text; it generates a warning if used with other text types. Example The following example selects the characters from index 2 up to, but not including, index 6 and sets the autoKern property to true: fl.getDocumentDOM().setTextSelection(3, 6); fl.getDocumentDOM().setElementTextAttr('autoKern', true); textAttrs.bold Availability Flash MX 2004. Usage textAttrs.bold Description Property; a Boolean value.
textAttrs.characterSpacing Availability Flash MX 2004. Usage textAttrs.characterSpacing Description Property; an integer that represents the space between characters. Acceptable values are -60 through 60. This property applies only to static text; it generates a warning if used with other text types. Example The following example sets the character spacing of the selected text field to 10: fl.getDocumentDOM().setElementTextAttr("characterSpacing", 10); textAttrs.face Availability Flash MX 2004.
Example The following example sets the color of the selected text field from the character at index 2 up to, but not including, the character at index 8 to red: fl.getDocumentDOM().selection[0].setTextAttr("fillColor", 0xff0000, 2, 8); textAttrs.indent Availability Flash MX 2004. Usage textAttrs.indent Description Property; an integer that specifies paragraph indentation. Acceptable values are -720 through 720.
Description Property; an integer that specifies the paragraph’s left margin. Acceptable values are 0 through 720. Example The following example sets the leftMargin property of the selected text field from the character at index 2 up to, but not including, the character at index 8 to 100. This can affect characters outside the specified range if they are in the same paragraph. fl.getDocumentDOM().selection[0].setTextAttr("leftMargin", 100, 2, 8); textAttrs.lineSpacing Availability Flash MX 2004.
textAttrs.rotation Availability Flash MX 2004. Usage textAttrs.rotation Description Property; a Boolean value. A value of true causes Flash to rotate the characters of the text 90º. The default value is false. This property applies only to static text with a vertical orientation; it generates a warning if used with other text types. Example The following example sets the rotation of the selected text field to true: fl.getDocumentDOM().setElementTextAttr("rotation", true); textAttrs.
Example The following example gets the target property of the text field in the first frame of the top layer of the current scene and shows it in the Output panel: fl.outputPanel.trace(fl.getDocumentDOM().getTimeline().layers[0].frames[0].ele ments[0].getTextAttr("target")); textAttrs.url Availability Flash MX 2004. Usage textAttrs.url Description Property; a string that represents the URL property of the text field. This property works only with static text.
CHAPTER 3 Objects Text object Inheritance Element object > Text object Availability Flash MX 2004. Description The Text object represents a single text item in a document. All properties of the text pertain to the entire text block. To set properties of a text run within the text field, see “Property summary for the TextRun object” on page 322. To change properties of a selection within a text field, you can use document.setElementTextAttr() and specify a range of text, or use the current selection.
Property Description text.embeddedCharacters Property; a string that specifies characters to embed. This is equivalent to entering text in the Character Options dialog box. text.embedRanges Property; a string that consists of delimited integers that correspond to the items that can be selected in the Character Options dialog box. text.length Read-only; an integer that represents the number of characters in the text object. text.
Description Property; a string that is equivalent to the Name field in the Accessibility panel. Screen readers identify objects by reading the name aloud. This property cannot be used with dynamic text. Example The following example retrieves the name of the object: var theName = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].accName; The following example sets the name of the currently selected object: fl.getDocumentDOM().selection[0].accName = "Home Button"; text.
text.description Availability Flash MX 2004. Usage text.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 retrieves the description of the object: var theDescription = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].descripti on; The following example sets the description of the object: fl.getDocumentDOM().getTimeline().layers[0].frames[0].
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. Note: This property corresponds to the XML file in the Configuration/Font Embedding folder. Example The following example sets the embedRanges property to "1|3|7": fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].
The following example gets the text fill color of the selected text field: var TheFill = fl.getDocumentDOM().selection[0].getTextAttr("fillColor"); fl.trace(TheFill); The following example gets the size of the third character: var Char2 = fl.getDocumentDOM().selection[0].getTextAttr("size", 2); fl.trace(Char2); The following example gets the color of the selected text field from the third through the eighth character: fl.getDocumentDOM().selection[0].getTextAttr("fillColor", 2, 8); text.
text.length Availability Flash MX 2004. Usage text.length Description Read-only property; an integer that represents the number of characters in the text object. Example The following example returns the number of characters in the selected text: var textLength = fl.getDocumentDOM().selection[0].length; text.lineType Availability Flash MX 2004. Usage text.lineType Description Property; a string that sets the line type.
Example The following example sets the value of the maxCharacters property to 30: fl.getDocumentDOM().selection[0].maxCharacters = 30; text.orientation Availability Flash MX 2004. Usage text.orientation Description Property; a string that specifies the orientation of the text field. Acceptable values are "horizontal", "vertical left to right", and "vertical right to left". This property works only with static text; it generates a warning if used with other text types.
text.scrollable Availability Flash MX 2004. Usage text.scrollable Description Property; a Boolean value. If the value is true, the text can be scrolled. This property works only with dynamic or input text; it generates a warning if used with static text. Example The following example sets the scrollable property to false: fl.getDocumentDOM().selection[0].scrollable = false; text.selectable Availability Flash MX 2004. Usage text.selectable Description Property; a Boolean value.
text.selectionStart Availability Flash MX 2004. Usage text.selectionStart Description Property; a zero-based integer that specifies the beginning of a text subselection. You can use this property with text.selectionEnd to select a range of characters. Characters up to, but not including, text.selectionEnd are selected. • If there is an insertion point or no selection, text.selectionEnd is equal to text.selectionStart. • If text.selectionStart is set to a value greater than text.selectionEnd, text.
An integer that is a range of text, which starts at startIndex and goes up to, but not including, endIndex. This parameter is optional. endIndex Returns Nothing. Description Method; sets the attribute specified by the attrName parameter associated with the text identified by startIndex and endIndex to the value specified by attrValue. This method can be used to change attributes of text that might span TextRun elements (see TextRun object), or that are portions of existing TextRun elements.
Description Property; changes the text string within this text object. If you omit the optional parameters, the whole text object is replaced. If you specify only startIndex, the specified string is inserted at the startIndex position. If you specify both startIndex and endIndex, the specified string replaces the segment of text starting from startIndex up to, but not including, endIndex. Example The following example assigns the string "this is a string" to the selected text field: fl.getDocumentDOM().
text.silent Availability Flash MX 2004. Usage text.silent Description Property; a Boolean value that specifies whether the object is accessible. This is equivalent to the inverse logic of the Make Object Accessible setting in the Accessibility panel. That is, if silent is true, Make Object Accessible is deselected. If it is false, Make Object Accessible is selected. Example The following example determines if the object is accessible (a value of false means that it is accessible): var isSilent = fl.
text.textRuns Availability Flash MX 2004. Usage text.textRuns Description Read-only property; an array of TextRun objects (see TextRun object). Example The following example stores the value of the textRuns property in the myTextRuns variable: var myTextRuns = fl.getDocumentDOM().selection[0].textRuns; text.textType Availability Flash MX 2004. Usage text.textType Description Property; a string that specifies the type of text field. Acceptable values are "static", "dynamic", and "input".
text.variableName Availability Flash MX 2004. Usage text.variableName Description Property; a string that contains the name of the variable associated with the text object. This property works only with dynamic or input text; it generates a warning if used with other text types.
CHAPTER 3 Objects TextRun object Availability Flash MX 2004. Description The TextRun object represents a run of characters that have attributes that match all of the properties in the TextAttrs object. This object is a property of the Text object (text.textRuns). Property summary for the TextRun object In addition to the properties available for use with the Text object, the TextRun object provides the following properties. Property Description textRun.
Example The following example displays the properties of the first run of characters in the selected text field in the Output panel. var curTextAttrs = fl.getDocumentDOM().selection[0].textRuns[0].textAttrs; for (var prop in curTextAttrs) { fl.
CHAPTER 3 Objects Timeline object Availability Flash MX 2004. Description The Timeline object represents the Flash Timeline, which can be accessed for the current document by fl.getDocumentDOM().getTimeline(). This method returns the Timeline of the current scene or symbol that is being edited. When you work with scenes, each scene’s Timeline has an index value, and can be accessed for the current document by fl.getDocumentDOM().timelines[i]. (In this example, i is the index of the value of the Timeline.
Method Description timeline.getFrameProperty() Retrieves the specified property’s value for the selected frames. timeline.getLayerProperty() Retrieves the specified property’s value for the selected layers. timeline.getSelectedFrames() Retrieves the currently selected frames in an array. timeline.getSelectedLayers() Retrieves the zero-based index values of the currently selected layers. timeline.
Property Description timeline.frameCount Read-only; an integer that represents the number of frames in this Timeline’s longest layer. timeline.layerCount Read-only; an integer that represents the number of layers in the specified Timeline. timeline.layers Read-only; an array of layer objects. timeline.name A string that represents the name of the current Timeline. timeline.addMotionGuide() Availability Flash MX 2004. Usage timeline.addMotionGuide() Parameters None.
Parameters name A string that specifies the name for the new layer. If you omit this parameter, a new default layer name is assigned to the new layer (“Layer n,” where n is the total number of layers). This parameter is optional. A string that specifies the type of layer to add. If you omit this parameter, a “Normal” type layer is created. This parameter is optional.
Example The following example clears the frames from Frame 6 up to, but not including, Frame 11 (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().clearFrames(5, 10); The following example clears Frame 15: fl.getDocumentDOM().getTimeline().clearFrames(14); timeline.clearKeyframes() Availability Flash MX 2004. Usage timeline.
Parameters A zero-based index that specifies the starting frame to convert to keyframes. If you omit startFrameIndex, the method converts the currently selected frames. This parameter is optional. startFrameIndex A zero-based index that specifies the frame at which the conversion to keyframes will stop. The range of frames to convert goes up to, but does not include, endFrameIndex. If you specify only startFrameIndex, endFrameIndex defaults to the value of startFrameIndex. This parameter is optional.
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); The following example converts Frame 5 to a keyframe: fl.getDocumentDOM().getTimeline().convertToKeyframes(4); timeline.
timeline.createMotionTween() Availability Flash MX 2004. Usage timeline.createMotionTween([startFrameIndex [, endFrameIndex]]) Parameters A zero-based index that specifies the beginning frame at which to create a motion tween. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. startFrameIndex endFrameIndex A zero-based index that specifies the frame at which to stop the motion tween. The range of frames goes up to, but does not include, endFrameIndex.
The following example stores the value of the current playhead location in the curFrame variable: var curFrame = fl.getDocumentDOM().getTimeline().currentFrame; timeline.currentLayer Availability Flash MX 2004. Usage timeline.currentLayer Description Property; the zero-based index for the currently active layer. A value of 0 specifies the top layer, a value of 1 specifies the layer below it, and so on. Example The following example makes the top layer active: fl.getDocumentDOM().getTimeline().
Example The following example cuts the selected frames from the Timeline and saves them to the Clipboard: fl.getDocumentDOM().getTimeline().cutFrames(); The following example cuts Frame 2 up to, but not including, Frame 10 from the Timeline and saves them to the Clipboard (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().cutFrames(1, 9); The following example cuts Frame 5 from the Timeline and saves it to the Clipboard: fl.getDocumentDOM().
Parameters A Boolean value that, if set to true, causes the method to expand the folder; false causes the method to collapse the folder. bExpand bRecurseNestedParents A Boolean value that, if set to true, causes all the layers within the specified folder to be opened or closed, based on the bExpand parameter. This parameter is optional. A zero-based index of the folder to expand or collapse. Use -1 to apply to all layers (you also must set bRecurseNestedParents to true).
Returns An array of index values for the specified layer. If the specified layer is not found, Flash returns undefined. Description Method; finds an array of indexes for the layers with the given name. The layer index is flat, so folders are considered part of the main index. Example The following example shows the index values of all layers named Layer 7 in the Output panel: var layerIndex = fl.getDocumentDOM().getTimeline().findLayerIndex("Layer 7"); fl.
startFrameIndex A zero-based index that specifies the starting frame number for which to get the value. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. A zero-based index that specifies the end of the range of frames to select. The range goes up to, but does not include, endFrameIndex. If you specify only startFrameIndex, endFrameIndex defaults to the value of startFrameIndex. This parameter is optional.
timeline.getSelectedFrames() Availability Flash MX 2004. Parameters None. Returns An array containing 3n integers, where n is the number of selected regions. The first integer in each group is the layer index, the second integer is the start frame of the beginning of the selection, and the third integer specifies the ending frame of that selection range. The ending frame is not included in the selection. Description Method; retrieves the currently selected frames in an array.
timeline.insertBlankKeyframe() Availability Flash MX 2004. Usage timeline.insertBlankKeyframe([frameNumIndex]) Parameters A zero-based index that specifies the frame at which to insert the keyframe. If you omit frameNumIndex, the method uses the current playhead frame number. This parameter is optional. frameNumIndex If the specified or selected frame is a regular frame, the keyframe is inserted at the frame.
bAllLayers A Boolean value that, if set to true (the default), causes the method to insert the specified number of frames in the numFrames parameter into all layers; if set to false, the method inserts frames into the current layer. This parameter is optional. A zero-based index that specifies the frame at which to insert a new frame. This parameter is optional. frameNumIndex Returns Nothing. Description Method; inserts the specified number of frames at the specified index.
The following example inserts three frames in the current layer only: fl.getDocumentDOM().getTimeline().insertFrames(3, false); The following example inserts four frames in all layers, starting from the first frame: fl.getDocumentDOM().getTimeline().insertFrames(4, true, 0); timeline.insertKeyframe() Availability Flash MX 2004. Usage timeline.insertKeyframe([frameNumIndex]) Parameters A zero-based index that specifies the frame index at which to insert the keyframe in the current layer.
Example The following example uses the NumLayer variable to store the number of layers in the current scene: var NumLayer = fl.getDocumentDOM().getTimeline().layerCount; timeline.layers Availability Flash MX 2004. Usage timeline.layers Description Read-only property; an array of layer objects. Example The following example uses the currentLayers variable to store the array of layer objects in the current document: var currentLayers = fl.getDocumentDOM().getTimeline().layers; timeline.
Parameters startFrameIndex A zero-based index that specifies the beginning of a range of frames to paste. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. endFrameIndex A zero-based index that specifies the frame at which to stop pasting frames. The method pastes up to, but not including, endFrameIndex. If you specify only startFrameIndex, endFrameIndex defaults to the startFrameIndex value. This parameter is optional. Returns Nothing.
Description Method; deletes the frame. Example The following example deletes Frame 5 up to, but not including, Frame 10 of the top layer in the current scene (remember that index values are different from frame number values): fl.getDocumentDOM().getTimeline().currentLayer = 0; fl.getDocumentDOM().getTimeline().removeFrames(4, 9); The following example deletes Frame 8 on the top layer in the current scene: fl.getDocumentDOM().getTimeline().currentLayer = 0; fl.getDocumentDOM().getTimeline().
timeline.reverseFrames() Availability Flash MX 2004. Usage timeline.reverseFrames([startFrameIndex [, endFrameIndex]]) Parameters A zero-based index that specifies the first frame at which to start reversing frames. If you omit startFrameIndex, the method uses the current selection. This parameter is optional. startFrameIndex A zero-based index that specifies the first frame at which to stop reversing frames; the range of frames goes up to, but does not include, endFrameIndex.
Example The following example selects all the frames in the current Timeline. fl.getDocumentDOM().getTimeline().selectAllFrames(); timeline.setFrameProperty() Availability Flash MX 2004. Usage timeline.setFrameProperty(property, value [, startFrameIndex [, endFrameIndex]]) Parameters A string that specifies the name of the property to be modified. For a complete list of properties and values, see “Property summary for the Frame object” on page 185.
timeline.setLayerProperty() Availability Flash MX 2004. Usage timeline.setLayerProperty(property, value [, layersToChange]) Parameters A string that specifies the property to set. For a list of properties, see “Layer object” on page 208. property The value to which you want to set the property. Use the same type of value you would use when setting the property on the Layer object. value A string that identifies which layers should be modified.
A Boolean value that, if it is set to true, causes the currently selected frames to be deselected before the specified frames are selected. The default value is true. bReplaceCurrentSelection selectionList An array of three integers, as returned by timeline.getSelectedFrames(). Returns Nothing. Description Method; selects a range of frames in the current layer or sets the selected frames to the selection array passed into this method.
Description Method; sets the layer to be selected, and also makes the specified layer the current layer. Selecting a layer also means that all the frames in the layer are selected. 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); timeline.showLayerMasking() Availability Flash MX 2004. Usage timeline.
CHAPTER 3 Objects ToolObj object Availability Flash MX 2004. Description A ToolObj object represents an individual tool in the Tools panel. To access a ToolObj object, use properties of the Tools object: either the tools.toolObjs array or tools.activeTool. Method summary for the ToolObj object The following methods are available for the ToolObj object. Note: The following methods are used only when creating extensible tools. Method Description toolObj.
toolObj.enablePIControl() Availability Flash MX 2004. Usage toolObj.enablePIControl( control, bEnable ) Parameters control A string that specifies the name of the control to enable or disable. Legal values depend on the Property inspector invoked by this tool (see toolObj.setPI()).
Example The following command in an extensible tool’s JavaScript file will set Flash to not show the stroke options in the Property inspector for that tool: theTool.enablePIControl( "stroke", false); toolObj.position Availability Flash MX 2004. Usage toolObj.position Description Read-only property; an integer specifying the position of the tool in the Tools panel.
toolObj.setMenuString() Availability Flash MX 2004. Usage toolObj.setMenuString( menuStr ) Parameters menuStr A string that specifies the name that appears in the pop-up menu as the name for the tool. Returns Nothing. Description Method; sets the string that appears in the pop-up menu as the name for the tool. Example The following example specifies that the tool named theTool should display the name “Arrow Style 1” in its pop-up menu. theTool.setMenuString("Arrow Style 1"); toolObj.
toolObj.setPI() Availability Flash MX 2004. Usage toolObj.setPI( pi ) Parameters pi A string that specifies the Property inspector to invoke for this tool. Returns Nothing. Description Method; specifies which Property inspector should be used when the tool is activated. Valid values are "shape" (the default), "text", and "movie". Example The following example specifies that the text Property inspector should be used when the tool is activated. fl.tools.activeTool.setPI( "text" ); toolObj.
toolObj.setToolTip() Availability Flash MX 2004. Usage toolObj.setToolTip( toolTip ) Parameters toolTip A string that specifies the tooltip to use for the tool. Returns Nothing. Description Method; sets the tooltip that appears when the mouse is held over the tool icon. Example The following example specifies that the tooltip for the tool should be “Arrow Style 1 Tool.” fl.tools.activeTool.setToolTip("Arrow Style 1 Tool"); toolObj.showPIControl() Availability Flash MX 2004. Usage toolObj.
deviceFonts varEdit options link maxChars target The movie Property inspector has the following controls: size publish background framerate player profile bShow A Boolean value that determines whether to show or hide the specified control (true shows the control; false hides the control). Returns Nothing. Description Method; shows or hides a control in the Property inspector.
CHAPTER 3 Objects Tools object Availability Flash MX 2004. Description The Tools object is accessible from the Flash object (fl.tools). The tools.toolObjs property contains an array of ToolObj objects, and the tools.activeTool property returns the ToolObj object for the currently active tool. (See also ToolObj object.) Note: The following methods and properties are used only when creating extensible tools. Method summary for the Tools object The following methods are available for the Tools object.
tools.activeTool Availability Flash MX 2004. Usage tools.activeTool Description Read-only property; returns the ToolObj object for the currently active tool. Example The following example saves an object that represents the currently active tool in the theTool variable. var theTool = fl.tools.activeTool; tools.altIsDown Availability Flash MX 2004. Usage tools.altIsDown Description Read-only property; a Boolean value that identifies if the Alt key is being pressed.
tools.ctlIsDown Availability Flash MX 2004. Usage tools.ctlIsDown Description Read-only property; a Boolean value that identifies if the Control key is being pressed. The value is true if the Control key is pressed, and false otherwise. tools.getKeyDown() Availability Flash MX 2004. Usage tools.getKeyDown() Parameters None. Returns The integer value of the key. Description Method; returns the most recently pressed key. tools.mouseIsDown Availability Flash MX 2004. Usage tools.
Description Read-only property; a point that represents the position of the last mouse-down event on the Stage. penDownLoc has two properties, x and y, corresponding to the x,y location of the mouse on the current document. tools.penLoc Availability Flash MX 2004. Usage tools.penLoc Description Read-only property; a point that represents the current location of the mouse. penLoc has two properties: x and y, corresponding to the x,y location of the mouse on the current document. tools.
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 identifies if the Shift key is being pressed. The value is true if the Shift key is pressed, and false otherwise. tools.snapPoint() Availability Flash MX 2004. Usage tools.snapPoint(pt) Parameters pt specifies the location of the point for which you want to return a snap point.
CHAPTER 3 Objects Vertex object Availability Flash MX 2004. Description The Vertex object is the part of the shape data structure that holds the coordinate data. Method summary for the Vertex object You can use the following methods with the Vertex object. Method Description vertex.getHalfEdge() Gets a HalfEdge object that shares this vertex. vertex.setLocation() Sets the location of the vertex.
Usage vertex.setLocation( x, y ) Parameters A floating point value that specifies the x coordinate of where the vertex should be positioned, in pixels. x A floating point value that specifies the y coordinate of where the vertex should be positioned, in pixels. y Returns Nothing. Description Method; sets the location of the vertex. You must call shape.beginEdit() before using this method. Example The following example sets the vertex to the origin point. var shape = fl.getDocumentDOM().
vertex.y Availability Flash MX 2004. Usage vertex.y Description Read-only property; the y location of the vertex in pixels. Example See vertex.x.
VideoItem object Inheritance CHAPTER 3 Objects Item object > VideoItem object Availability Flash MX 2004. Description The VideoItem object is a subclass of the Item object. There are no unique methods or properties of VideoItem.
CHAPTER 3 Objects XMLUI object Availability Flash MX 2004. Description Flash MX 2004 supports custom dialog boxes written in a subset of the XML User Interface Language (XUL). For more information, see Appendix B, “XML to UI” in Using Flash. You can write a dialog.xml file and invoke it from the JavaScript API using the document.xmlPanel() method.
Description Method; makes the current XMLUI dialog box exit with an accept state, which is equivalent to the user clicking the OK button. xmlui.cancel() Availability Flash MX 2004. Usage xmlui.cancel() Parameters None. Returns Nothing. Description Method; makes the current XMLUI dialog box exit with a cancel state, which is equivalent to the user clicking the Cancel button. xmlui.get() Availability Flash MX 2004. Usage xmlui.
Parameters name value A string that specifies the name of XMLUI property to modify. A string that specifies the value to which you want to set the XMLUI property. Returns Nothing. Description Method; modifies the value of the specified property of the current XMLUI dialog box.
Chapter 3: Objects
CHAPTER 4 C-Level Extensibility The C-level extensibility mechanism lets you implement Macromedia Flash MX 2004 and Macromedia Flash Professional MX 2004 extensibility files using a combination of JavaScript and custom C code. You define functions using C, bundle them in a dynamic linked library (DLL) or a shared library, save the library in the appropriate directory, and then call the functions from JavaScript using the Flash JavaScript API (JSAPI).
■ Windows 98: C:\Windows\Application Data\Macromedia\Flash MX 2004\ \ Configuration\Templates\External Libraries ■ Macintosh OS X: Hard Drive/Users//Library/Application Support/Macromedia/ Flash MX 2004//Configuration/Templates/External Libraries 4. Create a JSFL file that calls the functions. 5. Run the JSFL file from the Commands menu in the Flash authoring environment. For more information, see “Sample implementation” on page 374.
#define JS_FALSE 0 /***************************************************************************** * Public functions ****************************************************************************/ /* JSBool JS_DefineFunction(unsigned short *name, JSNative call, unsigned int nargs) */ #define JS_DefineFunction(n, c, a) \ (mmEnv.defineFunction ? (*(mmEnv.defineFunction))(mmEnv.
/* jsval JS_IntegerToValue(long lv); */ #define JS_IntegerToValue(lv) (((jsval)(lv) << 1) | 0x1) /* jsval JS_BooleanToValue(JSBool bv); */ #define JS_BooleanToValue(bv) (((jsval)(bv) << 3) | 0x6) /* jsval JS_ObjectToValue(JSObject *obj); */ #define JS_ObjectToValue(ov) ((jsval)(ov)) /* unsigned short *JS_ObjectType(JSObject *obj); */ #define JS_ObjectType(o) \ (mmEnv.objectType ? (*(mmEnv.
unsigned short *(*valueToString)(JSContext *cx, jsval v, unsigned int *pLength); unsigned char *(*valueToBytes)(JSContext *cx, jsval v, unsigned int *pLength); JSBool (*valueToInteger)(JSContext *cx, jsval v, long *lp); JSBool (*valueToDouble)(JSContext *cx, jsval v, double *dp); JSBool (*valueToBoolean)(JSContext *cx, jsval v, JSBool *bp); JSBool (*valueToObject)(JSContext *cx, jsval v, JSObject **op); JSBool (*stringToValue)(JSContext *cx, unsigned short *b, unsigned int sz, jsval *vp); JSBool (*bytesToVa
{ extern void MM_Init(); char char char char **envPtr = (char **)env; **mmPtr = (char **)(&mmEnv); **envEnd = (char **)((char *)envPtr + envSize); **mmEnd = (char **)((char *)mmPtr + sizeof(MM_Environment)); \ \ \ \ \ \ \ /* Copy fields from env to mmEnv, one pointer at a time */ while (mmPtr < mmEnd && envPtr < envEnd) *mmPtr++ = *envPtr++; \ \ \ \ \ /* If env doesn't define all of mmEnv's fields, set extras to NULL */ \ while (mmPtr < mmEnd) *mmPtr++ = (char *)0; /* Call user's MM_Init function */ MM
long a, b, sum; // Make sure the right number of arguments were passed in if (argc != 2) return JS_FALSE; // Convert the two arguments from jsvals to longs if (JS_ValueToInteger(cx, argv[0], &a) == JS_FALSE || JS_ValueToInteger(cx, argv[1], &b) == JS_FALSE) return JS_FALSE; /* Perform the actual work */ sum = a + b; /* Package the return value as a jsval */ *rval = JS_IntegerToValue(sum); /* Indicate success */ return JS_TRUE; } After writing this code, build the DLL file or shared library, and store it in
typedef struct jsval jsval An opaque data structure that can contain an integer, or a pointer to a float, string, or object. Some functions in the API can read the values of function arguments by reading the contents of a jsval structure, and some can be used to write the function’s return value by writing a jsval structure. typedef enum { JS_FALSE = 0, JS_TRUE = 1 } JSBool A simple data type that stores a Boolean value.
typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) Description Method: describes C-level implementations of JavaScript functions in the following situations: • The cx pointer is a pointer to an opaque JSContext structure, which must be passed to some of the functions in the JavaScript API. This variable holds the interpreter’s execution context. • The obj pointer is a pointer to the object in whose context the script executes.
unsigned short *JS_ValueToString() Usage unsigned short *JS_ValueToString(JSContext *cx, jsval v, unsigned int *pLength) Description Method; extracts a function argument from a jsval structure, converts it to a string, if possible, and passes the converted value back to the caller. Note: Do not modify the returned buffer pointer or you might corrupt the data structures of the JavaScript interpreter. To change the string, you must copy the characters into another buffer and create a new JavaScript string.
JSBool JS_ValueToDouble() Usage JSBool JS_ValueToDouble(JSContext *cx, jsval v, double *dp); Description Method; extracts a function argument from a jsval structure, converts it to a double (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, double *dp • The cx argument is the opaque JSContext pointer that passed to the JavaScript function. • The v argument is the jsval structure from which the double is to be extracted.
JSBool JS_ValueToObject() Usage JSBool JS_ValueToObject(JSContext *cx, jsval v, JSObject **op); Description Method; extracts a function argument from a jsval structure, converts it to an object (if possible), and passes the converted value back to the caller. If the object is an array, use JS_GetArrayLength() and JS_GetElement() to read its contents. Arguments JSContext *cx, jsval v, JSObject **op • The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
JSBool JS_DoubleToValue() Usage JSBool JS_DoubleToValue(JSContext *cx, double dv, jsval *vp); Description Method; stores a floating-point number return value in a jsval structure. Arguments JSContext *cx, double dv, jsval *vp • The cx argument is the opaque JSContext pointer that passes to the JavaScript function. • The dv argument is an 8-byte floating-point number. • The vp argument is a pointer to the jsval structure into which the contents of the double should be copied.
• The sz argument is the number of bytes to be converted. • The vp argument is the JavaScript value. Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSVal JS_IntegerToValue() Usage jsval JS_IntegerToValue(long lv); Description Method; converts a long integer value to JSVal structure. Arguments lv • The lv argument is the long integer value that you want to convert to a jsval structure.
Note: Do not modify the returned buffer pointer, or you might corrupt the data structures of the JavaScript interpreter. Arguments JSObject *obj • Typically, this argument is passed in and converted using the JS_ValueToObject() function. Returns A pointer to a null-terminated string. The caller should not free this string when it finishes.
JSBool JS_GetElement() Usage JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) Description Method; reads a single element of an array object. Arguments JSContext *cx, JSObject *obj, unsigned int index, jsval *v • The cx argument is the opaque JSContext pointer that passes to the JavaScript function. • The obj argument is a pointer to an array object. • The index argument is an integer index into the array. The first element is index 0, and the last element is index (length - 1).
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 JSContext *cx, JSObject *obj, unsigned short *script, unsigned int sz, jsval *rval • The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
Chapter 4: C-Level Extensibility