MACROMEDIA FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY Manual

Other manuals for FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY: User Manual

Summary of FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY

  • Page 1

    Flash javascript dictionary.

  • Page 2

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

  • Page 3: Contents

    3 contents chapter 1: introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 overview of the macromedia flash javascript api . . . . . . . . . . . . . . . . . . . . . . . . 17 the flash document object model . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents contour object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 contour.Gethalfedge() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 contour.Interior . . . . . . . . . . . . . . . . . . . . ....

  • Page 5

    Contents 5 document.Getaligntodocument() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 document.Getcustomfill() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 document.Getcustomstroke(). . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents document.Setselectionbounds() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 document.Setselectionrect(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 document.Setstroke() . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 7

    Contents 7 effect object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 effect.Effectname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 effect.Groupname . . . . . . . . . . . . . . . . . . ...

  • Page 8

    8 contents fl.Opendocument(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 fl.Openproject(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 fl.Openscript() . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 9

    Contents 9 instance object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 instance.Instancetype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 instance.Libraryitem . . . . . . . . . . . . . . . . . . ...

  • Page 10

    10 contents linkedvideoinstance object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 math object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 math.Concatmatrix() . . . . . . . . . . . . . . . . . . ...

  • Page 11

    Contents 11 screenoutline object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 screenoutline.Copyscreenfromfile() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 screenoutline.Currentscreen . . . . . . . . . . . . . . . . . . . . . ...

  • Page 12

    12 contents stroke.Variation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 stroke.Waveheight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 stroke.Wavelength . . . . . . . . . . . . . . . . . . . . ....

  • Page 13

    Contents 13 textattrs.Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 textattrs.Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 textattrs.Url . . . . . . . . . . . . . . . . . . . ...

  • Page 14

    14 contents timeline.Getlayerproperty() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 timeline.Getselectedframes(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 timeline.Getselectedlayers() . . . . . . . . . . . . . . . . . . . . . ....

  • Page 15

    Contents 15 xmlui object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 xmlui.Accept(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 xmlui.Cancel(). . . . . . . . . . . . . . . . . . . . ...

  • Page 16

    16 contents.

  • Page 17: Chapter 1

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

  • Page 18

    18 chapter 1: introduction 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. To make a script appear in the commands menu, save its jsfl file in...

  • Page 19

    The flash document object model 19 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 ...

  • Page 20

    20 chapter 1: introduction the flash object contains the following child objects: the document object an important property of the top-level flash object is the documents property. The documents property contains an array of document objects that each represent one of the fla files currently open in...

  • Page 21

    The flash document object model 21 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, whi...

  • Page 22

    22 chapter 1: introduction 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 ...

  • Page 23

    The polystar example 23 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 ob...

  • Page 24

    24 chapter 1: introduction 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 (wi...

  • Page 25: Chapter 2

    25 chapter 2 top-level functions this chapter describes the top-level functions that are available when creating extensible tools. The following list shows the functions in alphabetical order: activate() configureeffect() configuretool() deactivate() executeeffect() keydown() keyup() mousedoubleclic...

  • Page 26

    26 chapter 2: top-level functions 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 to...

  • Page 27

    Configureeffect() 27 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 parame...

  • Page 28

    28 chapter 2: top-level functions 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 need...

  • Page 29

    Deactivate() 29 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 perf...

  • Page 30

    30 chapter 2: top-level functions 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 fun...

  • Page 31

    Keydown() 31 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. Exampl...

  • Page 32

    32 chapter 2: top-level functions 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.Trace("key is released"); }.

  • Page 33

    Mousedoubleclick() 33 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.Trace("mouse was do...

  • Page 34

    34 chapter 2: top-level functions 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 o...

  • Page 35

    Mousemove() 35 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-...

  • Page 36

    36 chapter 2: top-level functions 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.Trace("mous...

  • Page 37

    Notifysettingschanged() 37 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 ...

  • Page 38

    38 chapter 2: top-level functions 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...

  • Page 39

    Setcursor() 39 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 poin...

  • Page 40

    40 chapter 2: top-level functions.

  • Page 41: Chapter 3

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

  • Page 42

    42 chapter 3: objects 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 obje...

  • Page 43

    Bitmapinstance object 43 bitmapinstance object inheritance element object > instance object > bitmapinstance object availability flash mx 2004. Description the bitmapinstance object is a subclass of the instance object and represents a bitmap in a frame. Method summary for the bitmapinstance object ...

  • Page 44

    44 chapter 3: objects 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...

  • Page 45

    Bitmapinstance object 45 var isbitmap = bmobj.Instancetype; if(isbitmap == "bitmap"){ var numhorizontalpixels = bmobj.Hpixels; } bitmapinstance.Setbits() availability flash mx 2004. Usage bitmapinstance.Setbits(bitmap) parameters bitmap an object that contains height , width , depth , bits , and cta...

  • Page 46

    46 chapter 3: objects 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.Vpixels; }.

  • Page 47: Chapter 3

    Bitmapitem object 47 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 addit...

  • Page 48

    48 chapter 3: objects 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 fals...

  • Page 49

    Bitmapitem object 49 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 t...

  • Page 50: Chapter 3

    50 chapter 3: objects compiledclipinstance object inheritance element object > instance object > compiledclipinstance object availability flash mx 2004. Description the compiledclipinstance object is a subclass of the instance object . It is essentially an instance of a movie clip that has been conv...

  • Page 51

    Compiledclipinstance object 51 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 compiledclipinsta...

  • Page 52

    52 chapter 3: objects 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 acc...

  • Page 53

    Compiledclipinstance object 53 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 silen...

  • Page 54: Chapter 3

    54 chapter 3: objects componentinstance object inheritance element object > instance object > symbolinstance object > componentinstance object availability flash mx 2004. Description the componentinstance object is a subclass of the symbolinstance object and represents a component in a frame. Proper...

  • Page 55: Chapter 3

    Componentspanel object 55 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 follo...

  • Page 56: Chapter 3

    56 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 summary for the contour object you...

  • Page 57

    Contour object 57 elt.Beginedit(); var contourarray = elt.Contours; var contourcount = 0; for (i=0; i { var contour = contourarray[i]; contourcount++; var he = contour.Gethalfedge(); var istart = he.Id; var id = 0; while (id != istart) { // get the next vertex var vrt = he.Getvertex(); var x = vrt.X...

  • Page 58

    58 chapter 3: objects } 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...

  • Page 59: Chapter 3

    Document object 59 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.Adddat...

  • Page 60

    60 chapter 3: objects 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...

  • Page 61

    Document object 61 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.G...

  • Page 62

    62 chapter 3: objects 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. Docum...

  • Page 63

    Document object 63 property summary for the document object you can use the following properties with the document object. Document.Settextselection() sets the text selection of the currently selected text field to the values specified by the startindex and endindex values. Document.Settextstring() ...

  • Page 64

    64 chapter 3: objects document.Accname availability flash mx 2004. Usage document.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. Document.Description a string that is equivalent to the...

  • Page 65

    Document object 65 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() availabili...

  • Page 66

    66 chapter 3: objects 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" , "double" , "doublearray" , "string" , and "bytearray" . Data the value to add. Valid types depend on the type para...

  • Page 67

    Document object 67 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...

  • Page 68

    68 chapter 3: objects parameters boundingrectangle a rectangle that specifies the bounds of the oval to be added. Bsuppressfill 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. Bsuppressstroke a bool...

  • Page 69

    Document object 69 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().Addnew...

  • Page 70

    70 chapter 3: objects 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.G...

  • Page 71

    Document object 71 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 tex...

  • Page 72

    72 chapter 3: objects 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. Us...

  • Page 73

    Document object 73 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. Usa...

  • Page 74

    74 chapter 3: objects 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().B...

  • Page 75

    Document object 75 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 docu...

  • Page 76

    76 chapter 3: objects 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() para...

  • Page 77

    Document object 77 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...

  • Page 78

    78 chapter 3: objects 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 ...

  • Page 79

    Document object 79 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.Conver...

  • Page 80

    80 chapter 3: objects 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 def...

  • Page 81

    Document object 81 ++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...

  • Page 82

    82 chapter 3: objects 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.Deleteselectio...

  • Page 83

    Document object 83 document.Distribute() availability flash mx 2004. Usage document.Distribute( distributemode [, busedocumentbounds ] ) parameters distributemode a string that specifies where to distribute the selected object. Valid values for distributemode are "left edge" , "horizontal center" , ...

  • Page 84

    84 chapter 3: objects 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 layer...

  • Page 85

    Document object 85 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 ac...

  • Page 86

    86 chapter 3: objects 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 fl...

  • Page 87

    Document object 87 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 select...

  • Page 88

    88 chapter 3: objects 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 prof...

  • Page 89

    Document object 89 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...

  • Page 90

    90 chapter 3: objects 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 s...

  • Page 91

    Document object 91 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 ...

  • Page 92

    92 chapter 3: objects 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 st...

  • Page 93

    Document object 93 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 st...

  • Page 94

    94 chapter 3: objects 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 metho...

  • Page 95

    Document object 95 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: " +...

  • Page 96

    96 chapter 3: objects 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 bei...

  • Page 97

    Document object 97 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 cu...

  • Page 98

    98 chapter 3: objects 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 ...

  • Page 99

    Document object 99 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 doc...

  • Page 100

    100 chapter 3: objects document.Match() availability flash mx 2004. Usage document.Match( bwidth, bheight [, busedocumentbounds] ) parameters bwidth a boolean value that, when set to true , causes the method to make the widths of the selected items the same. Bheight a boolean value that, when set to...

  • Page 101

    Document object 101 btogglesel a boolean value that specifies the state of the shift key: true for pressed; false for not pressed. Bshiftsel a boolean value that specifies the state of the application preference shift select: true for on; false for off. Returns nothing. Description method; performs ...

  • Page 102

    102 chapter 3: objects document.Moveselectedbezierpointsby() availability flash mx 2004. Usage document.Moveselectedbezierpointsby( delta ) parameters delta 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, pass...

  • Page 103

    Document object 103 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().Moveselection...

  • Page 104

    104 chapter 3: objects 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º...

  • Page 105

    Document object 105 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 fol...

  • Page 106

    106 chapter 3: objects 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...

  • Page 107

    Document object 107 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,...

  • Page 108

    108 chapter 3: objects 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 ...

  • Page 109

    Document object 109 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 ...

  • Page 110

    110 chapter 3: objects 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.Savedocumen...

  • Page 111

    Document object 111 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...

  • Page 112

    112 chapter 3: objects 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 ...

  • Page 113

    Document object 113 • 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 s...

  • Page 114

    114 chapter 3: objects //begin loop through the elements on a layer for(var c=0; 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.Name == "mymo...

  • Page 115

    Document object 115 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...

  • Page 116

    116 chapter 3: objects 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);...

  • Page 117

    Document object 117 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 s...

  • Page 118

    118 chapter 3: objects 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.Getd...

  • Page 119

    Document object 119 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.Setinstancebr...

  • Page 120

    120 chapter 3: objects 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...

  • Page 121

    Document object 121 breplacecurrentselection 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 . Returns nothing. Description method; draws a rectangular selection marquee relative ...

  • Page 122

    122 chapter 3: objects 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 ...

  • Page 123

    Document object 123 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 th...

  • Page 124

    124 chapter 3: objects 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...

  • Page 125

    Document object 125 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. Startindex an integer that specifies first character to replace. The first character posit...

  • Page 126

    126 chapter 3: objects 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...

  • Page 127

    Document object 127 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 po...

  • Page 128

    128 chapter 3: objects 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().Smoo...

  • Page 129

    Document object 129 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 t...

  • Page 130

    130 chapter 3: objects 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 mov...

  • Page 131

    Document object 131 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...

  • Page 132

    132 chapter 3: objects 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 flo...

  • Page 133

    Document object 133 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 elemen...

  • Page 134

    134 chapter 3: objects 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...

  • Page 135: Chapter 3

    Drawinglayer object 135 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 crea...

  • Page 136

    136 chapter 3: objects 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 refe...

  • Page 137

    Drawinglayer object 137 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 ...

  • Page 138

    138 chapter 3: objects 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 po...

  • Page 139

    Drawinglayer object 139 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 draw...

  • Page 140

    140 chapter 3: objects 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. Y a floating-point value that specifies the y coordinate of the position at which to...

  • Page 141

    Drawinglayer object 141 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 persis...

  • Page 142: Chapter 3

    142 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: property summary for the edge object the following properties are availab...

  • Page 143

    Edge object 143 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 index a...

  • Page 144

    144 chapter 3: objects 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...

  • Page 145

    Edge object 145 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 2...

  • Page 146: Chapter 3

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

  • Page 147

    Effect object 147 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 le...

  • Page 148

    148 chapter 3: objects 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 val...

  • Page 149: Chapter 3

    Element object 149 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 f...

  • Page 150

    150 chapter 3: objects 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...

  • Page 151

    Element object 151 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...

  • Page 152

    152 chapter 3: objects 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.Getpersis...

  • Page 153

    Element object 153 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 t...

  • Page 154

    154 chapter 3: objects 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 exampl...

  • Page 155

    Element object 155 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" , "integerarray" , "double" , "doublearray" , "string" , and "bytearray" . Value...

  • Page 156

    156 chapter 3: objects 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() . Usin...

  • Page 157: Chapter 3

    Embeddedvideoinstance object 157 embeddedvideoinstance object inheritance 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 embeddedv...

  • Page 158: Chapter 3

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

  • Page 159

    Fill object 159 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 ...

  • Page 160

    160 chapter 3: objects 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 a...

  • Page 161: Chapter 3

    Flash object 161 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 ...

  • Page 162

    162 chapter 3: objects property summary for the flash object the following properties can be used with the flash object. 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 s...

  • Page 163

    Flash object 163 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 fo...

  • Page 164

    164 chapter 3: objects 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 an...

  • Page 165

    Flash object 165 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] , tru...

  • Page 166

    166 chapter 3: objects 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 speci...

  • Page 167

    Flash object 167 //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 followi...

  • Page 168

    168 chapter 3: objects 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.Createnewtem...

  • Page 169

    Flash object 169 fl.Effects availability flash mx 2004. Usage fl.Effects description read-only property; an array of effect object s, 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 de...

  • Page 170

    170 chapter 3: objects 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 dis...

  • Page 171

    Flash object 171 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...

  • Page 172

    172 chapter 3: objects 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 meth...

  • Page 173

    Flash object 173 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 follo...

  • Page 174

    174 chapter 3: objects 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 chan...

  • Page 176

    176 chapter 3: objects 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 ...

  • Page 177

    Flash object 177 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( documentobjec...

  • Page 178

    178 chapter 3: objects 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 wit...

  • Page 179

    Flash object 179 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 documen...

  • Page 180

    180 chapter 3: objects parameters document a document object that specifies the document to save. If document is null , the active document is saved. Returns a boolean value: true if the save as operation completes successfully; false otherwise. Description method; displays the save as dialog box fo...

  • Page 181

    Flash object 181 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 ...

  • Page 182

    182 chapter 3: objects 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 xml...

  • Page 183: Chapter 3

    Folderitem object 183 folderitem object inheritance item object > folderitem object availability flash mx 2004. Description the folderitem object is a subclass of the item object . There are no unique methods or properties of folderitem. Chapter 3 objects.

  • Page 184: Chapter 3

    184 chapter 3: objects fontitem object inheritance item object > fontitem object availability flash mx 2004. Description the fontitem object is a subclass of the item object . There are no unique methods or properties of fontitem. Chapter 3 objects.

  • Page 185: Chapter 3

    Frame object 185 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 actionscrip...

  • Page 186

    186 chapter 3: objects frame.Actionscript availability flash mx 2004. Usage frame.Actionscript description property; a string representing actionscript code. Example the following example assigns stop() to first frame top layer action: fl.Getdocumentdom().Gettimeline().Layers[0].Frames[0].Actionscri...

  • Page 187

    Frame object 187 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...

  • Page 188

    188 chapter 3: objects 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 =...

  • Page 189

    Frame object 189 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 ...

  • Page 190

    190 chapter 3: objects 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 ...

  • Page 191

    Frame object 191 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 ri...

  • Page 192

    192 chapter 3: objects 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 . Fr...

  • Page 193

    Frame object 193 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...

  • Page 194

    194 chapter 3: objects 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...

  • Page 195: Chapter 3

    Halfedge object 195 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, yo...

  • Page 196

    196 chapter 3: objects 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....

  • Page 197

    Halfedge object 197 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 ...

  • Page 198

    198 chapter 3: objects 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 shape = fl.Getdocumentdom().Selection[0]; var edge = shape.Edges[0]; var hedge = edge.Gethalfe...

  • Page 199: Chapter 3

    Instance object 199 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:...

  • Page 200

    200 chapter 3: objects 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.Items[0];.

  • Page 201: Chapter 3

    Item object 201 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. Property summary for the ite...

  • Page 202

    202 chapter 3: objects 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" , "double" , "doublearray" , "string" , and...

  • Page 203

    Item object 203 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...

  • Page 204

    204 chapter 3: objects 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.Linkageexpor...

  • Page 205

    Item object 205 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...

  • Page 206

    206 chapter 3: objects 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 t...

  • Page 207

    Item object 207 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 speci...

  • Page 208: Chapter 3

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

  • Page 209

    Layer object 209 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().Laye...

  • Page 210

    210 chapter 3: objects } } 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: ...

  • Page 211

    Layer object 211 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...

  • Page 212

    212 chapter 3: objects 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 laye...

  • Page 213: Chapter 3

    Library object 213 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 t...

  • Page 214

    214 chapter 3: objects property summary for the library object the following property is available for the library object. Library.Additemtodocument() availability flash mx 2004. Usage library.Additemtodocument( position [, namepath] ) parameters position a point that specifies the x,y position of t...

  • Page 215

    Library object 215 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, f...

  • Page 216

    216 chapter 3: objects 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 e...

  • Page 217

    Library object 217 parameters namepath 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 ...

  • Page 218

    218 chapter 3: objects library.Finditemindex() availability flash mx 2004. Usage library.Finditemindex( namepath ) parameters namepath 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. Returns an integer value representi...

  • Page 219

    Library object 219 library.Getitemtype() availability flash mx 2004. Usage library.Getitemtype( [ namepath ] ) parameters namepath 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 th...

  • Page 220

    220 chapter 3: objects 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 a string that provides the name ...

  • Page 221

    Library object 221 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/s...

  • Page 222

    222 chapter 3: objects 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 tha...

  • Page 223

    Library object 223 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...

  • Page 224

    224 chapter 3: objects parameters namepath 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. Breplacecurrentselection a boolean value that specifies whether to replace the current selection or add the item to the current...

  • Page 225

    Library object 225 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 property ...

  • Page 226

    226 chapter 3: objects 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...

  • Page 227: Chapter 3

    Linkedvideoinstance object 227 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 linkedvideoin...

  • Page 228: Chapter 3

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

  • Page 229

    Math object 229 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; ...

  • Page 230: Chapter 3

    230 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: matrix.A availability flash mx 2004. Usage matrix.A description prop...

  • Page 231

    Matrix object 231 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...

  • Page 232

    232 chapter 3: objects 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 av...

  • Page 233

    Matrix object 233 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 m...

  • Page 234: Chapter 3

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

  • Page 235

    Outputpanel object 235 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. Bappendtofile optional parameter, if it has a value of true , appends the output p...

  • Page 236

    236 chapter 3: objects 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 "hel...

  • Page 237: Chapter 3

    Parameter object 237 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...

  • Page 238

    238 chapter 3: objects 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. Para...

  • Page 239

    Parameter object 239 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 valu...

  • Page 240

    240 chapter 3: objects 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...

  • Page 241

    Parameter object 241 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 pa...

  • Page 242: Chapter 3

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

  • Page 243

    Path object 243 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 nu...

  • Page 244

    244 chapter 3: objects 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...

  • Page 245

    Path object 245 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...

  • Page 246

    246 chapter 3: objects 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 paramete...

  • Page 247

    Path object 247 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 mypa...

  • Page 248: Chapter 3

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

  • Page 249

    Screen object 249 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 t...

  • Page 250

    250 chapter 3: objects 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 th...

  • Page 251

    Screen object 251 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 fir...

  • Page 252

    252 chapter 3: objects 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 assi...

  • Page 253

    Screen object 253 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...

  • Page 254

    254 chapter 3: objects 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 t...

  • Page 255

    Screen object 255 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 examp...

  • Page 256: Chapter 3

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

  • Page 257

    Screenoutline object 257 property summary for the screenoutline object you can use the following properties with the screenoutline object: screenoutline.Copyscreenfromfile() availability flash mx 2004. Usage screenoutline.Copyscreenfromfile( fileuri [, screenname] ) parameters fileuri astring that s...

  • Page 258

    258 chapter 3: objects 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...

  • Page 259

    Screenoutline object 259 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 d...

  • Page 260

    260 chapter 3: objects fl.Trace(myarray[i].Name) } screenoutline.Insertnestedscreen() availability flash mx 2004. Usage screenoutline.Insertnestedscreen( [ name [, referencescreen [, screentypename ] ] ]) parameters name a string indicating the name of the new screen to insert. An empty name will in...

  • Page 261

    Screenoutline object 261 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 ch...

  • Page 262

    262 chapter 3: objects 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 [, oldscr...

  • Page 263

    Screenoutline object 263 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 descriptio...

  • Page 264

    264 chapter 3: objects 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 ...

  • Page 265

    Screenoutline object 265 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 s...

  • Page 266: Chapter 3

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

  • Page 267

    Shape object 267 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 i...

  • Page 268

    268 chapter 3: objects 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.Beginedi...

  • Page 269

    Shape object 269 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...

  • Page 270: Chapter 3

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

  • Page 271

    Sounditem object 271 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" ,...

  • Page 272

    272 chapter 3: objects 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 boole...

  • Page 273

    Sounditem object 273 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 ...

  • Page 274: Chapter 3

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

  • Page 275

    Stroke object 275 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 ...

  • Page 276

    276 chapter 3: objects 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 ...

  • Page 277

    Stroke object 277 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 ...

  • Page 278

    278 chapter 3: objects 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 str...

  • Page 279

    Stroke object 279 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" , ...

  • Page 280

    280 chapter 3: objects 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" , "...

  • Page 281

    Stroke object 281 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...

  • Page 282

    282 chapter 3: objects 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 p...

  • Page 283

    Stroke object 283 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...

  • Page 284: Chapter 3

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

  • Page 285

    Symbolinstance object 285 symbolinstance.Accname availability flash mx 2004. Usage symbolinstance.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. This property is not available for grap...

  • Page 286

    286 chapter 3: objects 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" :...

  • Page 287

    Symbolinstance object 287 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 ...

  • Page 288

    288 chapter 3: objects 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...

  • Page 289

    Symbolinstance object 289 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 speci...

  • Page 290

    290 chapter 3: objects 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 pe...

  • Page 291

    Symbolinstance object 291 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 proper...

  • Page 292

    292 chapter 3: objects 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 ani...

  • Page 293

    Symbolinstance object 293 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...

  • Page 294: Chapter 3

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

  • Page 295

    Symbolitem object 295 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...

  • Page 296

    296 chapter 3: objects 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; exp...

  • Page 297

    Symbolitem object 297 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 sourc...

  • Page 298

    298 chapter 3: objects example the following example obtains and shows the number of layers that the selected movie clip in the library contains: var tl = fl.Getdocumentdom().Library.Getselecteditems()[0].Timeline; alert(tl.Layercount);.

  • Page 299: Chapter 3

    Textattrs object 299 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...

  • Page 300

    300 chapter 3: objects 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...

  • Page 301

    Textattrs object 301 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...

  • Page 302

    302 chapter 3: objects 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 use...

  • Page 303

    Textattrs object 303 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...

  • Page 304

    304 chapter 3: objects 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 inde...

  • Page 305

    Textattrs object 305 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 orientatio...

  • Page 306

    306 chapter 3: objects 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")); t...

  • Page 307: Chapter 3

    Text object 307 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 ...

  • Page 308

    308 chapter 3: objects text.Accname availability flash mx 2004. Usage text.Accname 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 in...

  • Page 309

    Text object 309 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....

  • Page 310

    310 chapter 3: objects 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 t...

  • Page 311

    Text object 311 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 th...

  • Page 312

    312 chapter 3: objects 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].Gette...

  • Page 313

    Text object 313 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()....

  • Page 314

    314 chapter 3: objects 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...

  • Page 315

    Text object 315 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 exampl...

  • Page 316

    316 chapter 3: objects 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...

  • Page 317

    Text object 317 endindex an integer that is a range of text, which starts at startindex and goes up to, but not including, endindex . This parameter is optional. Returns nothing. Description method; sets the attribute specified by the attrname parameter associated with the text identified by startin...

  • Page 318

    318 chapter 3: objects 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 endin...

  • Page 319

    Text object 319 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...

  • Page 320

    320 chapter 3: objects 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.Getdocumentd...

  • Page 321

    Text object 321 text.Variablename availability flash mx 2004. Usage text.Variablename description property; a string that contains the name of the variable associated with the text object. This property works only with dynamic or input text; it generates a warning if used with other text types..

  • Page 322: Chapter 3

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

  • Page 323

    Textrun object 323 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.Trace(prop + " = " + curtextattrs[pro...

  • Page 324: Chapter 3

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

  • Page 325

    Timeline object 325 property summary for the timeline object the following methods are available for the timeline object. Timeline.Getframeproperty() retrieves the specified property’s value for the selected frames. Timeline.Getlayerproperty() retrieves the specified property’s value for the selecte...

  • Page 326

    326 chapter 3: objects timeline.Addmotionguide() availability flash mx 2004. Usage timeline.Addmotionguide() parameters none. Returns an integer that represents the zero-based index of the newly added guide layer. If the current layer type is not of type “normal”, flash returns -1. Description metho...

  • Page 327

    Timeline object 327 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. Layertype a string that specifies the type of laye...

  • Page 328

    328 chapter 3: objects 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()...

  • Page 329

    Timeline object 329 parameters startframeindex a zero-based index that specifies the starting frame to convert to keyframes. If you omit startframeindex , the method converts the currently selected frames. This parameter is optional. Endframeindex a zero-based index that specifies the frame at which...

  • Page 330

    330 chapter 3: objects 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 fro...

  • Page 331

    Timeline object 331 timeline.Createmotiontween() availability flash mx 2004. Usage timeline.Createmotiontween([startframeindex [, endframeindex]]) parameters startframeindex a zero-based index that specifies the beginning frame at which to create a motion tween. If you omit startframeindex , the met...

  • Page 332

    332 chapter 3: objects 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 i...

  • Page 333

    Timeline object 333 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 (rememb...

  • Page 334

    334 chapter 3: objects parameters bexpand a boolean value that, if set to true , causes the method to expand the folder; false causes the method to collapse the folder. Brecursenestedparents a boolean value that, if set to true , causes all the layers within the specified folder to be opened or clos...

  • Page 335

    Timeline object 335 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. Ex...

  • Page 336

    336 chapter 3: objects 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. Endframeindex a zero-based index that specifies the end of the range of fram...

  • Page 337

    Timeline object 337 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 selectio...

  • Page 338

    338 chapter 3: objects timeline.Insertblankkeyframe() availability flash mx 2004. Usage timeline.Insertblankkeyframe([framenumindex]) parameters framenumindex a zero-based index that specifies the frame at which to insert the keyframe. If you omit framenumindex , the method uses the current playhead...

  • Page 339

    Timeline object 339 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. Framenumindex a ze...

  • Page 340

    340 chapter 3: objects 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); t...

  • Page 341

    Timeline object 341 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 ...

  • Page 342

    342 chapter 3: objects 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...

  • Page 343

    Timeline object 343 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; f...

  • Page 344

    344 chapter 3: objects timeline.Reverseframes() availability flash mx 2004. Usage timeline.Reverseframes([startframeindex [, endframeindex]]) parameters startframeindex a zero-based index that specifies the first frame at which to start reversing frames. If you omit startframeindex , the method uses...

  • Page 345

    Timeline object 345 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]]) parame...

  • Page 346

    346 chapter 3: objects timeline.Setlayerproperty() availability flash mx 2004. Usage timeline.Setlayerproperty(property, value [, layerstochange]) parameters property a string that specifies the property to set. For a list of properties, see “layer object” on page 208 . Value the value to which you ...

  • Page 347

    Timeline object 347 breplacecurrentselection 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 . Selectionlist an array of three integers, as returned by timeline.Getselectedframes() ...

  • Page 348

    348 chapter 3: objects 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().Setselect...

  • Page 349: Chapter 3

    Toolobj object 349 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 th...

  • Page 350

    350 chapter 3: objects 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.Setp...

  • Page 351

    Toolobj object 351 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 r...

  • Page 352

    352 chapter 3: objects 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...

  • Page 353

    Toolobj object 353 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 valu...

  • Page 354

    354 chapter 3: objects 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. Exampl...

  • Page 355

    Toolobj object 355 the movie property inspector has the following controls: 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....

  • Page 356: Chapter 3

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

  • Page 357

    Tools object 357 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 ...

  • Page 358

    358 chapter 3: objects 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...

  • Page 359

    Tools object 359 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.Penlo...

  • Page 360

    360 chapter 3: objects 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...

  • Page 361: Chapter 3

    Vertex object 361 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. Property summary for the vertex object the ...

  • Page 362

    362 chapter 3: objects usage vertex.Setlocation( x, y ) parameters x a floating point value that specifies the x coordinate of where the vertex should be positioned, in pixels. Y a floating point value that specifies the y coordinate of where the vertex should be positioned, in pixels. Returns nothi...

  • Page 363

    Vertex object 363 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 ..

  • Page 364: Chapter 3

    364 chapter 3: objects videoitem object inheritance 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.

  • Page 365: Chapter 3

    Xmlui object 365 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 java...

  • Page 366

    366 chapter 3: objects 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 xml...

  • Page 367

    Xmlui object 367 parameters name a string that specifies the name of xmlui property to modify. Value 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..

  • Page 368

    368 chapter 3: objects.

  • Page 369: Chapter 4

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

  • Page 370

    370 chapter 4: c-level extensibility ■ 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...

  • Page 371

    How integrating c functions works 371 #define js_false 0 /***************************************************************************** * public functions ****************************************************************************/ /* jsbool js_definefunction(unsigned short *name, jsnative call, un...

  • Page 372

    372 chapter 4: c-level extensibility /* jsval js_integertovalue(long lv); */ #define js_integertovalue(lv) (((jsval)(lv) /* jsval js_booleantovalue(jsbool bv); */ #define js_booleantovalue(bv) (((jsval)(bv) /* jsval js_objecttovalue(jsobject *obj); */ #define js_objecttovalue(ov) ((jsval)(ov)) /* un...

  • Page 373

    How integrating c functions works 373 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, jsv...

  • Page 374

    374 chapter 4: c-level extensibility { \ extern void mm_init(); \ \ char **envptr = (char **)env; \ char **mmptr = (char **)(&mmenv); \ char **envend = (char **)((char *)envptr + envsize); \ char **mmend = (char **)((char *)mmptr + sizeof(mm_environment)); \ \ /* copy fields from env to mmenv, one p...

  • Page 375

    js_valuetointeger(cx, argv[1], &b) == js_false) return js_false; /* perform...

  • Page 376

    376 chapter 4: c-level extensibility 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 ...

  • Page 377

    The c-level api 377 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 m...

  • Page 378

    378 chapter 4: c-level extensibility 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 ...

  • Page 379

    The c-level api 379 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 ...

  • Page 380

    380 chapter 4: c-level extensibility 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 ...

  • Page 381

    The c-level api 381 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 th...

  • Page 382

    382 chapter 4: c-level extensibility • 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 meth...

  • Page 383

    The c-level api 383 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 str...

  • Page 384

    384 chapter 4: c-level extensibility 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 o...

  • Page 385

    The c-level api 385 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 *...

  • Page 386

    386 chapter 4: c-level extensibility.