MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Summary of FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE

  • Page 1

    Actionscript 2.0 language reference.

  • Page 2

    Trademarks 1 step robopdf, activeedit, activetest, authorware, blue sky software, blue sky, breeze, breezo, captivate, central, coldfusion, contribute, database explorer, director, dreamweaver, fireworks, flash, flashcast, flashhelp, flash lite, flashpaper, flash video encoder, flex, flex builder, f...

  • Page 3

    3 contents chapter 1: actionscript language elements. . . . . . . . . . . . . . . . . . 31 compiler directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 #endinitclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents loadmovienum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 loadvariables function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 loadvariablesnum function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 5

    Contents 5 _focusrect property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 _global property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 _highquality property . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents inequality operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 instanceof operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 lt less than (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 7

    Contents 7 if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 implements statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 import statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 8

    8 contents tostring (array.Tostring method). . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 uniquesort (array.Uniquesort property) . . . . . . . . . . . . . . .264 unshift (array.Unshift method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 asbroadcaster . . . . . . . ...

  • Page 9

    Contents 9 noise (bitmapdata.Noise method) . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 palettemap (bitmapdata.Palettemap method). . . . . . . . . . . . . . . . 320 perlinnoise (bitmapdata.Perlinnoise method) . . . . . . . . . . . . . . . . 322 pixeldissolve (bitmapdata.Pixeldissolve m...

  • Page 10

    10 contents onsetfocus (button.Onsetfocus handler). . . . . . . . . . . . . . . . . . . .366 _parent (button._parent property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .367 _quality (button._quality property). . . . . . . . . . . . . . . . . . . . . . . . . . . .368 _rotation (button._r...

  • Page 11

    Contents 11 hasembeddedvideo (capabilities.Hasembeddedvideo property) . . . . . . . . . . . . . . . . 409 hasime (capabilities.Hasime property) . . . . . . . . . . . . . . . . . . . . . . . 409 hasmp3 (capabilities.Hasmp3 property) . . . . . . . . . . . . . . . . . . . . . 409 hasprinting (capabilit...

  • Page 12

    12 contents redoffset (colortransform.Redoffset property) . . . . . . . . . . . . . . . 439 rgb (colortransform.Rgb property) . . . . . . . . . . . . . . . . . . . . . . . . . . 440 tostring (colortransform.Tostring method) . . . . . . . . . . . . . . . . . . . 441 contextmenu . . . . . . . . . . . ...

  • Page 13

    Contents 13 gettime (date.Gettime method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 gettimezoneoffset (date.Gettimezoneoffset method) . . . . . . . . 487 getutcdate (date.Getutcdate method) . . . . . . . . . . . . . . . . . . . . 487 getutcday (date.Getutcday method). . . . . . . ....

  • Page 14

    14 contents angle (dropshadowfilter.Angle property). . . . . . . . . . . . . . . . . . . . .532 blurx (dropshadowfilter.Blurx property) . . . . . . . . . . . . . . . . . . . . .533 blury (dropshadowfilter.Blury property) . . . . . . . . . . . . . . . . . . . . .534 clone (dropshadowfilter.Clone meth...

  • Page 15

    Contents 15 browse (filereferencelist.Browse method) . . . . . . . . . . . . . . . . . . 588 filelist (filereferencelist.Filelist property) . . . . . . . . . . . . . . . . . . 590 filereferencelist constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .591 oncancel (filereferenceli...

  • Page 16

    16 contents ratios (gradientglowfilter.Ratios property) . . . . . . . . . . . . . . . . . . . .647 strength (gradientglowfilter.Strength property) . . . . . . . . . . . . . . 650 type (gradientglowfilter.Type property) . . . . . . . . . . . . . . . . . . . . . . 651 ime (system.Ime) . . . . . . . . ...

  • Page 17

    Contents 17 onkeydown (key.Onkeydown event listener) . . . . . . . . . . . . . . . . 686 onkeyup (key.Onkeyup event listener) . . . . . . . . . . . . . . . . . . . . . . 687 pgdn (key.Pgdn property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687 pgup (key.Pgup property) . . . . . ...

  • Page 18

    18 contents loadstringex (locale.Loadstringex method) . . . . . . . . . . . . . . . . . .739 setdefaultlang (locale.Setdefaultlang method). . . . . . . . . . . . . .740 setloadcallback (locale.Setloadcallback method) . . . . . . . . . . .740 setstring (locale.Setstring method) . . . . . . . . . . . ...

  • Page 19

    Contents 19 rotate (matrix.Rotate method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .777 scale (matrix.Scale method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 tostring (matrix.Tostring method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 tr...

  • Page 20

    20 contents cacheasbitmap (movieclip.Cacheasbitmap property) . . . . . . . . .846 clear (movieclip.Clear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .847 createemptymovieclip (movieclip.Createemptymovieclip method) . . . . . . . . . . . . . . . .848 createtextfield (movieclip.C...

  • Page 21

    Contents 21 ondragover (movieclip.Ondragover handler) . . . . . . . . . . . . . . . . 902 onenterframe (movieclip.Onenterframe handler) . . . . . . . . . . . . 903 onkeydown (movieclip.Onkeydown handler) . . . . . . . . . . . . . . . . 903 onkeyup (movieclip.Onkeyup handler) . . . . . . . . . . . . ...

  • Page 22

    22 contents _y (movieclip._y property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 941 _ymouse (movieclip._ymouse property) . . . . . . . . . . . . . . . . . . . . . 942 _yscale (movieclip._yscale property) . . . . . . . . . . . . . . . . . . . . . . . . 943 moviecliploader ...

  • Page 23

    Contents 23 valueof (number.Valueof method) . . . . . . . . . . . . . . . . . . . . . . . . . . 990 object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990 addproperty (object.Addproperty method). . . . . . . . . . . . . . . . . . . 992 ...

  • Page 24

    24 contents contains (rectangle.Contains method) . . . . . . . . . . . . . . . . . . . . . . 1037 containspoint (rectangle.Containspoint method). . . . . . . . . . . . .1038 containsrectangle (rectangle.Containsrectangle method) . . .1038 equals (rectangle.Equals method) . . . . . . . . . . . . . . ...

  • Page 25

    Contents 25 onstatus (sharedobject.Onstatus handler) . . . . . . . . . . . . . . . . . 1092 sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094 attachsound (sound.Attachsound method) . . . . . . . . . . . . . . . . . 1096 duration (sou...

  • Page 26

    26 contents touppercase (string.Touppercase method) . . . . . . . . . . . . . . . . . 1140 valueof (string.Valueof method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1141 stylesheet (textfield.Stylesheet) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142 clear (stylesheet.Cl...

  • Page 27

    Contents 27 menu (textfield.Menu property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189 mousewheelenabled (textfield.Mousewheelenabled property) . . . . . . . . . . . . . . . . . 1191 multiline (textfield.Multiline property) . . . . . . . . . . . . . . . . . . . . . . . 1192 _name (t...

  • Page 28

    28 contents textformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1228 align (textformat.Align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231 blockindent (textformat.Blockindent property) . . . . . . . . . . . . . . 1232 bo...

  • Page 29

    Contents 29 video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1273 _alpha (video._alpha property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1276 attachvideo (video.Attachvideo method) . . . . . . . . . . . . . . . . . ...

  • Page 30

    30 contents clonenode (xmlnode.Clonenode method). . . . . . . . . . . . . . . . . . 1318 firstchild (xmlnode.Firstchild property) . . . . . . . . . . . . . . . . . . . . .1320 getnamespaceforprefix (xmlnode.Getnamespaceforprefix method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 31

    31 1 chapter 1 actionscript language elements this section provides syntax, usage information, and code samples for global functions and properties (those elements that do not belong to an actionscript class); compiler directives; and for the constants, operators, statements, and keywords used in ac...

  • Page 32

    32 actionscript language elements #include directive #include "[path]filename.As":string includes the contents of the specified file, as if the commands in the file are part of the calling script. The #include directive is invoked at compile time. Therefore, if you make any changes to an external fi...

  • Page 33

    Compiler directives 33 parameters [path]filename.As:string - filename.As the filename and optional path for the script to add to the actions panel or to the current script; .As is the recommended filename extension. Example the following examples show various ways of specifying a path for a file to ...

  • Page 34

    34 actionscript language elements do not place a semicolon (;) at the end of the line that contains the #initclip directive. Availability: actionscript 1.0; flash player 6.0 parameters order:number [optional] - a non-negative integer that specifies the execution order of blocks of #initclip code. Th...

  • Page 35

    Constants 35 constants a constant is a variable used to represent a property whose value never changes. This section describes global constants that are available to every script. Constants summary false constant a unique boolean value that represents the opposite of true . When automatic data typin...

  • Page 36

    36 actionscript language elements // converts it to a string trace("string: " + bool1); // outputs string: false infinity constant specifies the ieee-754 value representing positive infinity. The value of this constant is the same as number.Positive_infinity . Availability: actionscript 1.0; flash p...

  • Page 37

    Constants 37 example the following example shows how newline displays output from the trace() statement on multiple lines. Var myname:string = "lisa", myage:number = 30; trace(myname+myage); trace("-----"); trace(myname+newline+myage); // output: lisa30 ----- lisa 30 see also trace function null con...

  • Page 38

    38 actionscript language elements true constant a unique boolean value that represents the opposite of false . When automatic data typing converts true to a number, it becomes 1; when it converts true to a string, it becomes "true" . Availability: actionscript 1.0; flash player 5 example the followi...

  • Page 39

    Constants 39 in files published for flash player 6 or earlier, the value of number(undefined) is 0 . In files published for flash player 7 or later, the value of number(undefined) is nan . The value undefined is similar to the special value null . When null and undefined are compared with the equali...

  • Page 40

    40 actionscript language elements global functions this section contains a set of built-in functions that are available in any part of a swf file where actionscript is used. These global functions cover a wide variety of common programming tasks such as working with data types ( boolean() , int() , ...

  • Page 41

    Global functions 41 fscommand (command:st ring, parameters:string) lets the swf file communicate with either flash player or the program hosting flash player, such as a web browser. Getproperty (my_mc:st ring, property) returns the value of the specified property for the movie clip my_mc. Gettimer (...

  • Page 42

    42 actionscript language elements loadmovie (url:string , target:object, [method:string]) loads a swf or jpeg file into flash player while the original swf file plays. Loadmovienum (url:str ing, level:number, [method:string]) loads a swf or jpeg file into a level in flash player while the originally...

  • Page 43

    Global functions 43 object ([value:object ]) creates a new empty object or converts the specified number, string, or boolean value to an object. On (mouseevent:object ) specifies the mouse event or keypress that triggers an action. Onclipevent (movieeve nt:object) triggers actions defined for a spec...

  • Page 44

    44 actionscript language elements setinterval (function reference:function, interval:number, [param:object], objectreference:obje ct, methodname:string) calls a function or a method of an object at periodic intervals while a swf file plays. Setproperty (target:o bject, property:object, expression:ob...

  • Page 45

    Global functions 45 array function array() : array array(numelements:number) : array array(element0:object, [element1, element2, ...Elementn]) : array creates a new array of length 0 or more, or an array populated by a list of specified elements, possibly of different data types. Use array() to crea...

  • Page 46

    46 actionscript language elements parameters numelements:number [optional] - a positive integer that specifies the number of elements in the array. You can specify either numelements or the list of elements, but not both. Elementn:object [optional] - one or more parameters, element0, element1, ... ,...

  • Page 47

    Global functions 47 parameters function:string - an identifier for a function. Parameter:string - a string that is passed to the function named in the function parameter. Example in the following example, the playmp3() function is defined. The textfield object list_txt is created and set so html tex...

  • Page 48

    48 actionscript language elements if expression is a string, the return value is as follows: ■ in files published for flash player 6 and earlier, the string is first converted to a number. The value is true if the number is not 0, otherwise the return value is false . ■ in files published for flash ...

  • Page 49

    Global functions 49 this example shows a significant difference between use of the boolean() function and the boolean class. The boolean() function creates a boolean value, and the boolean class creates a boolean object. Boolean values are compared by value, and boolean objects are compared by refer...

  • Page 50

    50 actionscript language elements chr function chr(number:number) : string deprecated since flash player 5. This function was deprecated in favor of string.Fromcharcode() . Converts ascii code numbers to characters. Availability: actionscript 1.0; flash player 4 parameters number:number - an ascii c...

  • Page 51

    Global functions 51 you must clear the interval when you have finished using the function. Create a button called clearint_btn and use the following actionscript to clear setinterval() : clearint_btn.Onrelease = function(){ clearinterval( intervalid ); trace("cleared interval"); }; see also setinter...

  • Page 52

    52 actionscript language elements example in the following example, a new movie clip instance is created called img_mc. An image is loaded into the movie clip, and then the img_mc clip is duplicated. The duplicated clip is called newimg_mc , and this new clip is moved on the stage so it does not ove...

  • Page 53

    Global functions 53 example the following code produces the result someuser%40somedomain%2ecom : var email:string = "someuser@somedomain.Com"; trace(escape(email)); in this example, the at symbol ( @ ) was replaced with %40 and the dot symbol ( . ) was replaced with %2e . This is useful if you're tr...

  • Page 54

    54 actionscript language elements parameters expression:object - the name of a variable, property, object, or movie clip to retrieve. This parameter can be either a string or a direct reference to the object instance (i.E use of quotation marks (" ") is optional.) returns object - a value, reference...

  • Page 55

    Global functions 55 the fscommand() function lets a swf file communicate with a script in a web page. However, script access is controlled by the web page's allowscriptaccess setting. (you set this attribute in the html code that embeds the swf file—for example, in the param tag for internet explore...

  • Page 56

    56 actionscript language elements availability: ■ none of the commands described in the table are available in web players. ■ all of the commands are available in stand-alone applications, such as projectors. ■ only allowscale and exec are available in test-movie players. The exec command can contai...

  • Page 57

    Global functions 57 usage 3: the fscommand() function can send messages to macromedia director. These messages are interpreted by lingo (the director scripting language) as strings, events, or executable lingo code. If a message is a string or an event, you must write the lingo code to receive the m...

  • Page 58

    58 actionscript language elements you must add a function to the web page that contains the swf file. This function, mydocument_dofscommand() , waits for an fscommand() call. When fscommand() is triggered in flash (for example, when a user clicks the button), the command and parameter strings are pa...

  • Page 59

    Global functions 59 returns object - the value of the specified property. Example the following example creates a new movie clip someclip_mc and shows the alpha value ( _alpha ) for the movie clip someclip_mc in the output panel: this.Createemptymovieclip("someclip_mc", 999); trace("the alpha of "+g...

  • Page 60

    60 actionscript language elements parameters url:string - the url from which to obtain the document. Window:string [optional] - specifies the window or html frame into which the document should load. You can enter the name of a specific window or select from the following reserved target names: ■ _s...

  • Page 61

    Global functions 61 you can also use get or post for sending variables. The following example uses get to append variables to a url: var firstname:string = "gus"; var lastname:string = "richardson"; var age:number = 92; mybtn_btn.Onrelease = function() { geturl("http://www.Macromedia.Com", "_blank",...

  • Page 62

    62 actionscript language elements see also os (capabilities.Os property) , version (capabilities.Version property) gotoandplay function gotoandplay([scene:string], frame:object) : void sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playh...

  • Page 63

    Global functions 63 gotoandstop function gotoandstop([scene:string], frame:object) : void sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene.You can use the scene parameter only on the root timeline, not...

  • Page 64

    64 actionscript language elements ifframeloaded function ifframeloaded([scene:string], frame) { statement(s); } deprecated since flash player 5. This function has been deprecated. Macromedia recommends that you use the movieclip._framesloaded property. Checks whether the contents of a specific frame...

  • Page 65

    Global functions 65 isfinite function isfinite(expression:object) : boolean evaluates expression and returns true if it is a finite number or false if it is infinity or negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0. Av...

  • Page 66

    66 actionscript language elements example the following code illustrates return values for the isnan() function: trace( isnan("tree") ); // returns true trace( isnan(56) ); // returns false trace( isnan(number.Positive_infinity) ) // returns false the following example shows how you can use isnan() ...

  • Page 67

    Global functions 67 returns number - the length of the specified string or variable. Example the following example returns the length of the string "hello": length("hello"); the result is 5. See also " string delimiter operator , string , length (string.Length property) loadmovie function loadmovie(...

  • Page 68

    68 actionscript language elements for flash player 8: ■ loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox. ■ loading is not allowed if the calling swf file is in a network sandbox and the movie clip to be loa...

  • Page 69

    Global functions 69 example usage 1: the following example loads the swf file circle.Swf from the same directory and replaces a movie clip called mysquare that already exists on the stage: loadmovie("circle.Swf", mysquare); // equivalent statement (usage 1): loadmovie("circle.Swf", _level0.Mysquare)...

  • Page 70

    70 actionscript language elements loadmovienum function loadmovienum(url:string, level:number, [method:string]) : void loads a swf, jpeg, gif, or png file into a level while the original swf file is playing. Support for unanimated gif files, png files, and progressive jpeg files is added in flash pl...

  • Page 71

    Global functions 71 for flash player 8: ■ loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox. ■ loading is not allowed if the calling swf file is in a network sandbox and the movie clip to be loaded is local. ...

  • Page 72

    72 actionscript language elements example the following example loads the jpeg image tim.Jpg into level 2 of flash player: loadmovienum("http://www.Helpexamples.Com/flash/images/image1.Jpg", 2); see also unloadmovienum function , loadmovie function , loadclip (moviecliploader.Loadclip method) , _lev...

  • Page 73

    Global functions 73 parameters url:string - an absolute or relative url where the variables are located. If the swf file issuing this call is running in a web browser, url must be in the same domain as the swf file; for details, see the description section. Target:object - the target path to a movie...

  • Page 74

    74 actionscript language elements loadvariablesnum function loadvariablesnum(url:string, level:number, [method:string]) : void reads data from an external file, such as a text file or text generated by coldfusion, a cgi script, asp, php, or a perl script, and sets the values for variables in a flash...

  • Page 75

    Global functions 75 example the following example loads information from a text file called params.Txt into the main timeline of the swf at level 2 in flash player. The variable names of the text fields must match the variable names in the params.Txt file. The setinterval() function is used to check...

  • Page 76

    76 actionscript language elements see also fromcharcode (string.Fromcharcode method) mblength function mblength(string:string) : number deprecated since flash player 5. This function was deprecated in favor of the methods and properties of the string class. Returns the length of the multibyte charac...

  • Page 77

    Global functions 77 mbsubstring function mbsubstring(value:string, index:number, count:number) : string deprecated since flash player 5. This function was deprecated in favor of string.Substr() . Extracts a new multibyte character string from a multibyte character string. Availability: actionscript ...

  • Page 78

    78 actionscript language elements availability: actionscript 1.0; flash player 7 parameters command:string - any command that you can use in a flash javascript (jsfl) file. Returns string - a string representation of the result, if any, sent by the javascript statement. Example the following command...

  • Page 79

    Global functions 79 nextframe function nextframe() : void sends the playhead to the next frame. Availability: actionscript 1.0; flash player 2 example in the following example, when the user presses the right or down arrow key, the playhead goes to the next frame and stops. If the user presses the l...

  • Page 80

    80 actionscript language elements example in the following example, when a user clicks the button that is created at runtime, the playhead is sent to frame 1 of the next scene. Create two scenes, and enter the following actionscript on frame 1 of scene 1. Stop(); if (init == undefined) { this.Create...

  • Page 81

    Global functions 81 ■ if expression is a string, the function attempts to parse expression as a decimal number with an optional trailing exponent (that is, 1.57505e-3). ■ if expression is nan , the return value is nan . ■ if expression is undefined , the return value is as follows: - in files publis...

  • Page 82

    82 actionscript language elements object function object([value:object]) : object creates a new empty object or converts the specified number, string, or boolean value to an object. This command is equivalent to creating an object using the object constructor (see "constructor for the object class")...

  • Page 83

    Global functions 83 parameters mouseevent:object - a mouseevent is a trigger called an event . When the event occurs, the statements following it within curly braces ({ }) execute. Any of the following values can be specified for the mouseevent parameter: ■ press the mouse button is pressed while th...

  • Page 84

    84 actionscript language elements onclipevent handler onclipevent(movieevent:object) { // your statements here } triggers actions defined for a specific instance of a movie clip. Availability: actionscript 1.0; flash player 5 parameters movieevent:object - the movieevent is a trigger called an event...

  • Page 85

    Global functions 85 example the following example uses onclipevent() with the keydown movie event and is designed to be attached to a movie clip or button. The keydown movie event is usually used with one or more methods and properties of the key object. The following script uses key.Getcode() to fi...

  • Page 86

    86 actionscript language elements returns number - the ascii code number of the specified character. See also string , charcodeat (string.Charcodeat method) parsefloat function parsefloat(string:string) : number converts a string to a floating-point number. The function reads, or parses, and returns...

  • Page 87

    Global functions 87 parseint function parseint(expression:string, [radix:number]) : number converts a string to an integer. If the specified string in the parameters cannot be converted to a number, the function returns nan . Strings beginning with 0x are interpreted as hexadecimal numbers. Integers...

  • Page 88

    88 actionscript language elements see also , parsefloat function play function play() : void moves the playhead forward in the timeline. Availability: actionscript 1.0; flash player 2 example in the following example, there are two movie clip instances on the stage with the instance names stop_mc an...

  • Page 89

    Global functions 89 see also nextframe function , prevframe (movieclip.Prevframe method) prevscene function prevscene() : void sends the playhead to frame 1 of the previous scene. Availability: actionscript 1.0; flash player 2 see also nextscene function print function print(target:object, boundingb...

  • Page 90

    90 actionscript language elements parameters target:object - the instance name of a movie clip to print. By default, all of the frames in the target instance can be printed. If you want to print specific frames in the movie clip, assign a #p frame label to those frames. Boundingbox:string - a modifi...

  • Page 91

    Global functions 91 printasbitmap function printasbitmap(target:object, boundingbox:string) : void prints the target movie clip as a bitmap according to the boundaries specified in the parameter ( bmovie , bmax , or bframe ). Use printasbitmap() to print movie clips that contain frames with objects ...

  • Page 92

    92 actionscript language elements example the following example prints all of the printable frames in holder_mc with a print area defined by the bounding box of the frame: this.Createemptymovieclip("holder_mc", 999); holder_mc.Loadmovie("http://www.Helpexamples.Com/flash/images/image1.Jpg"); this.My...

  • Page 93

    Global functions 93 boundingbox:string - a modifier that sets the print area of the movie clip. Enclose this parameter in quotation marks (" or '), and specify one of the following values: ■ bmovie designates the bounding box of a specific frame in a movie clip as the print area for all of the print...

  • Page 94

    94 actionscript language elements availability: actionscript 1.0; flash player 5 - if you are authoring for flash player 7 or later, you can create a printjob object, which gives you (and the user) more control over the printing process. For more information, see the printjob class entry. Parameters...

  • Page 95

    Global functions 95 example the following use of random() returns a value of 0, 1, 2, 3, or 4: random(5); see also random (math.Random method) removemovieclip function removemovieclip(target:object) deletes the specified movie clip. Availability: actionscript 1.0; flash player 4 parameters target:ob...

  • Page 96

    96 actionscript language elements setinterval function setinterval(functionreference:function, interval:number, [param1:object, param2, ..., paramn]) : number setinterval(objectreference:object, methodname:string, interval:number, [param1:object, param2, ..., paramn]) : number calls a function or a ...

  • Page 97

    Global functions 97 interval:number - the time in milliseconds between calls to the functionreference or methodname function passed in. If interval is less than the swf file's frame rate (for example, 10 frames per second [fps] is equal to 100 millisecond intervals), the interval function is called ...

  • Page 98

    98 actionscript language elements example 2: the following example is similar to the first, except that it calls clearinterval() before setinterval() . This can help prevent unwanted loops and is especially important in event-based systems where the initiating script can be executed multiple times b...

  • Page 99

    Global functions 99 "powder blue", "mint"); function executecallback(param:string) { trace("executecallback intervalid: " + intervalid + " count: " + count + " param: " + param); clearinterval(intervalid); if(count count++; intervalid = setinterval(this, "executecallback", duration, colors[count]); ...

  • Page 100

    100 actionscript language elements count++; } } in a new document, instantiate a new instance of the new class: var custom:customclass = new customclass(); see also clearinterval function , updateafterevent function , class statement setproperty function setproperty(target:object, property:object, e...

  • Page 101

    Global functions 101 showredrawregions function showredrawregions(enable:boolean, [color:number]) : void provides the ability for the debugger player to outline the regions of the screen that are being redrawn (that is, dirty regions that are being updated). The outlines can also be turned on with t...

  • Page 102

    102 actionscript language elements startdrag function startdrag(target:object, [lock:boolean, left:number, top:number, right:number, bottom:number]) : void makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a startdrag() operation is exec...

  • Page 103

    Global functions 103 stop function stop() : void stops the swf file that is currently playing. The most common use of this action is to control movie clips with buttons. Availability: actionscript 1.0; flash player 2 see also gotoandstop function , gotoandstop (movieclip.Gotoandstop method) stopalls...

  • Page 104

    104 actionscript language elements this.Stop_mc.Onrelease = function() { stopallsounds(); }; see also sound stopdrag function stopdrag() : void stops the current drag operation. Availability: actionscript 1.0; flash player 4 example the following code, placed in the main timeline, stops the drag act...

  • Page 105

    Global functions 105 string function string(expression:object) : string returns a string representation of the specified parameter, as described in the following list: ■ if expression is a number, the return string is a text representation of the number. ■ if expression is a string, the return strin...

  • Page 106

    106 actionscript language elements substring function substring(string:string, index:number, count:number) : string deprecated since flash player 5. This function was deprecated in favor of string.Substr() . Extracts part of a string. This function is one-based, whereas the string object methods are...

  • Page 107

    Global functions 107 example the following example traces the target path of a movie clip as soon as it loads: this.Createemptymovieclip("myclip_mc", this.Getnexthighestdepth()); trace(targetpath(myclip_mc)); // _level0.Myclip_mc see also eval function telltarget function telltarget(target:string) {...

  • Page 108

    108 actionscript language elements the following example uses dot (.) notation to achieve the same results: on(release) { _parent.Ball.Gotoandplay(2); } if you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement: on(release) { with(_...

  • Page 109

    Global functions 109 trace function trace(expression:object) you can use flash debug player to capture output from the trace() function and display the result. Use this statement to record programming notes or to display messages in the output panel while testing a swf file. Use the expression param...

  • Page 110

    110 actionscript language elements unescape function unescape(string:string) : string evaluates the parameter x as a string, decodes the string from url-encoded format (converting all hexadecimal sequences to ascii characters), and returns the string. Availability: actionscript 1.0; flash player 5 p...

  • Page 111

    Global functions 111 example the following example creates a new movie clip called pic_mc and loads an image into that clip. It is loaded using the moviecliploader class. When you click the image, the movie clip unloads from the swf file: var pic_mcl:moviecliploader = new moviecliploader(); pic_mcl....

  • Page 112

    112 actionscript language elements see also loadmovienum function , unloadmovie function , loadmovie (movieclip.Loadmovie method) updateafterevent function updateafterevent() : void updates the display (independent of the frames per second set for the movie) when you call it within an onclipevent() ...

  • Page 113

    Global properties 113 global properties summary modifiers property description _accprops lets you control screen reader accessibility options for swf files, movie clips, buttons, dynamic text fields, and input text fields at runtime. _focusrect property (global); specifies whether a yellow rectangle...

  • Page 114

    114 actionscript language elements _accprops property _accprops.Propertyname instancename._accprops.Propertyname lets you control screen reader accessibilityoptions for swf files, movie clips, buttons, dynamic text fields, and input textfields at runtime. Theseproperties override the corresponding s...

  • Page 115

    Global properties 115 to specify settings that correspond to the tab index setting in the accessibility panel, use the button.Tabindex, movieclip.Tabindex, or textfield.Tabindex properties. There is no way to specify an auto label setting at runtime. To refer to the _accprops object that represents ...

  • Page 116

    116 actionscript language elements after you specify an accessibility property, you can't revert its value to avalue set in the accessibility panel. However, you can set the property to itsdefault value ( false for boolean values; empty strings for stringvalues) by deleting the property from the _ac...

  • Page 117

    Global properties 117 _focusrect property _focusrect = boolean; specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. If _focusrect is set to its default value of true , then a yellow rectangle appears around the currently focused button or movie clip ...

  • Page 118

    118 actionscript language elements _global property _global.Identifier a reference to the global object that holds the core actionscript classes, such as string, object, math, and array. For example, you could create a library that is exposed as a global actionscript object, similar to the math or d...

  • Page 119

    Global properties 119 see also var statement , set variable statement _highquality property _highquality deprecated since flash player 5. This property was deprecated in favor of _quality . Specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) to apply high q...

  • Page 120

    120 actionscript language elements example the following example stops the playhead in the main timeline of the swf file sub.Swf that is loaded into _level9 . The sub.Swf file contains animation and is in the same directory as the document that contains the following actionscript: loadmovienum("sub....

  • Page 121

    Global properties 121 example in the following example, there is a movie clip on the stage with the instance name square_mc . Within that movie clip is another movie clip with an instance name circle_mc . The following actionscript lets you modify the circle_mc parent instance (which is square_mc ) ...

  • Page 122

    122 actionscript language elements availability: actionscript 1.0; flash player 5 example the following example sets the rendering quality to low : _quality = "low"; " high " high rendering quality. This setting is the default rendering quality setting that flash uses. Graphics are anti- aliased usi...

  • Page 123

    Global properties 123 _root property _root.Movieclip _root.Action _root.Property specifies or returns a reference to the root movie clip timeline. If a movie clip has multiple levels, the root movie clip timeline is on the level containing the currently executing script. For example, if a script in ...

  • Page 124

    124 actionscript language elements scroll property textfieldvariablename.Scroll = x deprecated since flash player 5. This property was deprecated in favor of textfield.Scroll . Controls the display of information in a text field associated with a variable. The scroll property defines where the text ...

  • Page 125

    Global properties 125 example the following example streams an mp3 file and buffers the sound before it plays for the user. Two text fields are created at runtime to hold a timer and debugging information. The _soundbuftime property is set to buffer the mp3 for 10 seconds. A new sound object instanc...

  • Page 126

    126 actionscript language elements example create an actionsscript file named applythis.As and then enter the following code: class applythis { var str:string = "defined in applythis.As"; function conctstr(x:string):string { return x+x; } function addstr():string { return str; } } then, in a fla or ...

  • Page 127

    Operators 127 in the following example, the keyword this references the circle object: function circle(radius:number):void { this.Radius = radius; this.Area = math.Pi*math.Pow(radius, 2); } var mycircle = new circle(4); trace(mycircle.Area); in the following statement assigned to a frame inside a mo...

  • Page 128

    128 actionscript language elements & ( bitwise and ) converts expression1 and expression2 to 32-bit unsigned integers, and performs a boolean and operation on each bit of the integer parameters. &= ( bitwise and assignment ) assigns expression1 the value of expression1& expression2. Bitwise left shi...

  • Page 129

    Operators 129 /*..*/ ( block comment delimiter ) indicates one or more lines of script comments. , ( comma ) evaluates expression1 , then expression2 , and so on. Add ( concatenation (strings) ) deprecated since flash player 5. Macromedia recommends that you use the add (+) operator when creating co...

  • Page 130

    130 actionscript language elements ++ ( increment ) a pre-increment and post-increment unary operator that adds 1 to expression . != ( inequality ) tests for the exact opposite of the equality (== ) operator. ( inequality ) deprecated since flash player 5. This operator has been deprecated. Macromed...

  • Page 131

    Operators 131 %= ( modulo assignment ) assigns expression1 the value of expression1 % expression2. * ( multiplication ) multiplies two numerical expressions. *= ( multiplication assignment ) assigns expression1 the value of expression1 * expression2. New creates a new, initially anonymous, object an...

  • Page 132

    132 actionscript language elements + addition operator expression1 + expression2 adds numeric expressions or concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated. If both expressions are integers, the sum is an integer; if ei...

  • Page 133

    Operators 133 usage 3: variables associated with dynamic and input text fields have the data type string. In the following example, the variable deposit is an input text field on the stage. After a user enters a deposit amount, the script attempts to add deposit to oldbalance . However, because depo...

  • Page 134

    134 actionscript language elements example usage 1: this example uses the += operator with a string expression and sends "my name is gilbert" to the output panel. Var x1:string = "my name is "; x1 += "gilbert"; trace(x1); // output: my name is gilbert usage 2: the following example shows a numeric u...

  • Page 135

    Operators 135 usage 2: surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the following example: var my_array:array = ...

  • Page 136

    136 actionscript language elements example the following example shows two ways to create a new empty array object; the first line uses brackets ([]): var my_array:array = []; var my_array:array = new array(); the following example creates an array called employee_array and uses the trace() statemen...

  • Page 137

    Operators 137 = assignment operator expression1 = expression2 assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1 . Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and s...

  • Page 138

    138 actionscript language elements the following example uses assignment by reference to create a new object, and assign a reference to that object to the variable mercury . Assignment by value is then used to assign the value of 3030 to the diameter property of the mercury object: var mercury:objec...

  • Page 139

    Operators 139 operands expression1 : number - a number. Expression2 : number - a number. Returns number - the result of the bitwise operation. Example the following example compares the bit representation of the numbers and returns 1 only if both bits at the same position are 1. In this actionscript...

  • Page 140

    140 actionscript language elements operands expression1 : number - a number. Expression2 : number - a number. Returns number - the value of expression1 & expression2 . Example the following example assigns the value 9 to x : var x:number = 15; var y:number = 9; trace(x &= y); // output: 9 see also &...

  • Page 141

    Operators 141 operands expression1 : number - a number or expression to be shifted left. Expression2 : number - a number or expression that converts to an integer from 0 to 31. Returns number - the result of the bitwise operation. Example in the following example, the integer 1 is shifted 10 bits to...

  • Page 142

    142 actionscript language elements returns number - the result of the bitwise operation. Example in the following example, you use the bitwise left shift and assignment ( ) operator to shift all bits one space to the left: var x:number = 4; // shift all bits one slot to the left. X trace(x); // outp...

  • Page 143

    Operators 143 floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xffffffff; values larger than the maximum have their most significant digits discar...

  • Page 146

    146 actionscript language elements >> bitwise right shift operator expression1 >> expression2 converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2 ...

  • Page 147

    Operators 147 the following example shows the result of the previous example: var x:number = 255; this is because 65535 decimal equals 1111111111111111 binary (sixteen 1s), 1111111111111111 binary shifted right by 8 bits is 11111111 binary, and 11111111 binary is 255 decimal. The most significant bi...

  • Page 148

    148 actionscript language elements example the following commented code uses the bitwise right shift and assignment ( >>= ) operator. Function converttobinary(numbertoconvert:number):string { var result:string = ""; for (var i = 0; i // extract least significant bit using bitwise and var lsb:number ...

  • Page 149

    Operators 149 returns number - the result of the bitwise operation. Example the following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:number = -1 >>> 1; trace(x); // output: 2147483647 this is because -1 decimal is 11111111111111111111111111111111 binary (thirty-t...

  • Page 150

    150 actionscript language elements example see also >>> bitwise unsigned right shift operator , >>= bitwise right shift and assignment operator ^ bitwise xor operator expression1 ^ expression2 converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position wher...

  • Page 152

    152 actionscript language elements /*..*/ block comment delimiter operator /* comment */ /* comment comment */ indicates one or more lines of script comments. Any characters that appear between the opening comment tag ( /* ) and the closing comment tag ( */ ), are interpreted as a comment and ignore...

  • Page 153

    Operators 153 , comma operator (expression1 , expression2 [, expressionn... ]) evaluates expression1 , then expression2 , and so on. This operator is primarily used with the for loop statement and is often used with the parentheses () operator. Availability: actionscript 1.0; flash player 4 operands...

  • Page 154

    154 actionscript language elements the following example uses the comma (,) operator without the parentheses () operator and illustrates that the comma operator sequentially evaluates all of the expressions but returns the value of the first expression. The second expression, z++ , is evaluated and ...

  • Page 155

    Operators 155 returns string - the concatenated string. See also + addition operator ?: conditional operator expression1 ? Expression2 : expression3 instructs flash to evaluate expression1 , and if the value of expression1 is true , it returns the value of expression2 ; otherwise it returns the valu...

  • Page 156

    156 actionscript language elements -- decrement operator --expression expression-- a pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The expression can be a variable, element in an array, or property of an object. The pre- decrement form of the operator ( --exp...

  • Page 157

    Operators 157 operands expression : number - a number or a variable that evaluates to a number. Returns number - the floating-point result of the operation. Example the following statement divides the current width and height of the stage, and then displays the result in the output panel. Trace(stag...

  • Page 158

    158 actionscript language elements see also / division operator . Dot operator object.Property_or_methodinstancename.Variable instancename.Childinstanceinstancename.Childinstance.Variable used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties. The dot ...

  • Page 159

    Operators 159 the following example creates a new movie clip within the _root scope. Then a text field is created inside the movie clip called container_mc . The text field's autosize property is set to true and then populated with the current date. This.Createemptymovieclip("container_mc", this.Get...

  • Page 160

    160 actionscript language elements example the following example uses the equality ( ==) operator with an if statement: var a:string = "david", b:string = "david"; if (a == b) { trace("david is david"); } the following examples show the results of operations that compare mixed types: var x:number = ...

  • Page 161

    Operators 161 compares two expressions for equality and returns a value of true if the string representation of expression1 is equal to the string representation of expression2 , false otherwise. Availability: actionscript 1.0; flash player 4 operands expression1 : object - numbers, strings, or vari...

  • Page 162

    162 actionscript language elements example in the following example, the greater than ( > ) operator is used to determine whether the value of the text field score_txt is greater than 90: if (score_txt.Text>90) { trace("congratulations, you win!"); } else { trace("sorry, try again"); } gt greater th...

  • Page 163

    Operators 163 availability: actionscript 1.0; flash player 4 - in flash 4, > is a numeric operator. In flash 5 or later, the greater than or equal to ( >= ) operator is a comparison operator capable of handling various data types. Flash 4 files that are brought into the flash 5 or later authoring en...

  • Page 164

    164 actionscript language elements returns boolean - the result of the comparison. See also >= greater than or equal to operator ++ increment operator ++expression expression++ a pre-increment and post-increment unary operator that adds 1 to expression . The expression can be a variable, element in ...

  • Page 165

    Operators 165 example the following example uses ++ as a post-increment operator to make a while loop run five times: var i:number = 0; while (i++ trace("this is execution " + i); } /* output: this is execution 1 this is execution 2 this is execution 3 this is execution 4 this is execution 5 */ the ...

  • Page 166

    166 actionscript language elements != inequality operator expression1 != expression2 tests for the exact opposite of the equality ( == ) operator. If expression1 is equal to expression2 , the result is false . As with the equality ( == ) operator, the definition of equal depends on the data types be...

  • Page 167

    Operators 167 the following example illustrates comparison by reference with two functions: var a:function = function() { trace("foo"); }; var b:function = function() { trace("foo"); }; a(); // foo b(); // foo trace(a != b); // true a = b; a(); // foo b(); // foo trace(a != b); // false // trace sta...

  • Page 168

    168 actionscript language elements operands expression1 : object - a number, string, boolean value, variable, object, array, or function. Expression2 : object - a number, string, boolean value, variable, object, array, or function. Returns boolean - the boolean result of the comparison. See also != ...

  • Page 169

    Operators 169 expression1 expression2 compares two expressions and determines whether expression1 is less than expression2 ; if so, the operator returns true . If expression1 is greater than or equal to expression2 , the operator returns false . String expressions are evaluated using alphabetical or...

  • Page 170

    170 actionscript language elements lt less than (strings) operator expression1 lt expression2 deprecated since flash player 5. This operator was deprecated in favor of the (less than) operator. Compares expression1 to expression2 and returns true if expression1 is less than expression2 , false other...

  • Page 171

    Operators 171 returns boolean - the boolean result of the comparison. Example the following examples show true and false results for both numeric and string comparisons: trace(5 trace(2 trace(10 trace("allen" trace("jack" trace("11" trace("11" trace("c" trace("a" le less than or equal to (strings) o...

  • Page 172

    172 actionscript language elements // line comment delimiter operator // comment indicates the beginning of a script comment. Any characters that appear between the comment delimiter ( //) and the end-of-line character are interpreted as a comment and ignored by the actionscript interpreter. Availab...

  • Page 173

    Operators 173 operands expression1 : number - a boolean value or an expression that converts to a boolean value. Expression2 : number - a boolean value or an expression that converts to a boolean value. Returns boolean - a boolean result of the logical operation. Example the following example uses t...

  • Page 174

    174 actionscript language elements returns boolean - a boolean result of the logical operation. See also && logical and operator ! Logical not operator ! Expression inverts the boolean value of a variable or expression. If expression is a variable with the absolute or converted value true , the valu...

  • Page 175

    Operators 175 not logical not operator not expression deprecated since flash player 5. This operator was deprecated in favor of the ! (logical not) operator. Performs a logical not (!) operation in flash player 4. Availability: actionscript 1.0; flash player 4 operands expression : object - a variab...

  • Page 176

    (start)) { tr...

  • Page 177

    logical or operator ,...

  • Page 178

    178 actionscript language elements the first trace returns 2, rather than 12/5 or 2.4, because the modulo ( % ) operator returns only the remainder. The second trace returns 0.0999999999999996 instead of the expected 0.1 because of the limitations of floating-point accuracy in binary computing. See ...

  • Page 179

    Operators 179 * multiplication operator expression1 * expression2 multiplies two numerical expressions. If both expressions are integers, the product is an integer. If either or both expressions are floating-point numbers, the product is a floating- point number. Availability: actionscript 1.0; flas...

  • Page 180

    180 actionscript language elements returns number - the value of expression1 * expression2 . If an expression cannot be converted to a numeric value, it returns nan (not a number). Example usage 1: the following example assigns the value 50 to the variable x : var x:number = 5; var y:number = 10; tr...

  • Page 181

    Operators 181 } book1 = new book("confederacy of dunces", 19.95); book2 = new book("the floating opera", 10.95); the following example uses the new operator to create an array object with 18 elements: golfcourse_array = new array(18); see also [] array access operator , {} object initializer operato...

  • Page 182

    182 actionscript language elements this operator is also used to mark blocks of contiguous code associated with flow control statements ( for , while , if , else , switch ) and functions. Availability: actionscript 1.0; flash player 5 operands object : object - the object to create. Name1,2,...N the...

  • Page 183

    Operators 183 the previous actionscript example can also be written in the following format: var person:object = new object(); person.Name = "gina vechio"; person.Children = new array("ruby", "chickie", "puppa"); see also object () parentheses operator (expression1 [, expression2]) ( expression1, ex...

  • Page 184

    184 actionscript language elements trace((2 + 3) * (4 + 5)); // output: 45trace(2 + (3 * (4 + 5))); // // writes 29 trace(2 + (3 * (4 + 5))); // output: 29trace(2+(3*4)+5); // writes 19 trace(2 + (3 * 4) + 5); // output: 19 usage 2: the following example evaluates the function foo() , and then the f...

  • Page 185

    Operators 185 expression2 : object - a number, string, boolean value, variable, object, array, or function. Returns boolean - the boolean result of the comparison. Example the comments in the following code show the returned value of operations that use the equality and strict equality operators: //...

  • Page 186

    logical or operator , == equality operator !== strict inequality operator expression1 !== expression2 tests for the exact opposite of the strict...

  • Page 187

    Operators 187 trace(s1 === s2); // true trace(s1 === s3); // false trace(s1 === n); // false trace(s1 === b); // false trace(s1 !== s2); // false trace(s1 !== s3); // true trace(s1 !== n); // true trace(s1 !== b); // true see also ! Logical not operator , != inequality operator , && logical and oper...

  • Page 188

    188 actionscript language elements - subtraction operator (negation) -expression (subtraction) expression1 - expression2 used for negating or subtracting. Usage 1: when used for negating, it reverses the sign of the numerical expression . Usage 2: when used for subtracting, it performs an arithmetic...

  • Page 189

    Operators 189 operands expression1 : number - a number or expression that evaluates to a number. Expression2 : number - a number or expression that evaluates to a number. Returns number - the result of the arithmetic operation. Example the following example uses the subtraction assignment ( -=) oper...

  • Page 190

    190 actionscript language elements availability: actionscript 1.0; flash player 6 operands variablename : object - an identifier for a variable. Type a native data type, class name that you have defined, or interface name. Functionname an identifier for a function. Parameter an identifier for a func...

  • Page 191

    Operators 191 returns string - a string representation of the type of expression . The following table shows the results of the typeof operator on each type of expression . See also instanceof operator void operator void expression the void operator evaluates an expression and then discards its valu...

  • Page 192

    192 actionscript language elements statements statements are language elements that perform or specify an action. For example, the return statement returns a result as a value of the function in which it executes. The if statement evaluates a condition to determine the next action that should be tak...

  • Page 193

    Statements 193 function comprises a set of statements that you define to perform a certain task. Get permits implicit getting of properties associated with objects based on classes you have defined in external class files. If evaluates a condition to determine the next action in a swf file. Implemen...

  • Page 194

    194 actionscript language elements break statement break appears within a loop ( for , for..In , do..While or while ) or within a block of statements associated with a particular case within a switch statement. When used in a loop, the break statement instructs flash to skip the rest of the loop bod...

  • Page 195

    Statements 195 case statement case expression : statement(s) defines a condition for the switch statement. If the expression parameter equals the expression parameter of the switch statement using strict equality ( === ), then flash player will execute statements in the statement(s) parameter until ...

  • Page 196

    196 actionscript language elements class statement [dynamic] class classname [ extends superclass ] [ implements interfacename[, interfacename... ] ] { // class definition here } defines a custom class, which lets you instantiate objects that share methods and properties that you define. For example...

  • Page 197

    Statements 197 example the following example creates a class called plant. The plant constructor takes two parameters. // filename plant.As class plant { // define property names and types var leaftype:string; var bloomseason:string; // following line is constructor // because it has the same name a...

  • Page 198

    198 actionscript language elements in an external script file or in the actions panel, use the new operator to create an imageloader object. Var jakob_mc:movieclip = this.Createemptymovieclip("jakob_mc", this.Getnexthighestdepth()); var jakob:imageloader = new imageloader("http://www.Helpexamples.Co...

  • Page 199

    Statements 199 in the following do..While loop, continue causes the flash interpreter to skip the rest of the loop body and jump to the bottom of the loop, where the condition is tested: trace("example 2"); var i:number = 0; do { if (i % 3 == 0) { i++; continue; } trace(i); i++; } while (i in a for ...

  • Page 200

    200 actionscript language elements default statement default: statements defines the default case for a switch statement. The statements execute if the expression parameter of the switch statement doesn't equal (using the strict equality [ === ] operation) any of the expression parameters that follo...

  • Page 201

    Statements 201 delete statement delete reference destroys the object reference specified by the reference parameter, and returns true if the reference is successfully deleted; false otherwise. This operator is useful for freeing memory used by scripts. You can use the delete operator to remove refer...

  • Page 202

    202 actionscript language elements usage 3: the following example deletes an object property: var my_array:array = new array(); my_array[0] = "abc"; // my_array.Length == 1 my_array[1] = "def"; // my_array.Length == 2 my_array[2] = "ghi"; // my_array.Length == 3 // my_array[2] is deleted, but array....

  • Page 203

    Statements 203 availability: actionscript 1.0; flash player 4 parameters condition:boolean - the condition to evaluate. The statement(s) within the do block of code are executed as long as the condition parameter evaluates to true . Example the following example uses a do..While loop to evaluate whe...

  • Page 204

    204 actionscript language elements subclasses of dynamic classes are also dynamic. Be sure to specify the type when declaring an object, as in the following: var x:myclass = new myclass(); if you do not specify the type when declaring an object (as in the following) then the object is considered dyn...

  • Page 205

    Statements 205 if you add an undeclared function, dance , an error is generated, as shown in the following example: trace(""); craig.Dance = true; for (i in craig) { trace("craig." + i + " = " + craig[i]); } /* output: **error** scene=scene 1, layer=layer 1, frame=1:line 14: there is no property wit...

  • Page 206

    206 actionscript language elements example in the following example, the else condition is used to check whether the age_txt variable is greater than or less than 18: if (age_txt.Text>=18) { trace("welcome, user"); } else { trace("sorry, junior"); userobject.Minor = true; userobject.Accessallowed = ...

  • Page 207

    Statements 207 example the following example uses else if statements to compare score_txt to a specified value: if (score_txt.Text>90) { trace("a"); } else if (score_txt.Text>75) { trace("b"); } else if (score_txt.Text>60) { trace("c"); } else { trace("f"); } see also if statement extends statement ...

  • Page 208

    208 actionscript language elements example in the following example, the car class extends the vehicle class so that all of its methods, properties, and functions are inherited. If your script instantiates a car object, methods from both the car class and the vehicle class can be used. The following...

  • Page 209

    Statements 209 the following example instantiates a car object, calls a method that is defined in the vehicle class ( start() ), then calls the method that is overridden by the car class ( stop() ), and finally calls a method from the car class ( activatecaralarm() ): var mynewcar:car = new car(2, "...

  • Page 210

    210 actionscript language elements for statement for(init; condition; next) { statement(s); } evaluates the init (initialize) expression once and then starts a looping sequence. The looping sequence begins by evaluating the condition expression. If the condition expression evaluates to true, stateme...

  • Page 211

    Statements 211 for..In statement for (variableiterant in object) { statement(s); } iterates over the properties of an object or elements in an array and executes the statement for each property or element. Methods of an object are not enumerated by the for..In action. Some properties cannot be enume...

  • Page 212

    212 actionscript language elements the following example uses for..In to iterate over the elements of an array: var myarray:array = new array("one", "two", "three"); for (var index in myarray) trace("myarray["+index+"] = " + myarray[index]); // output: myarray[2] = three myarray[1] = two myarray[0] ...

  • Page 213

    Statements 213 you can use this statement to define a function with the specified functionname , parameters , and statement(s) . When a script calls a function, the statements in the function's definition are executed. Forward referencing is permitted; within the same script, a function may be decla...

  • Page 214

    214 actionscript language elements the following function creates a loadvars object and loads params.Txt into the swf file. When the file successfully loads, variables loaded traces: var mylv:loadvars = new loadvars(); mylv.Load("params.Txt"); mylv.Onload = function(success:boolean) { trace("variabl...

  • Page 215

    Statements 215 enter the following actionscript in a frame on the timeline: var giants:team = new team("san fran", "sfo"); trace(giants.Name); giants.Name = "san francisco"; trace(giants.Name); /* output: san fran san francisco */ when you trace giants.Name, you use the get method to return the valu...

  • Page 216

    216 actionscript language elements the following example uses an if statement to evaluate how long it takes a user to click the submit_btn instance in a swf file. If a user clicks the button more than 10 seconds after the swf file plays, the condition evaluates to true and the message inside the cur...

  • Page 217

    Statements 217 import statement import classname import packagename.* lets you access classes without specifying their fully qualified names. For example, if you want to use a custom class macr.Util.Users.Userclass in a script, you must refer to it by its fully qualified name or import it; if you im...

  • Page 218

    218 actionscript language elements interface statement interface interfacename [extends interfacename ] {} defines an interface. An interface is similar to a class, with the following important differences: ■ interfaces contain only declarations of methods, not their implementation. That is, every c...

  • Page 219

    Statements 219 return 15; } function n(x:number):number { return x * x; } function o():void { trace("o"); } } // external script or actions panel // script file mvar = new d(); trace(mvar.K()); // 15 trace(mvar.N(7)); // 49 trace(mvar.O()); // "o" interface ic extends ia { function p():void; } class...

  • Page 220

    220 actionscript language elements the intrinsic keyword was created specifically to enable compile-time type checking for built-in classes and objects, and global variables and functions. This keyword was not meant for general purpose use, but may be of some value to developers seeking to enable co...

  • Page 221

    Statements 221 trace(mycircle.Radius); trace(mycircle.Getarea()); trace(mycircle.Getdiameter()); see also class statement private statement class someclassname{ private var name; private function name() { // your statements here } } specifies that a variable or function is available only to the clas...

  • Page 222

    222 actionscript language elements as the following code demonstrates, the constructor for the beta class is able to access the privateproperty property that is inherited from the alpha class: var mybeta:beta = new beta(); // output: privateproperty is visible only within class and subclasses attemp...

  • Page 223

    Statements 223 jimmy.Age = 27; jimmy.Name = "jimmy"; if you change one of the public variables in the user class to a private variable, an error is generated when trying to access the property. See also private statement return statement return[expression] specifies the value returned by a function....

  • Page 224

    224 actionscript language elements see also function statement set statement function set property(varname) { // your statements here } permits implicit setting of properties associated with objects based on classes you have defined in external class files. Using implicit set methods lets you modify...

  • Page 225

    Statements 225 gus.Username = "rupert"; trace(gus.Username); // output: rupert in the following example, the get function executes when the value is traced. The set function triggers only when you pass it a value, as shown in the line: gus.Username = "rupert"; see also get statement set variable sta...

  • Page 226

    226 actionscript language elements parameters variablestring:string - a string that names a variable to hold the value of the expression parameter. Example in the following example, you assign a value to a variable. You are assigning the value of "jakob" to the name variable. Set("name", "jakob"); t...

  • Page 227

    Statements 227 example the following example demonstrates how you can use the static keyword to create a counter that tracks how many instances of the class have been created. Because the numinstances variable is static, it will be created only once for the entire class, not for every single instanc...

  • Page 228

    228 actionscript language elements returns both forms invoke a function. The function may return any value. Parameters method:function - the method to invoke in the superclass. Argn - optional parameters that are passed to the superclass version of the method (syntax 1) or to the constructor functio...

  • Page 229

    Statements 229 trace("you pressed e or e"); break; case "i" : case "i" : trace("you pressed i or i"); break; default : trace("you pressed some other key"); break; } }; key.Addlistener(listenerobj); see also === strict equality operator throw statement throw expression generates, or throws, an error ...

  • Page 230

    230 actionscript language elements try { checkemail("joe smith"); } catch (e) { error_txt.Text = e.Tostring(); } in the following example, a subclass of the error class is thrown. The checkemail() function is modified to throw an instance of that subclass. // define error subclass invalidemailerror ...

  • Page 231

    Statements 231 }] encloses a block of code in which an error can occur, and then respond to the error. If any code in the try code block throws an error (using the throw statement), control passes to the catch block, if one exists, and then to the finally code block, if one exists. The finally block...

  • Page 232

    232 actionscript language elements myfunction = function () { trace("this is myfunction"); }; try { myinterval = setinterval(this, "myfunction", 1000); throw new error("my error"); } catch (myerror:error) { trace("error caught: "+myerror); } finally { clearinterval(myinterval); trace("error is clear...

  • Page 233

    Statements 233 var returnval = account.Getaccountinfo(); if (returnval != 0) { throw new error("error getting account information."); } trace("success"); } catch (e) { this.Createtextfield("status_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); status_txt.Autosize = true; status_txt.Text = e.Tostr...

  • Page 234

    234 actionscript language elements finally, in another as file or fla script, the following code invokes the sortrows() method on an instance of the recordset class. It defines catch blocks for each type of error that is thrown by sortrows() import recordset; var myrecordset:recordset = new recordse...

  • Page 235

    Statements 235 parameters variablename:string - an identifier. Example the following actionscript creates a new array of product names. Array.Push adds an element onto the end of the array. If you want to use strict typing, it is essential that you use the var keyword. Without var before product_arr...

  • Page 236

    236 actionscript language elements parameters condition:boolean - an expression that evaluates to true or false . Example in the following example, the while statement is used to test an expression. When the value of i is less than 20, the value of i is traced. When the condition is no longer true ,...

  • Page 237

    Statements 237 to find the value of an identifier in the statement(s) parameter, actionscript starts at the beginning of the scope chain specified by the object and searches for the identifier at each level of the scope chain, in a specific order. The scope chain used by the with statement to resolv...

  • Page 238

    238 actionscript language elements the following code snippet shows how to write the preceding code without using a with statement. Someother_mc._x = 50; someother_mc._y = 100; someother_mc.Gotoandstop(3); the with statement is useful for accessing multiple items in a scope chain list simultaneously...

  • Page 239

    239 2 chapter 2 actionscript classes documentation for actionscript classes includes syntax, usage information, and code samples for methods, properties, and event handlers and listeners that belong to a specific class in actionscript (as opposed to global functions or properties). The classes are l...

  • Page 240

    240 actionscript classes property summary properties inherited from class object method summary methods inherited from class object isactive (accessibility.Isactive method) public static isactive() : boolean indicates whether an accessibility aid is currently active and the player is communicating w...

  • Page 241

    Accessibility 241 returns boolean - a boolean value: true if the flash player is communicating with an accessibility aid (usually a screen reader); false otherwise. Example the following example checks whether an accessibility aid is currently active: if (accessibility.Isactive()) { trace ("an acces...

  • Page 243

    Arguments 243 method summary methods inherited from class object callee (arguments.Callee property) public callee : object a reference to the currently executing function. Availability: actionscript 1.0; flash player 5 see also caller (arguments.Caller property) caller (arguments.Caller property) pu...

  • Page 245

    Array 245 availability: actionscript 1.0; flash player 5 - became a native object in flash player 6, which improved performance significantly. Example in the following example, my_array contains four months of the year: var my_array:array = new array(); my_array[0] = "january"; my_array[1] = "februa...

  • Page 246

    246 actionscript classes method summary modifiers signature description concat ([value:object ]) : array concatenates the elements specified in the parameters with the elements in an array and creates a new array. Join ([delimiter:stri ng]) : string converts the elements in an array to strings, inse...

  • Page 247

    Array 247 methods inherited from class object array constructor public array([value:object]) lets you create an array. You can use the constructor to create different types of arrays: an empty array, an array with a specific length but whose elements have undefined values, or an array whose elements...

  • Page 248

    248 actionscript classes if (my_array[0] == undefined) { // no quotation marks around undefined. Trace("undefined is a special value, not a string"); } // traces: undefined is a special value, not a string. Usage 3: the following example creates the new array object go_gos_array with an initial leng...

  • Page 249

    Array 249 concat (array.Concat method) public concat([value:object]) : array concatenates the elements specified in the parameters with the elements in an array and creates a new array. If the value parameters specify an array, the elements of that array are concatenated, rather than the array itsel...

  • Page 250

    250 actionscript classes trace(x_array[3]); // 1 trace(x_array[4]); // 2, 3 trace(x_array[5]); // 4 descending (array.Descending property) public static descending : number in the sorting methods, this constant specifies descending sort order. You can use this constant for the options parameter in t...

  • Page 251

    Array 251 trace(a_array.Join(" + ")); // displays earth + moon + sun. The following example creates a nested array that contains two arrays. The first array has three elements: europa, io, and callisto. The second array has two elements: titan and rhea. It joins the array by using a plus sign (+), b...

  • Page 252

    252 actionscript classes // a,b,undefined,undefined,undefined,undefined,undefined,undefined,undefine d,c // if the length property is now set to 5, the array will be truncated my_array.Length = 5; trace(my_array.Length); // my_array.Length is updated to 5 trace(my_array); // outputs: a,b,undefined,u...

  • Page 253

    Array 253 example the following code creates the array mypets_array array containing four elements, and then removes its last element: var mypets_array:array = new array("cat", "dog", "bird", "fish"); var popped:object = mypets_array.Pop(); trace(popped); // displays fish. Trace(mypets_array); // di...

  • Page 254

    254 actionscript classes returnindexedarray (array.Returnindexedarray property) public static returnindexedarray : number specifies that a sort returns an indexed array as a result of calling the sort() or sorton() method. You can use this constant for the options parameter in the sort() or sorton()...

  • Page 255

    Array 255 example the following code creates the array mypets_array and then removes the first element from the array and assigns it to the variable shifted : var mypets_array:array = new array("cat", "dog", "bird", "fish"); var shifted:object = mypets_array.Shift(); trace(shifted); // displays "cat...

  • Page 256

    256 actionscript classes example the following example creates an array of five pets and uses slice() to populate a new array that contains only four-legged pets: var mypets_array:array = new array("cat", "dog", "fish", "canary", "parrot"); var myfourleggedpets_array:array = new array(); var myfourl...

  • Page 257

    Array 257 availability: actionscript 1.0; flash player 5 - array sorting option added in flash player 7. Parameters comparefunction:object [optional] - a comparison function used to determine the sorting order of elements in an array. Given the elements a and b, the result of comparefunction can hav...

  • Page 258

    258 actionscript classes example usage 1: the following example shows the use of array.Sort() with and without a value passed for options : var fruits_array:array = new array("oranges", "apples", "strawberries", "pineapples", "cherries"); trace(fruits_array); // displays oranges,apples,strawberries,...

  • Page 259

    Array 259 sorton (array.Sorton method) public sorton(fieldname:object, [options:object]) : array sorts the elements in an array according to one or more fields in the array. The array should have the following characteristics: ■ the array is an indexed array, not an associative array. ■ each element...

  • Page 260

    260 actionscript classes availability: actionscript 1.0; flash player 6 - the options parameter was added in flash player 7. The ability to use different options parameters on multiple sort fields was added in flash player 8. Parameters fieldname:object - a string that identifies a field to be used ...

  • Page 261

    Array 261 } // results: // john, omaha // john, kansas city // bob, omaha rec_array.Sorton(["name", "city"]); for(i=0; i trace(rec_array[i].Name + ", " + rec_array[i].City); } // results: // bob, omaha // john, kansas city // john, omaha rec_array.Sorton(["city", "name" ]); for(i=0; i trace(rec_arra...

  • Page 263

    Array 263 parameters startindex:number - an integer that specifies the index of the element in the array where the insertion or deletion begins. You can specify a negative integer to specify a position relative to the end of the array (for example, -1 is the last element of the array). Deletecount:n...

  • Page 264

    264 actionscript classes tostring (array.Tostring method) public tostring() : string returns a string value representing the elements in the specified array object. Every element in the array, starting with index 0 and ending with the highest index, is converted to a concatenated string and separate...

  • Page 265

    Asbroadcaster 265 unshift (array.Unshift method) public unshift(value:object) : number adds one or more elements to the beginning of an array and returns the new length of the array. Availability: actionscript 1.0; flash player 5 parameters value:object - one or more numbers, elements, or variables ...

  • Page 266

    266 actionscript classes property summary properties inherited from class object method summary methods inherited from class object addlistener (asbroadcaster.Addlistener method) public addlistener(listenerobj:object) : boolean registers an object to receive event notification messages. This method ...

  • Page 267

    Asbroadcaster 267 parameters listenerobj:object - the name of the listener object that receives event notification. Returns boolean - although this method technically returns a boolean value, in practical terms it returns void because it always returns the value true . Example the following example ...

  • Page 268

    268 actionscript classes parameters eventname:string - the name of the event to broadcast. The name of any listener methods must match this parameter in order to receive the broadcast event. You can pass arguments to the listener methods by including additional arguments after eventname . Example th...

  • Page 269

    Asbroadcaster 269 parameters obj:object - an object to serve as a broadcasting object. Example the following example creates a generic object, someobject , and turns it into an event broadcaster. The output should be the strings shown in the two trace() statements: var someobject:object = new object...

  • Page 270

    270 actionscript classes _listeners (asbroadcaster._listeners property) a list of references to all registered listener objects. This property is intended for internal use, and is not intended for direct manipulation. Objects are added to and removed from this array by calls to the addlistener() and...

  • Page 271

    Asbroadcaster 271 // cycle through all listener objects, listing all properties of each listener object for (var i:number = 0; i trace("listener " + i + " listens for these events:"); for (item in someobject._listeners[i]) { trace (" " + item + ": " + someobject._listeners[i][item]); } } see also in...

  • Page 273

    Bevelfilter (flash.Filters.Bevelfilter) 273 see also filters (movieclip.Filters property) , cacheasbitmap (movieclip.Cacheasbitmap property) , filters (button.Filters property) , cacheasbitmap (button.Cacheasbitmap property) , filters (textfield.Filters property) , applyfilter (bitmapdata.Applyfilte...

  • Page 274

    274 actionscript classes constructor summary method summary methods inherited from class bitmapfilter methods inherited from class object signature description bevelfilter ([distanc e:number], [angle:number], [highlightcolor:numb er], [highlightalpha:numb er], [shadowcolor:number] , [shadowalpha:num...

  • Page 275

    Bevelfilter (flash.Filters.Bevelfilter) 275 angle (bevelfilter.Angle property) public angle : number the angle of the bevel. Valid values are from 0 to 360 degrees. The default value is 45. The angle value represents the angle of the theoretical light source falling on the object and determines the ...

  • Page 276

    276 actionscript classes bevelfilter constructor public bevelfilter([distance:number], [angle:number], [highlightcolor:number], [highlightalpha:number], [shadowcolor:number], [shadowalpha:number], [blurx:number], [blury:number], [strength:number], [quality:number], [type:string], [knockout:boolean])...

  • Page 277

    Bevelfilter (flash.Filters.Bevelfilter) 277 type:string [optional] - the type of bevel. Valid values are "inner" , "outer" , and "full" . The default value is "inner" . Knockout:boolean [optional] - applies a knockout effect ( true ), which effectively makes the object's fill transparent and reveals...

  • Page 278

    278 actionscript classes rect.Lineto(w, h); rect.Lineto(0, h); rect.Lineto(0, 0); rect._x = 20; rect._y = 20; return rect; } blurx (bevelfilter.Blurx property) public blurx : number the amount of horizontal blur in pixels. Valid values are from 0 to 255 (floating point). The default value is 4. Valu...

  • Page 279

    Bevelfilter (flash.Filters.Bevelfilter) 279 var filter:bevelfilter = new bevelfilter(5, 45, 0xffff00, .8, 0x0000ff, .8, 20, 20, 1, 3, "inner", false); rect.Filters = new array(filter); return rect; } blury (bevelfilter.Blury property) public blury : number the amount of vertical blur in pixels. Vali...

  • Page 280

    280 actionscript classes var filter:bevelfilter = new bevelfilter(5, 45, 0xffff00, .8, 0x0000ff, .8, 20, 20, 1, 3, "inner", false); rect.Filters = new array(filter); return rect; } clone (bevelfilter.Clone method) public clone() : bevelfilter returns a copy of this filter object. Availability: actio...

  • Page 281

    Bevelfilter (flash.Filters.Bevelfilter) 281 // >> highlightalpha: 0.8 // >> highlightcolor: 16776960 // >> angle: 45 // >> distance: 5 } for(var i in clonedfilter) { trace(">> " + i + ": " + clonedfilter[i]); // >> clone: [type function] // >> type: inner // >> blury: 20 // >> blurx: 20 // >> knocko...

  • Page 282

    282 actionscript classes distance (bevelfilter.Distance property) public distance : number the offset distance of the bevel. Valid values are in pixels (floating point). The default value is 4. Availability: actionscript 1.0; flash player 8 example the following example changes the distance property...

  • Page 283

    Bevelfilter (flash.Filters.Bevelfilter) 283 highlightalpha (bevelfilter.Highlightalpha property) public highlightalpha : number the alpha transparency value of the highlight color. The value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The defaul...

  • Page 284

    284 actionscript classes highlightcolor (bevelfilter.Highlightcolor property) public highlightcolor : number the highlight color of the bevel. Valid values are in hexadecimal format, 0xrrggbb. The default value is 0xffffff. Availability: actionscript 1.0; flash player 8 example the following example...

  • Page 285

    Bevelfilter (flash.Filters.Bevelfilter) 285 knockout (bevelfilter.Knockout property) public knockout : boolean applies a knockout effect ( true ), which effectively makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout). Availab...

  • Page 286

    286 actionscript classes quality (bevelfilter.Quality property) public quality : number the number of times to apply the filter. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more q...

  • Page 287

    Bevelfilter (flash.Filters.Bevelfilter) 287 shadowalpha (bevelfilter.Shadowalpha property) public shadowalpha : number the alpha transparency value of the shadow color. This value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The default value is ...

  • Page 288

    288 actionscript classes shadowcolor (bevelfilter.Shadowcolor property) public shadowcolor : number the shadow color of the bevel. Valid values are in hexadecimal format, 0xrrggbb. The default value is 0x000000. Availability: actionscript 1.0; flash player 8 example the following example changes the...

  • Page 289

    Bevelfilter (flash.Filters.Bevelfilter) 289 strength (bevelfilter.Strength property) public strength : number the strength of the imprint or spread. Valid values are from 0 to 255. The larger the value, the more color is imprinted and the stronger the contrast between the bevel and the background. T...

  • Page 290

    290 actionscript classes type (bevelfilter.Type property) public type : string the type of bevel. Valid values are "inner" , "outer" , and "full" . Availability: actionscript 1.0; flash player 8 example the following example changes the type property on the existing movieclip instance ( rect ) when ...

  • Page 292

    292 actionscript classes see also attachbitmap (movieclip.Attachbitmap method) , beginbitmapfill (movieclip.Beginbitmapfill method) property summary properties inherited from class object constructor summary modifiers property description height :number [read- only] the height of the bitmap image in...

  • Page 293

    Bitmapdata (flash.Display.Bitmapdata) 293 method summary modifiers signature description applyfilter (sourcebi tmap:bitmapdata, sourcerect:rectangle , destpoint:point, filter:bitmapfilter) : number takes a source image and a filter object and generates the filtered image. Clone () : bitmapdata retur...

  • Page 294

    294 actionscript classes draw (source:object, [matrix:matrix], [colortransform:colo rtransform], [blendmode:object], [cliprect:rectangle] , [smooth:boolean]) : void draws a source image or movie clip onto a destination image, using the flash player vector renderer. Fillrect (rect:rectan gle, color:n...

  • Page 295

    Bitmapdata (flash.Display.Bitmapdata) 295 merge (sourcebitmap:b itmapdata, sourcerect:rectangle , destpoint:point, redmult:number, greenmult:number, bluemult:number, alphamult:number) : void performs per-channel blending from a source image to a destination image. Noise (randomseed:num ber, [low:num...

  • Page 296

    296 actionscript classes methods inherited from class object pixeldissolve (source bitmap:bitmapdata, sourcerect:rectangle , destpoint:point, [randomseed:number], [numberofpixels:numb er], [fillcolor:number]) : number performs a pixel dissolve either from a source image to a destination image or by ...

  • Page 297

    Bitmapdata (flash.Display.Bitmapdata) 297 applyfilter (bitmapdata.Applyfilter method) public applyfilter(sourcebitmap:bitmapdata, sourcerect:rectangle, destpoint:point, filter:bitmapfilter) : number takes a source image and a filter object and generates the filtered image. This method relies on the ...

  • Page 298

    298 actionscript classes ■ colormatrixfilter — this filter can use source and destination images that are either opaque or transparent. ■ displacementmapfilter — this filter can use source and destination images that are either opaque or transparent, but the source and destination image formats must...

  • Page 299

    Bitmapdata (flash.Display.Bitmapdata) 299 bitmapdata constructor public bitmapdata(width:number, height:number, [transparent:boolean], [fillcolor:number]) creates a bitmapdata object with a specified width and height. If you specify a value for the fillcolor parameter, every pixel in the bitmap is s...

  • Page 300

    300 actionscript classes trace(bitmap_1.Width); // 100 trace(bitmap_1.Height); // 80 trace(bitmap_1.Transparent); // true var bitmap_2:bitmapdata = new bitmapdata(width, height); trace(bitmap_2.Width); // 100 trace(bitmap_2.Height); // 80 trace(bitmap_2.Transparent); // true clone (bitmapdata.Clone ...

  • Page 301

    Bitmapdata (flash.Display.Bitmapdata) 301 // >> palettemap: [type function] // >> hittest: [type function] // >> colortransform: [type function] // >> perlinnoise: [type function] // >> getcolorboundsrect: [type function] // >> floodfill: [type function] // >> setpixel32: [type function] // >> getpi...

  • Page 302

    302 actionscript classes // >> height: 80 // >> width: 100 } to further demonstrate the relationships between bitmap_1 , bitmap_2 , and clonedbitmap the following example modifies the pixel value at (1, 1) of bitmap_1 . Modifying pixel value at (1, 1) demonstrates that the clone() method creates an ...

  • Page 303

    Bitmapdata (flash.Display.Bitmapdata) 303 example the following example shows how to apply a color transform operation to a bitmapdata instance. Import flash.Display.Bitmapdata; import flash.Geom.Colortransform; var mybitmapdata:bitmapdata = new bitmapdata(100, 80, false, 0x00cccccc); var mc:moviecl...

  • Page 304

    304 actionscript classes parameters sourcebitmap:flash.Display.Bitmapdata - the input bitmap image to use. The source image can be a different bitmapdata object or it can refer to the current bitmapdata object. Sourcerect:flash.Geom.Rectangle - the source rectangle object. If you only want to copy c...

  • Page 305

    Bitmapdata (flash.Display.Bitmapdata) 305 copypixels (bitmapdata.Copypixels method) public copypixels(sourcebitmap:bitmapdata, sourcerect:rectangle, destpoint:point, [alphabitmap:bitmapdata], [alphapoint:point], [mergealpha:boolean]) : void provides a fast routine to perform pixel manipulation betwe...

  • Page 306

    306 actionscript classes example the following example shows how to copy pixels from one bitmapdata instance to another. Import flash.Display.Bitmapdata; import flash.Geom.Rectangle; import flash.Geom.Point; var bitmapdata_1:bitmapdata = new bitmapdata(100, 80, false, 0x00cccccc); var bitmapdata_2:b...

  • Page 307

    Bitmapdata (flash.Display.Bitmapdata) 307 var mc:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); mc.Onpress = function() { mybitmapdata.Dispose(); trace(mybitmapdata.Width); // -1 trace(mybitmapdata.Height); // -1 tr...

  • Page 308

    308 actionscript classes colortransform:flash.Geom.Colortransform [optional] - a colortransform object that you use to adjust the color values of the bitmap. If no object is supplied, the bitmap image's colors will not be transformed. Set this parameter to a colortransform object created using the d...

  • Page 309

    Bitmapdata (flash.Display.Bitmapdata) 309 mc_1.Onpress = function() { mybitmapdata.Draw(mc_2, mymatrix, mycolortransform, blendmode, myrectangle, smooth); } function createrectangle(width:number, height:number, color:number):movieclip { var depth:number = this.Getnexthighestdepth(); var mc:movieclip...

  • Page 310

    310 actionscript classes see also rectangle (flash.Geom.Rectangle) floodfill (bitmapdata.Floodfill method) public floodfill(x:number, y:number, color:number) : void performs a flood fill operation on an image starting at an (x, y) coordinate and filling with a certain color. The floodfill() method i...

  • Page 311

    Bitmapdata (flash.Display.Bitmapdata) 311 generatefilterrect (bitmapdata.Generatefilterrect method) public generatefilterrect(sourcerect:rectangle, filter:bitmapfilter) : rectangle determines the destination rectangle that the applyfilter() method call affects, given a bitmapdata object, a source re...

  • Page 312

    312 actionscript classes var filterrect:rectangle = mybitmapdata.Generatefilterrect(mybitmapdata.Rectangle, filter); trace(filterrect); // (x=-31, y=-31, w=162, h=142) getcolorboundsrect (bitmapdata.Getcolorboundsrect method) public getcolorboundsrect(mask:number, color:number, [findcolor:boolean]) ...

  • Page 313

    Bitmapdata (flash.Display.Bitmapdata) 313 mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); mybitmapdata.Fillrect(new rectangle(0, 0, 50, 40), 0x00ff0000); mc.Onpress = function() { var colorboundsrect:rectangle = mybitmapdata.Getcolorboundsrect(0x00ffffff, 0x00ff0000, true); trace(colorbou...

  • Page 314

    314 actionscript classes var mc:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); trace("0x" + mybitmapdata.Getpixel(0, 0).Tostring(16)); // 0xcccccc see also getpixel32 (bitmapdata.Getpixel32 method) getpixel32 (bitma...

  • Page 315

    Bitmapdata (flash.Display.Bitmapdata) 315 var green:string = (mybitmapdata.Getpixel32(0, 0) >> 8 & 0xff).Tostring(16); trace(">> green: " + green); // cc var blue:string = (mybitmapdata.Getpixel32(0, 0) & 0xff).Tostring(16); trace(">> blue: " + blue); // ee trace("0x" + alpha + red + green + blue); ...

  • Page 316

    316 actionscript classes if an image is an opaque image, it is considered a fully opaque rectangle for this method. Both images must be transparent images to perform pixel-level hit testing that considers transparency. When you are testing two transparent images, the alpha threshold parameters contr...

  • Page 317

    Bitmapdata (flash.Display.Bitmapdata) 317 currpoint.X = mc_2._x; currpoint.Y = mc_2._y; if(mybitmapdata.Hittest(destpoint, 255, currpoint)) { trace(">> collision at x:" + currpoint.X + " and y:" + currpoint.Y); } } mc_2.Startdrag(true); function createrectangle(width:number, height:number, color:num...

  • Page 318

    318 actionscript classes var mc:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); merge (bitmapdata.Merge method) public merge(sourcebitmap:bitmapdata, sourcerect:rectangle, destpoint:point, redmult:number, greenmult:n...

  • Page 319

    Bitmapdata (flash.Display.Bitmapdata) 319 var mc_2:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc_2.Attachbitmap(bitmapdata_2, this.Getnexthighestdepth()); mc_2._x = 101; mc_1.Onpress = function() { bitmapdata_1.Merge(bitmapdata_2, new rectangle(0, 0, 50, 40), new point(...

  • Page 320

    320 actionscript classes var mc_1:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc_1.Attachbitmap(bitmapdata_1, this.Getnexthighestdepth()); var mc_2:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc_2.Attachbitmap(bitmapdata_2, this.Getnexthighes...

  • Page 321

    Bitmapdata (flash.Display.Bitmapdata) 321 you can use this method for a variety of effects such as general palette mapping (taking one channel and converting it to a false color image). You can also use this method for a variety of advanced color manipulation algorithms, such as gamma, curves, level...

  • Page 322

    322 actionscript classes for(var i = 0; i redarray[i] = 0x00000000; greenarray[i] = 0x00000000; } redarray[0xff] = 0x0000ff00; greenarray[0xff] = 0x00ff0000; mybitmapdata.Palettemap(mybitmapdata, new rectangle(0, 0, 100, 40), new point(0, 0), redarray, greenarray, null, null); } perlinnoise (bitmapd...

  • Page 323

    Bitmapdata (flash.Display.Bitmapdata) 323 basey:number - frequency to use in the y direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 128 for the basey value. Numoctaves:number - number of octaves or individual noise functions to combine to create this noise. Larger...

  • Page 324

    324 actionscript classes var mc_2:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc_2.Attachbitmap(bitmapdata_2, this.Getnexthighestdepth()); mc_2._x = 101; mc_1.Onpress = function() { var randomnum:number = math.Floor(math.Random() * 10); bitmapdata_1.Perlinnoise(100, 80, ...

  • Page 325

    Bitmapdata (flash.Display.Bitmapdata) 325 randomseed:number [optional] - the random seed to use to start the pixel dissolve. The default value is 0. Numberofpixels:number [optional] - the default is 1/30 of the source area (width x height). Fillcolor:number [optional] - an argb color value that you ...

  • Page 326

    326 actionscript classes rectangle (bitmapdata.Rectangle property) public rectangle : rectangle [read-only] the rectangle that defines the size and location of the bitmap image. The top and left of the rectangle are 0; the width and height are equal to the width and height in pixels of the bitmapdat...

  • Page 327

    Bitmapdata (flash.Display.Bitmapdata) 327 var mc:movieclip = this.Createemptymovieclip("mc", this.Getnexthighestdepth()); mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); mybitmapdata.Fillrect(new rectangle(0, 0, 25, 80), 0x00ff0000); mc.Onpress = function() { mybitmapdata.Scroll(25, 0); }...

  • Page 328

    328 actionscript classes function sketch() { mybitmapdata.Setpixel(_xmouse, _ymouse, 0x000000); } see also getpixel (bitmapdata.Getpixel method) , setpixel32 (bitmapdata.Setpixel32 method) setpixel32 (bitmapdata.Setpixel32 method) public setpixel32(x:number, y:number, color:number) : void sets the c...

  • Page 329

    Bitmapdata (flash.Display.Bitmapdata) 329 function sketch() { mybitmapdata.Setpixel32(_xmouse, _ymouse, 0x00000000); } see also getpixel32 (bitmapdata.Getpixel32 method) , setpixel (bitmapdata.Setpixel method) threshold (bitmapdata.Threshold method) public threshold(sourcebitmap:bitmapdata, sourcere...

  • Page 330

    330 actionscript classes sourcerect:flash.Geom.Rectangle - a rectangle that defnes the area of the source image to use as input. Destpoint:flash.Geom.Point - the point within the destination image (the current bitmapdata instance) that corresponds to upper-left corner of the source rectangle. Operat...

  • Page 331

    Bitmapdata (flash.Display.Bitmapdata) 331 transparent (bitmapdata.Transparent property) public transparent : boolean [read-only] defines whether the bitmap image supports per-pixel transparency. You can set this value only when you construct a bitmapdata object by passing in true for the transparent...

  • Page 333

    Blurfilter (flash.Filters.Blurfilter) 333 clone (bitmapfilter.Clone method) public clone() : bitmapfilter returns a bitmapfilter object that is an exact copy of the original bitmapfilter object. Availability: actionscript 1.0; flash player 8 returns flash.Filters.Bitmapfilter - a bitmapfilter object...

  • Page 334

    334 actionscript classes a filter is not applied if the resulting image exceeds 2880 pixels in width or height. If, for example, you zoom in on a large movie clip with a filter applied, the filter is turned off if the resulting image exceeds the limit of 2880 pixels. Availability: actionscript 1.0; ...

  • Page 335

    Blurfilter (flash.Filters.Blurfilter) 335 method summary methods inherited from class bitmapfilter methods inherited from class object blurfilter constructor public blurfilter([blurx:number], [blury:number], [quality:number]) initializes the filter with the specified parameters. The default values c...

  • Page 336

    336 actionscript classes example the following example instantiates a new blurfilter constructor and applies it to a flat, rectangular shape: import flash.Filters.Blurfilter; var rect:movieclip = createrectangle(100, 100, 0x003366, "blurfilterexample"); var blurx:number = 30; var blury:number = 30; ...

  • Page 337

    Blurfilter (flash.Filters.Blurfilter) 337 filter.Blurx = 200; this.Filters = new array(filter); } function createblurfilterrectangle(name:string):movieclip { var rect:movieclip = this.Createemptymovieclip(name, this.Getnexthighestdepth()); var w:number = 100; var h:number = 100; rect.Beginfill(0x003...

  • Page 338

    338 actionscript classes var w:number = 100; var h:number = 100; rect.Beginfill(0x003366); rect.Lineto(w, 0); rect.Lineto(w, h); rect.Lineto(0, h); rect.Lineto(0, 0); rect._x = 20; rect._y = 20; var filter:blurfilter = new blurfilter(30, 30, 2); var filterarray:array = new array(); filterarray.Push(...

  • Page 339

    Blurfilter (flash.Filters.Blurfilter) 339 // >> clone: [type function] // >> quality: 2 // >> blury: 30 // >> blurx: 30 } for(var i in clonedfilter) { trace(">> " + i + ": " + clonedfilter[i]); // >> clone: [type function] // >> quality: 2 // >> blury: 30 // >> blurx: 30 } to further demonstrate the...

  • Page 340

    340 actionscript classes quality (blurfilter.Quality property) public quality : number the number of times to perform the blur. Valid values are from 0-15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality. A value of 3 is high quality and approximates a gaus...

  • Page 342

    342 actionscript classes method summary methods inherited from class object boolean constructor public boolean([value:object]) creates a boolean object. If you omit the value parameter, the boolean object is initialized with a value of false . If you specify a value for the value parameter, the meth...

  • Page 343

    Boolean 343 tostring (boolean.Tostring method) public tostring() : string returns the string representation ( "true" or "false" ) of the boolean object. Availability: actionscript 1.0; flash player 5 returns string - a string; "true" or "false" . Example this example creates a variable of type boole...

  • Page 345

    Button 345 _name :string instance name of the button specified by my_btn. _parent :movieclip a reference to the movie clip or object that contains the current movie clip or object. _quality :string property (global); sets or retrieves the rendering quality used for a swf file. _rotation :number the ...

  • Page 346

    346 actionscript classes properties inherited from class object event summary _y :number the y coordinate of the button relative to the local coordinates of the parent movie clip. _ymouse :number [read- only] indicates the y coordinate of the mouse position relative to the button. _yscale :number th...

  • Page 347

    Button 347 method summary methods inherited from class object _alpha (button._alpha property) public _alpha : number the alpha transparency value of the button specified by my_btn . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a button with _alph...

  • Page 348

    348 actionscript classes blendmode (button.Blendmode property) public blendmode : object the blend mode for the button. The blend mode affects the appearance of the button when it is in a layer above another object onscreen. Flash player applies the blendmode property on each pixel of the button. Ea...

  • Page 349

    Button 349 3 "multiply" multiplies the values of the button constituent colors by those of the background color, and then normalizes by dividing by 0xff, resulting in darker colors. This is commonly used for shadows and depth effects. For example, if a constituent color (such as red) of one pixel in...

  • Page 350

    350 actionscript classes 6 "darken" selects the darker of the constituent colors of the button and those of the background (the ones with the smaller values). This setting is commonly used for superimposing type. For example, if the button has a pixel with an rgb value of 0xffcc33, and the backgroun...

  • Page 351

    Button 351 8 "add" adds the values of the constituent colors of the button to those of its background, and applies a ceiling of 0xff. This setting is commonly used for animating a lightening dissolve between two objects. For example, if the button has a pixel with an rgb value of 0xaaa633, and the b...

  • Page 352

    352 actionscript classes 11 "alpha" applies the alpha value of each pixel of the button to the background. This requires the "layer" blendmode to be applied to a parent button. For example, in the illustration, the parent button, which is a white background, has blendmode = "layer" . 12 "erase" eras...

  • Page 353

    Button 353 if you attempt to set the blendmode property to any other value, flash player sets it to "normal" . Availability: actionscript 1.0; flash player 8 example in the following example you can see that if you set the property to an integer, flash player converts the value to the corresponding ...

  • Page 354

    354 actionscript classes in the following cases a button does not use a bitmap, even if the cacheasbitmap property is set to true and instead renders from vector data: ■ when the bitmap is too large, that is, greater than 2880 pixels in either direction ■ when the bitmap fails to allocate memory (du...

  • Page 355

    Button 355 //button code // the following function will not get called // because mybtn2_btn.Enabled was set to false mybtn1_btn.Onrelease = function() { trace( "you clicked : " + this._name ); }; mybtn2_btn.Onrelease = function() { trace( "you clicked : " + this._name ); }; filters (button.Filters ...

  • Page 356

    356 actionscript classes to clear the filters for a button, set filters to an empty array ( [] ). At load time, if a button has an associated filter, it is marked to cache itself as a transparent bitmap. From this point forward, as long as the button has a valid filter list, the player caches the bu...

  • Page 357

    Button 357 _focusrect (button._focusrect property) public _focusrect : boolean a boolean value that specifies whether a button has a yellow rectangle around it when it has keyboard focus. This property can override the global _focusrect property. By default, the _focusrect property of a button insta...

  • Page 358

    358 actionscript classes returns number - the depth of the button instance. Example if you create mybtn1_btn and mybtn2_btn on the stage, you can trace their depth using the following actionscript: trace(mybtn1_btn.Getdepth()); trace(mybtn2_btn.Getdepth()); if you load a swf file called buttonmovie....

  • Page 359

    Button 359 _highquality (button._highquality property) public _highquality : number deprecated since flash player 7. This property was deprecated in favor of button._quality . Specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) to apply high quality with bi...

  • Page 360

    360 actionscript classes example the following example assigns a contextmenu object to a button instance named mybtn_btn . The contextmenu object contains a single menu item (labeled "save...") with an associated callback handler function named dosave . Add the button instance to the stage and name ...

  • Page 361

    Button 361 ondragout (button.Ondragout handler) ondragout = function() {} invoked when the mouse button is clicked over the button and the pointer then dragged outside of the button. You must define a function that executes when the event handler is invoked. Availability: actionscript 1.0; flash pla...

  • Page 362

    362 actionscript classes see also ondragout (button.Ondragout handler) onkeydown (button.Onkeydown handler) onkeydown = function() {} invoked when a button has keyboard focus and a key is pressed. The onkeydown event handler is invoked with no parameters. You can use the key.Getascii() and key.Getco...

  • Page 363

    Button 363 onkeyup (button.Onkeyup handler) onkeyup = function() {} invoked when a button has input focus and a key is released. The onkeyup event handler is invoked with no parameters. You can use the key.Getascii() and key.Getcode() methods to determine which key was pressed. Availability: actions...

  • Page 364

    364 actionscript classes onkillfocus (button.Onkillfocus handler) onkillfocus = function(newfocus:object) {} invoked when a button loses keyboard focus. The onkillfocus handler receives one parameter, newfocus , which is an object representing the new object receiving the focus. If no object receive...

  • Page 365

    Button 365 example in the following example, a function that sends a trace() statement to the output panel is defined for the onpress handler: my_btn.Onpress = function () { trace ("onpress called"); }; onrelease (button.Onrelease handler) onrelease = function() {} invoked when a button is released....

  • Page 366

    366 actionscript classes onrollout (button.Onrollout handler) onrollout = function() {} invoked when the pointer moves outside a button area. You must define a function that executes when the event handler is invoked. Availability: actionscript 1.0; flash player 6 example in the following example, a...

  • Page 367

    Button 367 example the following example demonstrates how you can execute statements when the user of a swf file moves focus from one button to another. Create two buttons, btn1_btn and btn2_btn , and enter the following actionscript in frame 1 of the timeline: selection.Setfocus(btn1_btn); trace(se...

  • Page 368

    368 actionscript classes _quality (button._quality property) public _quality : string property (global); sets or retrieves the rendering quality used for a swf file. Device fonts are always aliased and therefore are unaffected by the _quality property. The _quality property can be set to the followi...

  • Page 369

    Button 369 example the following example rotates two buttons on the stage. Create two buttons on the stage called control_btn and my_btn . Make sure that my_btn is not perfectly round, so you can see it rotating. Then enter the following actionscript in frame 1 of the timeline: var control_btn:butto...

  • Page 370

    370 actionscript classes ■ the area below the rectangle ■ the area in the lower-right corner outside the rectangle you can think of the eight regions outside of the center (defined by the rectangle) as a picture frame that has special rules applied to it when the button is scaled. When the scale9gri...

  • Page 371

    Button 371 tabenabled (button.Tabenabled property) public tabenabled : boolean specifies whether my_btn is included in automatic tab ordering. It is undefined by default. If the tabenabled property is undefined or true , the object is included in automatic tab ordering. If the tabindex property is a...

  • Page 372

    372 actionscript classes the tabindex property may be a non-negative integer. The objects are ordered according to their tabindex properties, in ascending order. An object with a tabindex value of 1 precedes an object with a tabindex value of 2 . If two objects have the same tabindex value, the one ...

  • Page 373

    Button 373 example add a button instance to the stage with an instance name my_btn and add the following code to frame 1 of the timeline: trace(my_btn._target); //displays /my_btn select my_btn and convert it to a movie clip. Give the new movie clip an instance name my_mc . Delete the existing actio...

  • Page 374

    374 actionscript classes example the following example demonstrates how to track two buttons as a menu. Place two button instances on the stage called one_btn and two_btn . Enter the following actionscript in the timeline: var one_btn:button; var two_btn:button; one_btn.Trackasmenu = true; two_btn.T...

  • Page 375

    Button 375 var my_str:string = string(url_array.Pop()); output_txt.Text = unescape(my_str); }; when you click each button, the file name of the swf containing the buttons displays in the output panel. Usehandcursor (button.Usehandcursor property) public usehandcursor : boolean a boolean value that, ...

  • Page 376

    376 actionscript classes example create two buttons on the stage with the instance names mybtn1_btn and mybtn2_btn . Enter the following actionscript in frame 1 of the timeline: mybtn1_btn.Onrelease = function() { this._visible = false; trace("clicked "+this._name); }; mybtn2_btn.Onrelease = functio...

  • Page 377

    Button 377 _x (button._x property) public _x : number an integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip. If a button is on the main timeline, then its coordinate system refers to the upper left corner of the stage as (0, 0). If the button is...

  • Page 378

    378 actionscript classes table_str += "stage\t"+"x:"+_xmouse+"\t"+"y:"+_ymouse+newline; table_str += "button b>\t"+"x:"+my_btn._xmouse+"\t"+"y:"+my_btn._ymouse+newline; table_str += ""; mouse_txt.Htmltext = table_str; }; mouse.Addlistener(mouselistener); see also _ymouse (button._ymouse property) _x...

  • Page 379

    Button 379 the y coordinate of the button relative to the local coordinates of the parent movie clip. If a button is in the main timeline, its coordinate system refers to the upper left corner of the stage as (0, 0). If the button is inside another movie clip that has transformations, the button is ...

  • Page 380

    380 actionscript classes mouse_txt.Htmltext = table_str; }; mouse.Addlistener(mouselistener); see also _xmouse (button._xmouse property) _yscale (button._yscale property) public _yscale : number the vertical scale of the button as applied from the registration point of the button, expressed as a per...

  • Page 382

    382 actionscript classes properties inherited from class object event summary motionlevel :number [read-only] a numeric value that specifies the amount of motion required to invoke camera.Onactivity(true). Motiontimeout :number [read-only] the number of milliseconds between the time the camera stops...

  • Page 383

    Camera 383 method summary methods inherited from class object activitylevel (camera.Activitylevel property) public activitylevel : number [read-only] a numeric value that specifies the amount of motion the camera is detecting. Values range from 0 (no motion is being detected) to 100 (a large amount ...

  • Page 384

    384 actionscript classes example this example detects the amount of motion the camera detects using the activitylevel property and a progressbar instance. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and give it the instance name my_v...

  • Page 385

    Camera 385 example the following example changes the maximum amount of bandwidth used by the camera feed. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and give it the instance name my_video . Add a numericstepper component instance to...

  • Page 386

    386 actionscript classes example the following example detects the rate in frames per second that the camera captures data, using the currentfps property and a progressbar instance. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and giv...

  • Page 387

    Camera 387 example the following example detects the rate in frames per second that the camera captures data, using the currentfps property and a progressbar instance. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and give it the insta...

  • Page 388

    388 actionscript classes when a swf file tries to access the camera returned by camera.Get() , flash player displays a privacy dialog box that lets the user choose whether to allow or deny access to the camera. (make sure your stage size is at least 215 x 138 pixels; this is the minimum size flash r...

  • Page 389

    Camera 389 returns camera - if index is not specified, this method returns a reference to the default camera or, if it is in use by another application, to the first available camera. (if there is more than one camera installed, the user may specify the default camera in the flash player camera sett...

  • Page 390

    390 actionscript classes example the following code displays the current width, height and fps of a video instance in a label component instance on the stage. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and give it the instance name ...

  • Page 391

    Camera 391 cameras_txt.Html = true; cameras_txt.Border = true; cameras_txt.Wordwrap = true; cameras_txt.Multiline = true; for (var i = 0; i cameras_txt.Htmltext += " href=\"asfunction:changecamera,"+i+"\">"+camera.Names[i]+" cameras_txt.Htmltext += " href=\"asfunction:changecamera,"+i+"\">"+camera.N...

  • Page 392

    392 actionscript classes var motion_pb:mx.Controls.Progressbar; motion_pb.Mode = "manual"; motion_pb.Label = "motion: %3%%"; var motionlevel_lbl:mx.Controls.Label; // configure the numericstepper component instance var motionlevel_nstep:mx.Controls.Numericstepper; motionlevel_nstep.Minimum = 0; moti...

  • Page 393

    Camera 393 motiontimeout (camera.Motiontimeout property) public motiontimeout : number [read-only] the number of milliseconds between the time the camera stops detecting motion and the time camera.Onactivity (false) is invoked. The default value is 2000 (2 seconds). To set this value, use camera.Set...

  • Page 394

    394 actionscript classes see also setmotionlevel (camera.Setmotionlevel method) , onactivity (camera.Onactivity handler) muted (camera.Muted property) public muted : boolean [read-only] a boolean value that specifies whether the user has denied access to the camera ( true ) or allowed access ( false...

  • Page 395

    Camera 395 name (camera.Name property) public name : string [read-only] a string that specifies the name of the current camera, as returned by the camera hardware. Availability: actionscript 1.0; flash player 6 example the following example displays the name of the default camera in a text field. In...

  • Page 396

    396 actionscript classes calling the camera.Names property requires an extensive examination of the hardware, and it may take several seconds to build the array. In most cases, you can just use the default camera. Availability: actionscript 1.0; flash player 6 example the following example uses the ...

  • Page 397

    Camera 397 example the following example displays true or false in the output panel when the camera starts or stops detecting motion: // assumes a video object named "myvideoobject" is on the stage active_cam = camera.Get(); myvideoobject.Attachvideo(active_cam); active_cam.Setmotionlevel(10, 500); ...

  • Page 398

    398 actionscript classes example the following actionscript is used to display a message whenever the user allows or denies access to the camera: var my_cam:camera = camera.Get(); var my_video:video; my_video.Attachvideo(my_cam); my_cam.Onstatus = function(infoobj:object) { switch (infoobj.Code) { c...

  • Page 399

    Camera 399 quality_nstep.Minimum = 0; quality_nstep.Maximum = 100; quality_nstep.Stepsize = 5; quality_nstep.Value = my_cam.Quality; function changequality() { my_cam.Setquality(my_cam.Bandwidth, quality_nstep.Value); } quality_nstep.Addeventlistener("change", changequality); see also setquality (ca...

  • Page 400

    400 actionscript classes favorarea:boolean [optional] - a boolean value that specifies how to manipulate the width, height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is true , which means that maintaining capture size is favored...

  • Page 401

    Camera 401 setmotionlevel (camera.Setmotionlevel method) public setmotionlevel([motionlevel:number], [timeout:number]) : void specifies how much motion is required to invoke camera.Onactivity(true) . Optionally sets the number of milliseconds that must elapse without activity before flash considers ...

  • Page 402

    402 actionscript classes example the following example sends messages to the output panel when video activity starts or stops. Change the motion sensitivity value of 30 to a higher or lower number to see how different values affect motion detection. // assumes a video object named "myvideoobject" is...

  • Page 403

    Camera 403 ■ to specify that both bandwidth and quality are equally important, pass numeric values for both parameters. Flash will transmit video that achieves the specified quality and that doesn't exceed the specified bandwidth. If necessary, flash will reduce the frame rate to maintain picture qu...

  • Page 404

    404 actionscript classes example the following code displays the current width, height and fps of a video instance in a label component instance on the stage. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and give it the instance name ...

  • Page 405

    Capabilities (system.Capabilities) 405 r=1600x1200&dp=72&col=color&ar=1.0&os=windows%20xp& l=en&pt=external&avd=f&lfd=f&wd=f" all properties of the system.Capabilities object are read-only. Availability: actionscript 1.0; flash player 6 property summary modifiers property description static avhardwa...

  • Page 406

    406 actionscript classes static hasstreamingaudio :bo olean [read-only] a boolean value that is true if the player can play streaming audio; false otherwise. Static hasstreamingvideo :bo olean [read-only] a boolean value that is true if the player can play streaming video; false otherwise. Static ha...

  • Page 407

    Capabilities (system.Capabilities) 407 properties inherited from class object method summary methods inherited from class object avhardwaredisable (capabilities.Avhardwaredisable property) public static avhardwaredisable : boolean [read-only] a boolean value that specifies whether access to the user...

  • Page 408

    408 actionscript classes availability: actionscript 1.0; flash player 6 example the following example traces the value of this read-only property: trace(system.Capabilities.Hasaccessibility); see also isactive (accessibility.Isactive method) , updateproperties (accessibility.Updateproperties method)...

  • Page 409

    Capabilities (system.Capabilities) 409 hasembeddedvideo (capabilities.Hasembeddedvideo property) public static hasembeddedvideo : boolean [read-only] a boolean value that is true if the player is running on a system that supports embedded video; false otherwise. The server string is ev . Availabilit...

  • Page 410

    410 actionscript classes hasprinting (capabilities.Hasprinting property) public static hasprinting : boolean [read-only] a boolean value that is true if the player is running on a system that supports printing; false otherwise. The server string is pr . Availability: actionscript 1.0; flash player 6...

  • Page 411

    Capabilities (system.Capabilities) 411 hasstreamingaudio (capabilities.Hasstreamingaudio property) public static hasstreamingaudio : boolean [read-only] a boolean value that is true if the player can play streaming audio; false otherwise. The server string is sa . Availability: actionscript 1.0; fla...

  • Page 412

    412 actionscript classes isdebugger (capabilities.Isdebugger property) public static isdebugger : boolean [read-only] a boolean value that indicates whether the player is an officially released version ( false ) or a special debugging version ( true ). The server string is deb . Availability: action...

  • Page 413

    Capabilities (system.Capabilities) 413 availability: actionscript 1.0; flash player 6 - behavior changed in flash player 7. Example the following example traces the value of this read-only property: trace(system.Capabilities.Language); localfilereaddisable (capabilities.Localfilereaddisable property...

  • Page 414

    414 actionscript classes availability: actionscript 1.0; flash player 7 example the following example traces the value of this read-only property: trace(system.Capabilities.Localfilereaddisable); manufacturer (capabilities.Manufacturer property) public static manufacturer : string [read-only] a stri...

  • Page 415

    Capabilities (system.Capabilities) 415 example the following example traces the value of this read-only property: trace(system.Capabilities.Pixelaspectratio); playertype (capabilities.Playertype property) public static playertype : string [read-only] a string that indicates the type of player. This ...

  • Page 416

    416 actionscript classes example the following example traces the value of this read-only property: trace(system.Capabilities.Screendpi); screenresolutionx (capabilities.Screenresolutionx property) public static screenresolutionx : number [read-only] an integer that indicates the maximum horizontal ...

  • Page 417

    Color 417 l=en&pt=external&avd=f&lfd=f&wd=f availability: actionscript 1.0; flash player 6 example the following example traces the value of this read-only property: trace(system.Capabilities.Serverstring); version (capabilities.Version property) public static version : string [read-only] a string c...

  • Page 418

    418 actionscript classes property summary properties inherited from class object constructor summary method summary methods inherited from class object constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__reso...

  • Page 419

    Color 419 color constructor public color(target:object) deprecated since flash player 8. The color class has been deprecated in favor of the flash.Geom.Colortransform class. Creates a color object for the movie clip specified by the target_mc parameter. You can then use the methods of that color obj...

  • Page 420

    420 actionscript classes example the following code retrieves the rgb value for the color object my_color , converts the value to a hexadecimal string, and assigns it to the myvalue variable. To see this code work, add a movie clip instance to the stage, and give it the instance name my_mc : var my_...

  • Page 421

    Color 421 setrgb (color.Setrgb method) public setrgb(offset:number) : void deprecated since flash player 8. The color class has been deprecated in favor of the flash.Geom.Colortransform class. Specifies an rgb color for a color object. Calling this method overrides any previous color.Settransform() ...

  • Page 422

    422 actionscript classes ■ gb is the offset for the green component (-255 to 255). ■ ba is the percentage for the blue component (-100 to 100). ■ bb is the offset for the blue component (-255 to 255). ■ aa is the percentage for alpha (-100 to 100). ■ ab is the offset for alpha (-255 to 255). You cre...

  • Page 424

    424 actionscript classes this filter separates each source pixel into its red, green, blue, and alpha components as srcr, srcg, srcb, srca. As a final step, it combines each color component back into a single pixel and writes out the result. The calculations are performed on unmultiplied color value...

  • Page 425

    Colormatrixfilter (flash.Filters.Colormatrixfilter) 425 listener.Image = image; listener.Onmousemove = function() { var xpercent:number = 1 - (_xmouse/stage.Width); var ypercent:number = 1 - (_ymouse/stage.Height); var matrix:array = new array(); matrix = matrix.Concat([ypercent, 0, 0, 0, 0]); // re...

  • Page 426

    426 actionscript classes method summary methods inherited from class bitmapfilter methods inherited from class object clone (colormatrixfilter.Clone method) public clone() : colormatrixfilter returns a copy of this filter object. Availability: actionscript 1.0; flash player 8 returns flash.Filters.C...

  • Page 427

    Colormatrixfilter (flash.Filters.Colormatrixfilter) 427 var filter:colormatrixfilter = new colormatrixfilter(matrix); trace("filter: " + filter.Matrix); var clonedfilter:colormatrixfilter = filter.Clone(); matrix = clonedfilter.Matrix; matrix[2] = 1; clonedfilter.Matrix = matrix; trace("clonedfilter...

  • Page 429

    Colortransform (flash.Geom.Colortransform) 429 property summary properties inherited from class object modifiers property description alphamultiplier :numb er a decimal value that is multiplied by the alpha transparency channel value. Alphaoffset :number a number from -255 to 255 that is added to th...

  • Page 430

    430 actionscript classes constructor summary method summary methods inherited from class object signature description colortransform ([redm ultiplier:number], [greenmultiplier:num ber], [bluemultiplier:numb er], [alphamultiplier:num ber], [redoffset:number], [greenoffset:number] , [blueoffset:number...

  • Page 431

    Colortransform (flash.Geom.Colortransform) 431 alphamultiplier (colortransform.Alphamultiplier property) public alphamultiplier : number a decimal value that is multiplied by the alpha transparency channel value. If you set the alpha transparency value of a movie clip directly by using the movieclip...

  • Page 432

    432 actionscript classes alphaoffset (colortransform.Alphaoffset property) public alphaoffset : number a number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the alphamultiplier value. Availability: actionscript 1.0; flash player 8 example the...

  • Page 433

    Colortransform (flash.Geom.Colortransform) 433 example the following example creates the colortransform object colortrans and adjusts its bluemultiplier value from 1 to .5. Import flash.Geom.Colortransform; import flash.Geom.Transform; var colortrans:colortransform = new colortransform(); trace(colo...

  • Page 434

    434 actionscript classes colortrans.Blueoffset = 255; trace(colortrans.Blueoffset); // 255 var rect:movieclip = createrectangle(20, 80, 0x000000); var trans:transform = new transform(rect); trans.Colortransform = colortrans; function createrectangle(width:number, height:number, color:number, scope:m...

  • Page 435

    Colortransform (flash.Geom.Colortransform) 435 greenoffset:number [optional] - the offset for the green color channel value (-255 to 255). The default value is 0. Blueoffset:number [optional] - the offset for the blue color channel value (-255 to 255). The default value is 0. Alphaoffset:number [opt...

  • Page 436

    436 actionscript classes example the following example concatenates the colortransform object colortrans_2 to colortrans_1 resulting in a full red offset combined with a .5 alpha multiplier. Import flash.Geom.Colortransform; import flash.Geom.Transform; var colortrans_1:colortransform = new colortra...

  • Page 437

    Colortransform (flash.Geom.Colortransform) 437 greenmultiplier (colortransform.Greenmultiplier property) public greenmultiplier : number a decimal value that is multiplied by the green channel value. Availability: actionscript 1.0; flash player 8 example the following example creates the colortransf...

  • Page 438

    438 actionscript classes example the following example creates the colortransform object colortrans and adjusts its greenoffset value from 0 to 255. Import flash.Geom.Colortransform; import flash.Geom.Transform; var colortrans:colortransform = new colortransform(); trace(colortrans.Greenoffset); // ...

  • Page 439

    Colortransform (flash.Geom.Colortransform) 439 colortrans.Redmultiplier = .5; trace(colortrans.Redmultiplier); // .5 var rect:movieclip = createrectangle(20, 80, 0xff0000); var trans:transform = new transform(rect); trans.Colortransform = colortrans; function createrectangle(width:number, height:num...

  • Page 440

    440 actionscript classes scope = (scope == undefined) ? This : scope; var depth:number = scope.Getnexthighestdepth(); var mc:movieclip = scope.Createemptymovieclip("mc_" + depth, depth); mc.Beginfill(color); mc.Lineto(0, height); mc.Lineto(width, height); mc.Lineto(width, 0); mc.Lineto(0, 0); return...

  • Page 441

    Colortransform (flash.Geom.Colortransform) 441 var depth:number = scope.Getnexthighestdepth(); var mc:movieclip = scope.Createemptymovieclip("mc_" + depth, depth); mc.Beginfill(color); mc.Lineto(0, height); mc.Lineto(width, height); mc.Lineto(width, 0); mc.Lineto(0, 0); return mc; } tostring (colort...

  • Page 443

    Contextmenu 443 see also contextmenuitem , menu (button.Menu property) , menu (movieclip.Menu property) , menu (textfield.Menu property) property summary properties inherited from class object event summary constructor summary modifiers property description builtinitems :object an object that has th...

  • Page 444

    444 actionscript classes method summary methods inherited from class object builtinitems (contextmenu.Builtinitems property) public builtinitems : object an object that has the following boolean properties: zoom , quality , play , loop , rewind , forward_back , and print . Setting these variables to...

  • Page 445

    Contextmenu 445 in the next example, a for..In loop enumerates through all names and values of the built-in menu items of the contextmenu object, my_cm . Var my_cm:contextmenu = new contextmenu(); for(eachprop in my_cm.Builtinitems) { var propname = eachprop; var propvalue = my_cm.Builtinitems[propn...

  • Page 446

    446 actionscript classes } } function itemhandler(obj, item) { //...Put code here... Trace("selected!"); } this.Menu = my_cm; when the user right-clicks or control-clicks the stage, the custom menu is displayed. See also menu (button.Menu property) , onselect (contextmenu.Onselect handler) , customi...

  • Page 447

    Contextmenu 447 } for (var i in my_cm.Customitems) { trace("my_cm-> "+my_cm.Customitems[i].Caption); } customitems (contextmenu.Customitems property) public customitems : array an array of contextmenuitem objects. Each object in the array represents a context menu item that you have defined. Use thi...

  • Page 448

    448 actionscript classes hidebuiltinitems (contextmenu.Hidebuiltinitems method) public hidebuiltinitems() : void hides all built-in menu items (except settings) in the specified contextmenu object. If the flash debug player is running, the debugging menu item shows, although it is dimmed for swf fil...

  • Page 449

    Contextmenuitem 449 parameters item:object - a reference to the object (movie clip, button, or selectable text field) that was under the mouse pointer when the flash player context menu was invoked and whose menu property is set to a valid contextmenu object. Item_menu:object - a reference to the co...

  • Page 450

    450 actionscript classes custom menu items appear at the top of the context menu, above any built-in items. A separator bar always divides custom menu items from built-in items. You can add no more than 15 custom items to a context menu. Each item must contain at least one visible character; control...

  • Page 451

    Contextmenuitem 451 constructor summary method summary methods inherited from class object caption (contextmenuitem.Caption property) public caption : string a string that specifies the menu item caption (text) displayed in the context menu. Availability: actionscript 1.0; flash player 7 example the...

  • Page 452

    452 actionscript classes contextmenuitem constructor public contextmenuitem(caption:string, callbackfunction:function, [separatorbefore:boolean], [enabled:boolean], [visible:boolean]) creates a new contextmenuitem object that can be added to the contextmenu.Customitems array. Availability: actionscr...

  • Page 453

    Contextmenuitem 453 copy (contextmenuitem.Copy method) public copy() : contextmenuitem creates and returns a copy of the specified contextmenuitem object. The copy includes all properties of the original object. Availability: actionscript 1.0; flash player 7 returns contextmenuitem - a contextmenuit...

  • Page 454

    454 actionscript classes example the following example creates two new context menu items: start and stop. When the user selects start, the number of milliseconds from when the swf file started is traced. Start is then disabled in the menu. When stop is selected, the number of milliseconds that have...

  • Page 455

    Contextmenuitem 455 parameters obj:object - a reference to the object (movie clip, timeline, button, or selectable text field) on which the user right or control clicked. Menuitem:object - a reference to the selected contextmenuitem object. Example the following example determines over what type of ...

  • Page 456

    456 actionscript classes example this example creates three menu items, labeled open, save, and print. A separator bar divides the save and print items. The menu items are then added to the contextmenu object's customitems array. Finally, the menu is attached to the current timeline of the swf file....

  • Page 457

    Convolutionfilter (flash.Filters.Convolutionfilter) 457 stopmenuitem.Visible = false; } function starthandler(obj, item) { trace("starting... "+gettimer()+"ms"); startmenuitem.Visible = false; stopmenuitem.Visible = true; } this.Menu = my_cm; convolutionfilter (flash.Filters.Convolutionfilter) objec...

  • Page 458

    458 actionscript classes a matrix convolution is based on an n x m matrix, which describes how a given pixel value in the input image is combined with its neighboring pixel values to produce a resulting pixel value. Each result pixel is determined by applying the matrix to the corresponding source p...

  • Page 459

    Convolutionfilter (flash.Filters.Convolutionfilter) 459 property summary properties inherited from class object constructor summary modifiers property description alpha :number the alpha transparency value of the substitute color. Bias :number bias to add to the result of the matrix transformation. ...

  • Page 460

    460 actionscript classes method summary methods inherited from class bitmapfilter methods inherited from class object alpha (convolutionfilter.Alpha property) public alpha : number the alpha transparency value of the substitute color. Valid values are 0 to 1.0. The default is 0. For example, .25 set...

  • Page 462

    462 actionscript classes example the following example changes the clamp property of filter from its default value of true to false . Import flash.Filters.Convolutionfilter; import flash.Display.Bitmapdata; import flash.Geom.Rectangle; import flash.Geom.Point; var clamp:boolean = false; var filter:c...

  • Page 463

    Convolutionfilter (flash.Filters.Convolutionfilter) 463 var filter_1:convolutionfilter = new convolutionfilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9); var filter_2:convolutionfilter = filter_1; var clonedfilter:convolutionfilter = filter_1.Clone(); trace(filter_1 == filter_2); // true trace(filter_1 ...

  • Page 464

    464 actionscript classes filter_1.Bias = 20; trace(filter_1.Bias); // 20 trace(filter_2.Bias); // 20 trace(clonedfilter.Bias); // 0 color (convolutionfilter.Color property) public color : number the hexadecimal color to substitute for pixels that are off the source image. This is an rgb value with n...

  • Page 465

    Convolutionfilter (flash.Filters.Convolutionfilter) 465 convolutionfilter constructor public convolutionfilter(matrixx:number, matrixy:number, matrix:array, [divisor:number], [bias:number], [preservealpha:boolean], [clamp:boolean], [color:number], [alpha:number]) initializes a convolutionfilter inst...

  • Page 466

    466 actionscript classes the following example creates a convolutionfilter object with the four required parameters matrixx , matrixy , matrix , and divisor . Import flash.Filters.Convolutionfilter; import flash.Display.Bitmapdata; var matrixx:number = 3; var matrixy:number = 3; var matrix:array = [...

  • Page 467

    Convolutionfilter (flash.Filters.Convolutionfilter) 467 mc.Attachbitmap(mybitmapdata, this.Getnexthighestdepth()); mybitmapdata.Noise(128); mc.Onpress = function() { var newdivisor:number = 6; filter.Divisor = newdivisor; mybitmapdata.Applyfilter(mybitmapdata, mybitmapdata.Rectangle, new point(0, 0)...

  • Page 468

    468 actionscript classes matrixx (convolutionfilter.Matrixx property) public matrixx : number the x dimension of the matrix (the number of columns in the matrix). The default value is 0. Availability: actionscript 1.0; flash player 8 example the following example displays the matrixx property of fil...

  • Page 469

    Customactions 469 example the following example changes the preservealpha property of filter from its default value of true to false . Import flash.Filters.Convolutionfilter; import flash.Display.Bitmapdata; var preservealpha:boolean = false; var filter:convolutionfilter = new convolutionfilter(3, 3...

  • Page 470

    470 actionscript classes property summary properties inherited from class object method summary methods inherited from class object get (customactions.Get method) public static get(name:string) : string reads the contents of the custom action xml definition file named name . The name of the definiti...

  • Page 471

    Customactions 471 parameters name:string - the name of the custom action definition to retrieve. Returns string - if the custom action xml definition is located, returns a string; otherwise, returns undefined . Example the following example lists the custom actions in a combobox instance, and gets t...

  • Page 472

    472 actionscript classes parameters name:string - the name of the custom action definition to install. Data:string - the text of the xml definition to install. Returns boolean - a boolean value of false if an error occurs during installation; otherwise, a value of true is returned to indicate that t...

  • Page 473

    Customactions 473 list (customactions.List method) public static list() : array returns an array object containing the names of all the custom actions that are registered with the flash authoring tool. The elements of the array are simple names, without the .Xml file extension, and without any direc...

  • Page 474

    474 actionscript classes uninstall (customactions.Uninstall method) public static uninstall(name:string) : boolean removes the custom actions xml definition file named name . The name of the definition file must be a simple filename, without the .Xml file extension, and without any directory separat...

  • Page 476

    476 actionscript classes property summary properties inherited from class object constructor summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) signature description date ([yearorti...

  • Page 477

    Date 477 method summary modifiers signature description getdate () : number returns the day of the month (an integer from 1 to 31) of the specified date object according to local time. Getday () : number returns the day of the week (0 for sunday, 1 for monday, and so on) of the specified date object...

  • Page 478

    478 actionscript classes getutcminutes () : number returns the minutes (an integer from 0 to 59) of the specified date object, according to universal time. Getutcmonth () : number returns the month (0 [january] to 11 [december]) of the specified date object, according to universal time. Getutcsecond...

  • Page 479

    Date 479 setutcfullyear (year: number, [month:number], [date:number]) : number sets the year for the specified date object (my_date) in universal time and returns the new time in milliseconds. Setutchours (hour:num ber, [minute:number], [second:number], [millisecond:number] ) : number sets the hour ...

  • Page 480

    480 actionscript classes methods inherited from class object date constructor public date([yearortimevalue:number], [month:number], [date:number], [hour:number], [minute:number], [second:number], [millisecond:number]) constructs a new date object that holds the specified date and time. The date() co...

  • Page 481

    Date 481 in the third line, a date object is created with year, month, and date parameters passed to it, resulting in the time 09:30:15 gmt (+ 0 milliseconds) march 6, 1965. Note that since the year parameter is specified as a two-digit integer, it is interpreted as 1965. In the fourth line, only on...

  • Page 482

    482 actionscript classes see also getmonth (date.Getmonth method) , getdate (date.Getdate method) , getfullyear (date.Getfullyear method) getdate (date.Getdate method) public getdate() : number returns the day of the month (an integer from 1 to 31) of the specified date object according to local tim...

  • Page 483

    Date 483 example the following example creates a new date object and uses getday() to determine the current day of the week : var dayofweek_array:array = new array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"); var today_date:date = new date(); var day_str:string = da...

  • Page 484

    484 actionscript classes example the following example uses the constructor to create a date object based on the current time and uses the gethours() method to display hour values from that object: var my_date:date = new date(); trace(my_date.Gethours()); var my_date:date = new date(); var hourobj:o...

  • Page 485

    Date 485 getminutes (date.Getminutes method) public getminutes() : number returns the minutes (an integer from 0 to 59) of the specified date object, according to local time. Local time is determined by the operating system on which flash player is running. Availability: actionscript 1.0; flash play...

  • Page 486

    486 actionscript classes var monthnames_array:array = new array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); return monthnames_array[month]; } getseconds (date.Getseconds method) public getseconds() : number returns the se...

  • Page 487

    Date 487 gettimezoneoffset (date.Gettimezoneoffset method) public gettimezoneoffset() : number returns the difference, in minutes, between the computer's local time and universal time. Availability: actionscript 1.0; flash player 5 returns number - an integer. Example the following example returns t...

  • Page 488

    488 actionscript classes see also getdate (date.Getdate method) getutcday (date.Getutcday method) public getutcday() : number returns the day of the week (0 for sunday, 1 for monday, and so on) of the specified date object, according to universal time. Availability: actionscript 1.0; flash player 5 ...

  • Page 489

    Date 489 example the following example creates a new date object and uses date.Getutcfullyear() and date.Getfullyear() . The value returned by date.Getutcfullyear() may differ from the value returned by date.Getfullyear() if today's date is december 31 or january 1 , depending on the relationship be...

  • Page 490

    490 actionscript classes getutcmilliseconds (date.Getutcmilliseconds method) public getutcmilliseconds() : number returns the milliseconds (an integer from 0 to 999) of the specified date object, according to universal time. Availability: actionscript 1.0; flash player 5 returns number - an integer....

  • Page 491

    Date 491 returns number - an integer. Example the following example creates a new date object and uses date.Getutcmonth() and date.Getmonth() . The value returned by date.Getutcmonth() can differ from the value returned by date.Getmonth() if today's date is the first or last day of a month , dependi...

  • Page 492

    492 actionscript classes returns number - an integer. Example the following example creates a new date object and uses date.Getutcfullyear() and date.Getfullyear() . The value returned by date.Getutcfullyear() may differ from the value returned by date.Getfullyear() if today's date is december 31 or...

  • Page 493

    Date 493 setdate (date.Setdate method) public setdate(date:number) : number sets the day of the month for the specified date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which flash player is running. Availability: act...

  • Page 494

    494 actionscript classes date:number [optional] - a number from 1 to 31. If you omit this parameter, the date field of the specified date object will not be modified. Returns number - an integer. Example the following example initially creates a new date object, setting the date to may 15, 2004, and...

  • Page 495

    Date 495 setmilliseconds (date.Setmilliseconds method) public setmilliseconds(millisecond:number) : number sets the milliseconds for the specified date object according to local time and returns the new time in milliseconds. Local time is determined by the operating system on which flash player is r...

  • Page 496

    496 actionscript classes example the following example initially creates a new date object, setting the time and date to 8:00 a.M. On may 15, 2004, and then uses date.Setminutes() to change the time to 8:30 a.M.: var my_date:date = new date(2004,4,15,8,0); trace(my_date.Getminutes()); // output: 0 m...

  • Page 497

    Date 497 parameters second:number - an integer from 0 to 59. Returns number - an integer. Example the following example initially creates a new date object, setting the time and date to 8:00:00 a.M. On may 15, 2004, and uses date.Setseconds() to change the time to 8:00:45 a.M.: var my_date:date = ne...

  • Page 498

    498 actionscript classes setutcdate (date.Setutcdate method) public setutcdate(date:number) : number sets the date for the specified date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified date object, but date.Get...

  • Page 499

    Date 499 parameters year:number - an integer that represents the year specified as a full four-digit year, such as 2000. Month:number [optional] - an integer from 0 (january) to 11 (december). If you omit this parameter, the month field of the specified date object will not be modified. Date:number ...

  • Page 500

    500 actionscript classes second:number [optional] - a number; an integer from 0 to 59. If you omit this parameter, the seconds field of the specified date object will not be modified. Millisecond:number [optional] - a number; an integer from 0 to 999. If you omit this parameter, the milliseconds fie...

  • Page 501

    Date 501 example the following example initially creates a new date object, setting the date to 8:30 a.M. On may 15, 2004 with the milliseconds value set to 250, and uses date.Setutcmilliseconds() to change the milliseconds value to 575: var my_date:date = new date(2004,4,15,8,30,0,250); trace(my_da...

  • Page 502

    502 actionscript classes setutcmonth (date.Setutcmonth method) public setutcmonth(month:number, [date:number]) : number sets the month, and optionally the day, for the specified date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fiel...

  • Page 503

    Date 503 millisecond:number [optional] - an integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified date object will not be modified. Returns number - an integer. Example the following example initially creates a new date object, setting the time and date to 8:00:0...

  • Page 504

    504 actionscript classes trace(my_date.Getyear()); // output: 103 trace(my_date.Getfullyear()); // output: 2003 tostring (date.Tostring method) public tostring() : string returns a string value for the specified date object in a readable format. Availability: actionscript 1.0; flash player 5 returns...

  • Page 505

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 505 returns number - an integer. Example the following example creates a new marybirthday_date date object defined in universal time. This is the universal time variation of the example used for the new date constructor method. The output i...

  • Page 506

    506 actionscript classes to apply filters to movie clips at runtime, use the filters property. Setting the filters property of an object does not modify the object and can be undone by clearing the filters property. To apply filters to bitmapdata instances, use the bitmapdata.Applyfilter() method. C...

  • Page 507

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 507 property summary properties inherited from class object constructor summary modifiers property description alpha :number specifies the alpha transparency value to use for out- of-bounds displacements. Color :number specifies what color ...

  • Page 508

    508 actionscript classes method summary methods inherited from class bitmapfilter methods inherited from class object alpha (displacementmapfilter.Alpha property) public alpha : number specifies the alpha transparency value to use for out-of-bounds displacements. This is specified as a normalized va...

  • Page 509

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 509 filter.Alpha = .25; this.Filters = new array(filter); } function createdisplacementmaprectangle():movieclip { var mapbitmap:bitmapdata = creategradientbitmap(300, 80, 0xff000000, "radial"); var filter:displacementmapfilter = new displac...

  • Page 510

    510 actionscript classes clone (displacementmapfilter.Clone method) public clone() : displacementmapfilter returns a copy of this filter object. Availability: actionscript 1.0; flash player 8 returns flash.Filters.Displacementmapfilter - a new displacementmapfilter instance with all the same propert...

  • Page 511

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 511 } for(var i in clonedfilter) { trace(">> " + i + ": " + clonedfilter[i]); // >> clone: [type function] // >> alpha: 0 // >> color: 0 // >> mode: wrap // >> scaley: 10 // >> scalex: 10 // >> componenty: 1 // >> componentx: 1 // >> mappoi...

  • Page 512

    512 actionscript classes var mapbitmap:bitmapdata = creategradientbitmap(300, 80, 0xff000000, "radial", true); var filter_1:displacementmapfilter = new displacementmapfilter(mapbitmap, new point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var filter_2:displacementmapfilter = filter_1; var ...

  • Page 513

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 513 example the following example modifies the out-of-range color property on the existing movieclip filteredmc to 0x00ff00 when a user clicks it. Import flash.Filters.Displacementmapfilter; import flash.Display.Bitmapdata; import flash.Geo...

  • Page 514

    514 actionscript classes var bmp:bitmapdata = new bitmapdata(w, h, true, bgcolor); bmp.Draw(mc, new matrix(), new colortransform(), "normal", bmp.Rectangle, true); mc.Attachbitmap(bmp, this.Getnexthighestdepth()); return bmp; } function createtextblock():movieclip { var txtblock:movieclip = this.Cre...

  • Page 515

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 515 function createdisplacementmaprectangle():movieclip { var mapbitmap:bitmapdata = creategradientbitmap(300, 80, 0xff000000, "radial"); var filter:displacementmapfilter = new displacementmapfilter(mapbitmap, new point(-30, -30), 1, 1, 10,...

  • Page 516

    516 actionscript classes componenty (displacementmapfilter.Componenty property) public componenty : number describes which color channel to use in the map image to displace the y result. Possible values are 1 (red), 2 (green), 4 (blue), and 8 (alpha). Availability: actionscript 1.0; flash player 8 e...

  • Page 517

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 517 mc.Begingradientfill(type, [0xff0000, 0x0000ff], [100, 100], [0x55, 0x99], matrix, "pad"); mc.Lineto(w, 0); mc.Lineto(w, h); mc.Lineto(0, h); mc.Lineto(0, 0); mc.Endfill(); (hide == true) ? Mc._alpha = 0 : mc._alpha = 100; var bmp:bitma...

  • Page 518

    518 actionscript classes componentx:number - describes which color channel to use in the map image to displace the x result. Possible values are the following: ■ 1 (red) ■ 2 (green) ■ 4 (blue) ■ 8 (alpha) componenty:number - describes which color channel to use in the map image to displace the y res...

  • Page 519

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 519 import flash.Filters.Displacementmapfilter; import flash.Display.Bitmapdata; import flash.Geom.Point; import flash.Geom.Matrix; import flash.Geom.Colortransform; var mapbitmap:bitmapdata = creategradientbitmap(300, 80, 0xff000000, "radi...

  • Page 520

    520 actionscript classes function createtextblock():movieclip { var txtblock:movieclip = this.Createemptymovieclip("txtblock", this.Getnexthighestdepth()); txtblock.Createtextfield("txt", this.Getnexthighestdepth(), 0, 0, 300, 80); txtblock.Txt.Text = "watch the text bend with the displacement map";...

  • Page 521

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 521 txtblock._x = 30; txtblock._y = 30; txtblock.Filters = new array(filter); return txtblock; } function creategradientbitmap(w:number, h:number, bgcolor:number, type:string, hide:boolean):bitmapdata { var mc:movieclip = this.Createemptymo...

  • Page 522

    522 actionscript classes mappoint (displacementmapfilter.Mappoint property) public mappoint : point a flash.Geom.Point value that contains the offset of the upper-left corner of the target movie clip from the upper-left corner of the map image. The mappoint property cannot be changed by directly mod...

  • Page 523

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 523 function creategradientbitmap(w:number, h:number, bgcolor:number, type:string, hide:boolean):bitmapdata { var mc:movieclip = this.Createemptymovieclip("mc", 1); var matrix:matrix = new matrix(); matrix.Creategradientbox(w, h, 0, 0, 0); ...

  • Page 524

    524 actionscript classes mode (displacementmapfilter.Mode property) public mode : string the mode for the filter. Possible values are the following: ■ "wrap" — wraps the displacement value to the other side of the source image. This is the default value. ■ "clamp" — clamps the displacement value to ...

  • Page 525

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 525 return txtblock; } function creategradientbitmap(w:number, h:number, bgcolor:number, type:string, hide:boolean):bitmapdata { var mc:movieclip = this.Createemptymovieclip("mc", 1); var matrix:matrix = new matrix(); matrix.Creategradientb...

  • Page 526

    526 actionscript classes import flash.Geom.Point; import flash.Geom.Matrix; import flash.Geom.Colortransform; var filteredmc:movieclip = createdisplacementmaprectangle(); filteredmc.Onpress = function() { var filter:displacementmapfilter = this.Filters[0]; filter.Scalex = 5; this.Filters = new array...

  • Page 527

    Displacementmapfilter (flash.Filters.Displacementmapfilter) 527 function createtextblock():movieclip { var txtblock:movieclip = this.Createemptymovieclip("txtblock", this.Getnexthighestdepth()); txtblock.Createtextfield("txt", this.Getnexthighestdepth(), 0, 0, 300, 80); txtblock.Txt.Text = "watch th...

  • Page 528

    528 actionscript classes function creategradientbitmap(w:number, h:number, bgcolor:number, type:string, hide:boolean):bitmapdata { var mc:movieclip = this.Createemptymovieclip("mc", 1); var matrix:matrix = new matrix(); matrix.Creategradientbox(w, h, 0, 0, 0); mc.Begingradientfill(type, [0xff0000, 0...

  • Page 529

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 529 the use of filters depends on the object to which you apply the filter: ■ to apply filters to movie clips, text fields, and buttons at runtime, use the filters property. Setting the filters property of an object does not modify the object and can...

  • Page 530

    530 actionscript classes property summary properties inherited from class object constructor summary modifiers property description alpha :number the alpha transparency value for the shadow color. Angle :number the angle of the shadow. Blurx :number the amount of horizontal blur. Blury :number the a...

  • Page 531

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 531 method summary methods inherited from class bitmapfilter methods inherited from class object alpha (dropshadowfilter.Alpha property) public alpha : number the alpha transparency value for the shadow color. Valid values are 0 to 1. For example, .2...

  • Page 532

    532 actionscript classes art.Lineto(0, h); art.Lineto(0, 0); art._x = 20; art._y = 20; var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; return art; } ...

  • Page 533

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 533 var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; return art; } blurx (dropshadowfilter.Blurx pro...

  • Page 534

    534 actionscript classes return art; } blury (dropshadowfilter.Blury property) public blury : number the amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than ot...

  • Page 535

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 535 clone (dropshadowfilter.Clone method) public clone() : dropshadowfilter returns a copy of this filter object. Availability: actionscript 1.0; flash player 8 returns flash.Filters.Dropshadowfilter - a new dropshadowfilter instance with all the pro...

  • Page 536

    536 actionscript classes // >> hideobject: false // >> strength: 1 // >> blury: 16 // >> blurx: 16 // >> knockout: false // >> inner: false // >> quality: 3 // >> alpha: 0.8 // >> color: 0 // >> angle: 45 // >> distance: 15 } to further demonstrate the relationships between filter_1 , filter_2 , and...

  • Page 537

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 537 var mc:movieclip = createdropshadowrectangle("dropshadowcolor"); mc.Onrelease = function() { var filter:dropshadowfilter = this.Filters[0]; filter.Color = 0xff0000; this.Filters = new array(filter); } function createdropshadowrectangle(name:strin...

  • Page 538

    538 actionscript classes var art:movieclip = this.Createemptymovieclip(name, this.Getnexthighestdepth()); var w:number = 100; var h:number = 100; art.Beginfill(0x003366); art.Lineto(w, 0); art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0, 0); art._x = 20; art._y = 20; var filter:dropshadowfilter = n...

  • Page 539

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 539 blury:number [optional] - the amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values. Strength:...

  • Page 540

    540 actionscript classes blury, strength, quality, inner, knockout, hideobject); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; function createrectangle(w:number, h:number, bgcolor:number, name:string):movieclip { var mc:movieclip = this.Createemptymoviecli...

  • Page 541

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 541 var h:number = 100; art.Beginfill(0x003366); art.Lineto(w, 0); art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0, 0); art._x = 20; art._y = 20; var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, fa...

  • Page 542

    542 actionscript classes art._x = 20; art._y = 20; var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; return art; } knockout (dropshadowfilter.Knockout ...

  • Page 543

    Dropshadowfilter (flash.Filters.Dropshadowfilter) 543 var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; return art; } quality (dropshadowfilter.Quality...

  • Page 544

    544 actionscript classes var filter:dropshadowfilter = new dropshadowfilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; return art; } strength (dropshadowfilter.Strength property) public strength ...

  • Page 546

    546 actionscript classes method summary methods inherited from class object error constructor public error([message:string]) creates a new error object. If message is specified, its value is assigned to the object's error.Message property. Availability: actionscript 1.0; flash player 7 parameters me...

  • Page 547

    Error 547 message (error.Message property) public message : string contains the message associated with the error object. By default, the value of this property is " error ". You can specify a message property when you create an error object by passing the error string to the error constructor funct...

  • Page 548

    ...

  • Page 549

    Externalinterface (flash.External.Externalinterface) 549 example in the following example, a function throws an error (with a specified message) if the two strings that are passed to it are not identical: function comparestrings(str1_str:string, str2_str:string):void { if (str1_str != str2_str) { th...

  • Page 550

    550 actionscript classes externalinterface is supported in the following combinations of browser and operating system: externalinterface requires the user's web browser to support either activex or the npruntime api that is exposed by some browsers for plugin scripting. See http:// www.Mozilla.Org/p...

  • Page 551

    Externalinterface (flash.External.Externalinterface) 551 method summary methods inherited from class object addcallback (externalinterface.Addcallback method) public static addcallback(methodname:string, instance:object, method:function) : boolean registers an actionscript method as callable from th...

  • Page 552

    552 actionscript classes returns boolean - if the call succeeded, returns true . If it failed because the instance was not available, a security restriction was encountered, there was no such function object, a recursion occurred, or something similar, returns false . A return value of false may als...

  • Page 553

    Externalinterface (flash.External.Externalinterface) 553 function callexternalinterface() { thismovie("externalinterfaceexample").Gohome(); } function thismovie(moviename) { if (navigator.Appname.Indexof("microsoft") != -1) { return window[moviename] } else { return document[moviename] } } available...

  • Page 554

    554 actionscript classes if the container is hosting the netscape plug-in, you can either write custom support for the new npruntime interface or embed an html control and embed flash player within the html control. If you embed an html control, you can communicate with flash player through a javasc...

  • Page 555

    Filereference (flash.Net.Filereference) 555 mc.Lineto(0, 0); mcfmt = new textformat(); mcfmt.Align = "center"; mcfmt.Bold = true; mc.Createtextfield("mctxt", depth, 0, 0, width, height); mc.Mctxt.Text = "call js function"; mc.Mctxt.Settextformat(mcfmt); return mc; } for the previous example to work ...

  • Page 556

    556 actionscript classes during an upload operation, all of the properties of a filereference object are populated by calls to filereference.Browse() or filereferencelist.Browse() . During a download operation, the name property is populated when onselect has been invoked; all other properties are p...

  • Page 557

    Filereference (flash.Net.Filereference) 557 example the following example creates a filereference object that prompts the user to select an image or text file to be uploaded. It also listens for any possible event. Import flash.Net.Filereference; var alltypes:array = new array(); var imagetypes:obje...

  • Page 558

    558 actionscript classes trace("onioerror: " + file.Name); } listener.Onsecurityerror = function(file:filereference, errorstring:string):void { trace("onsecurityerror: " + file.Name + " errorstring: " + errorstring); } var fileref:filereference = new filereference(); fileref.Addlistener(listener); f...

  • Page 559

    Filereference (flash.Net.Filereference) 559 event summary event description oncancel = function(fileref :filereference) {} invoked when the user dismisses the file-browsing dialog box. Oncomplete = function(fileref :filereference) {} invoked when the upload or download operation has successfully com...

  • Page 560

    560 actionscript classes constructor summary method summary methods inherited from class object addlistener (filereference.Addlistener method) public addlistener(listener:object) : void registers an object to receive notification when a filereference event listener is invoked. Availability: actionsc...

  • Page 561

    Filereference (flash.Net.Filereference) 561 parameters listener:object - an object that listens for a callback notification from the filereference event listeners. Example the following example adds a listener to an instance of filereference. Import flash.Net.Filereference; var listener:object = new...

  • Page 562

    562 actionscript classes parameters typelist:array [optional] - an array of file types used to filter the files displayed in the dialog box. If you omit this parameter, all files are displayed. If you include this parameter, the array must contain one or more elements enclosed in curly braces { }. Y...

  • Page 563

    Filereference (flash.Net.Filereference) 563 returns boolean - returns true if the parameters are valid and the file-browsing dialog box is displayed. Returns false if the dialog box is not displayed, if another browse session is already in progress, or if you use the typelist parameter but fail to p...

  • Page 564

    564 actionscript classes example the following example downloads approximately half of the requested file and then cancels the download. This is obviously not a typical usage. You might more often use this method to allow users to click cancel in a download status dialog box. Import flash.Net.Filere...

  • Page 565

    Filereference (flash.Net.Filereference) 565 see also browse (filereference.Browse method) creator (filereference.Creator property) public creator : string [read-only] the macintosh creator type of the file. In windows, this property is null . If the filereference object has not been populated, a cal...

  • Page 566

    566 actionscript classes when the file has successfully downloaded, the properties of the filereference object are populated with the properties of the local file and the oncomplete listener is invoked. Only one browse() or download() session can be performed at a time (because only one dialog box c...

  • Page 567

    Filereference (flash.Net.Filereference) 567 returns boolean - a value of true if the dialog box in which a user can select a file is displayed. If the dialog box is not displayed, the method returns false . The dialog box could fail to be displayed for any of the following reasons: ■ you did not pas...

  • Page 568

    568 actionscript classes listener.Onioerror = function(file:filereference):void { trace("onioerror: " + file.Name); } var fileref:filereference = new filereference(); fileref.Addlistener(listener); var url:string = "http://www.Macromedia.Com/platform/whitepapers/ platform_overview.Pdf"; if(!Fileref....

  • Page 569

    Filereference (flash.Net.Filereference) 569 modificationdate (filereference.Modificationdate property) public modificationdate : date [read-only] the date that the file on the local disk was last modified. If the filereference object has not been populated, a call to get the value of this property r...

  • Page 570

    570 actionscript classes } var fileref:filereference = new filereference(); fileref.Addlistener(listener); fileref.Browse(); see also browse (filereference.Browse method) oncancel (filereference.Oncancel event listener) oncancel = function(fileref:filereference) {} invoked when the user dismisses th...

  • Page 571

    Filereference (flash.Net.Filereference) 571 oncomplete (filereference.Oncomplete event listener) oncomplete = function(fileref:filereference) {} invoked when the upload or download operation has successfully completed. Successful completion means that the entire file has been uploaded or downloaded....

  • Page 572

    572 actionscript classes parameters fileref:flash.Net.Filereference - the file reference object that initiated the operation. Httperror:number - the http error that caused this upload to fail. For example, an httperror of 404 indicates that a page is not found. Http error values can be found in sect...

  • Page 573

    Filereference (flash.Net.Filereference) 573 trace("onioerror: " + file.Name); } listener.Onsecurityerror = function(file:filereference, errorstring:string):void { trace("onsecurityerror: " + file.Name + " errorstring: " + errorstring); } var fileref:filereference = new filereference(); fileref.Addli...

  • Page 574

    574 actionscript classes example the following example traces a message when the onioerror event is triggered. For simplicity, none of the other event listeners are included in this example. Import flash.Net.Filereference; var listener:object = new object(); listener.Onioerror = function(file:filere...

  • Page 575

    Filereference (flash.Net.Filereference) 575 onprogress (filereference.Onprogress event listener) onprogress = function(fileref:filereference, bytesloaded:number, bytestotal:number) {} invoked periodically during the file upload or download operation. The onprogress listener is invoked while the flas...

  • Page 576

    576 actionscript classes see also onsecurityerror (filereference.Onsecurityerror event listener) onsecurityerror = function(fileref:filereference, errorstring:string) {} invoked when an upload or download fails because of a security error. The calling swf file may have tried to access a swf file out...

  • Page 577

    Filereference (flash.Net.Filereference) 577 trace("onprogress with bytesloaded: " + bytesloaded + " bytestotal: " + bytestotal); } listener.Oncomplete = function(file:filereference):void { trace("oncomplete: " + file.Name); } listener.Onhttperror = function(file:filereference):void { trace("onhttper...

  • Page 578

    578 actionscript classes parameters fileref:flash.Net.Filereference - the filereference object that initiated the operation. Example the following example traces a message within the onselect event listener. Import flash.Net.Filereference; var listener:object = new object(); listener.Onselect = func...

  • Page 579

    Filereference (flash.Net.Filereference) 579 example the following example removes an event listener using the removelistener method. If a user cancels the download, the listener is removed so that it no longer receives events from that filereference object. Import flash.Net.Filereference; var listen...

  • Page 580

    580 actionscript classes type (filereference.Type property) public type : string [read-only] the file type. In windows, this property is the file extension. On the macintosh, this property is the four-character file type. If the filereference object has not been populated, a call to get the value of...

  • Page 581

    Filereference (flash.Net.Filereference) 581 the file is uploaded to the url passed in the url parameter. The url must be a server script configured to accept uploads. Flash player uploads files using the http post method. The server script that handles the upload should expect a post request with th...

  • Page 582

    582 actionscript classes you can send data to the server with the upload() call by appending parameters to the url; for example, http://www.Myserver.Com/upload.Cgi?Userid=jdoe on some browsers, url strings are limited in length. Lengths greater than 256 characters may fail on some browsers or server...

  • Page 583

    Filereference (flash.Net.Filereference) 583 listener.Onopen = function(file:filereference):void { trace("onopen: " + file.Name); } listener.Onprogress = function(file:filereference, bytesloaded:number, bytestotal:number):void { trace("onprogress with bytesloaded: " + bytesloaded + " bytestotal: " + ...

  • Page 585

    Filereferencelist (flash.Net.Filereferencelist) 585 trace(item.Addlistener(this)); item.Upload("http://www.Yourdomain.Com/"); } } listener.Oncancel = function():void { trace("oncancel"); } listener.Onopen = function(file:filereference):void { trace("onopen: " + file.Name); } listener.Onprogress = fu...

  • Page 586

    586 actionscript classes property summary properties inherited from class object event summary constructor summary modifiers property description filelist :array an array of filereference objects. Constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.P...

  • Page 587

    Filereferencelist (flash.Net.Filereferencelist) 587 method summary methods inherited from class object addlistener (filereferencelist.Addlistener method) public addlistener(listener:object) : void registers an object to receive notification when a filereferencelist event listener is invoked. Availab...

  • Page 588

    588 actionscript classes var fileref:filereferencelist = new filereferencelist(); fileref.Addlistener(listener); fileref.Browse(); browse (filereferencelist.Browse method) public browse([typelist:array]) : boolean displays a file-browsing dialog box in which the user can select one or more local fil...

  • Page 589

    Filereferencelist (flash.Net.Filereferencelist) 589 ■ a list of file type descriptions followed by their windows file extensions and their macintosh file types. Each element in the array must contain a string that describes the file type; a semicolon- delimited list of windows file extensions, with ...

  • Page 590

    590 actionscript classes texttypes.Extension = "*.Txt; *.Rtf"; alltypes.Push(texttypes); var fileref:filereferencelist = new filereferencelist(); fileref.Browse(alltypes); see also browse (filereference.Browse method) , filereference (flash.Net.Filereference) filelist (filereferencelist.Filelist pro...

  • Page 591

    Filereferencelist (flash.Net.Filereferencelist) 591 var fileref:filereferencelist = new filereferencelist(); fileref.Addlistener(listener); fileref.Browse(); see also filereference (flash.Net.Filereference) , upload (filereference.Upload method) , browse (filereferencelist.Browse method) filereferen...

  • Page 592

    592 actionscript classes oncancel (filereferencelist.Oncancel event listener) oncancel = function(filereflist:filereferencelist) {} invoked when the user dismisses the file-browsing dialog box. (this dialog box is displayed when you call the filereferencelist.Browse() , filereference.Browse() , or f...

  • Page 593

    Filereferencelist (flash.Net.Filereferencelist) 593 parameters filereflist:flash.Net.Filereferencelist - the filereferencelist object that initiated the operation. Example the following example demonstrates the onselect listener. Import flash.Net.Filereferencelist; import flash.Net.Filereference; va...

  • Page 594

    594 actionscript classes parameters listener:object - an object that listens for a callback notification from the filereferencelist event listeners. Returns boolean - returns true if the object is removed. Otherwise, this method returns false . Example the following example demonstrates the removeli...

  • Page 595

    Function 595 property summary properties inherited from class object method summary methods inherited from class object apply (function.Apply method) public apply(thisobject:object, [argarray:array]) : void specifies the value of thisobject to be used within any function that actionscript calls. Thi...

  • Page 596

    596 actionscript classes parameters thisobject:object - the object to which myfunction is applied. Argarray:array [optional] - an array whose elements are passed to myfunction as parameters. Example the following function invocations are equivalent: math.Atan2(1, 0) math.Atan2.Apply(null, [1, 0]) th...

  • Page 597

    Function 597 // use apply() to set the value of this to be myobj and send secondarray thefunction.Apply(myobj,secondarray); // output: // this == myobj? True // arguments: a,b,c see also call (function.Call method) call (function.Call method) public call(thisobject:object, [parameter1:object]) : obj...

  • Page 598

    598 actionscript classes returns object - example the following example uses function.Call() to make a function behave as a method of another object, without storing the function in the object: function myobject() { } function mymethod(obj) { trace("this == obj? " + (this == obj)); } var obj:object ...

  • Page 599

    Glowfilter (flash.Filters.Glowfilter) 599 you can also apply filter effects to images and video during authoring. For more information, see your authoring documentation. If you apply a filter to a movie clip or button, the cacheasbitmap property of the movie clip or button is set to true . If you cl...

  • Page 600

    600 actionscript classes constructor summary method summary methods inherited from class bitmapfilter methods inherited from class object alpha (glowfilter.Alpha property) public alpha : number the alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency ...

  • Page 601

    Glowfilter (flash.Filters.Glowfilter) 601 example the following example changes the alpha property on an existing movie clip when a user clicks it. Import flash.Filters.Glowfilter; var mc:movieclip = createglowfilterrectangle("glowfilteralpha"); mc.Onrelease = function() { var filter:glowfilter = th...

  • Page 602

    602 actionscript classes example the following example changes the blurx property on an existing movie clip when a user clicks it. Import flash.Filters.Glowfilter; var mc:movieclip = createglowfilterrectangle("glowfilterblurx"); mc.Onrelease = function() { var filter:glowfilter = this.Filters[0]; fi...

  • Page 603

    Glowfilter (flash.Filters.Glowfilter) 603 example the following example changes the blury property on an existing movie clip when a user clicks it. Import flash.Filters.Glowfilter; var mc:movieclip = createglowfilterrectangle("glowfilterblury"); mc.Onrelease = function() { var filter:glowfilter = th...

  • Page 604

    604 actionscript classes example the following example creates three glowfilter objects and compares them: filter_1 is created by using the glowfilter constructor; filter_2 is created by setting it equal to filter_1 ; and clonedfilter is created by cloning filter_1 . Notice that although filter_2 ev...

  • Page 605

    Glowfilter (flash.Filters.Glowfilter) 605 to further demonstrate the relationships between filter_1 , filter_2 , and clonedfilter , the following example modifies the knockout property of filter_1 . Modifying knockout demonstrates that the clone() method creates a new instance based on the values of...

  • Page 606

    606 actionscript classes rect.Beginfill(0x003366); rect.Lineto(w, 0); rect.Lineto(w, h); rect.Lineto(0, h); rect.Lineto(0, 0); rect._x = 20; rect._y = 20; var filter:glowfilter = new glowfilter(0x000000, .8, 16, 16, 1, 3, false, false); var filterarray:array = new array(); filterarray.Push(filter); ...

  • Page 607

    Glowfilter (flash.Filters.Glowfilter) 607 inner:boolean [optional] - specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false , an outer glow (a glow around the outer edges of the object). Knockout:boolean [optional] - specifies whether the object has...

  • Page 608

    608 actionscript classes mc._y = 20; return mc; } inner (glowfilter.Inner property) public inner : boolean specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false , an outer glow (a glow around the outer edges of the object). Availability: actionscri...

  • Page 609

    Glowfilter (flash.Filters.Glowfilter) 609 knockout (glowfilter.Knockout property) public knockout : boolean specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default is false (no knockout effe...

  • Page 610

    610 actionscript classes quality (glowfilter.Quality property) public quality : number the number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower v...

  • Page 611

    Glowfilter (flash.Filters.Glowfilter) 611 strength (glowfilter.Strength property) public strength : number the strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. The defaul...

  • Page 613

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 613 see also ratios (gradientbevelfilter.Ratios property) , applyfilter (bitmapdata.Applyfilter method) , bevelfilter (flash.Filters.Bevelfilter) , filters (button.Filters property) , cacheasbitmap (button.Cacheasbitmap property) , cacheasbitma...

  • Page 614

    614 actionscript classes constructor summary method summary methods inherited from class bitmapfilter methods inherited from class object signature description gradientbevelfilter ( [distance:number], [angle:number], [colors:array], [alphas:array], [ratios:array], [blurx:number], [blury:number], [st...

  • Page 615

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 615 alphas (gradientbevelfilter.Alphas property) public alphas : array an array of alpha transparency values for the corresponding colors in the colors array. Valid values for each element in the array are 0 to 1. For example, .25 sets a transp...

  • Page 616

    616 actionscript classes var filter:gradientbevelfilter = new gradientbevelfilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); art.Filters = new array(filter); return art; } see also colors (gradientbevelfilter.Colors property) , ratios (gradientbevelfilter.Ratios property) angle (gr...

  • Page 617

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 617 var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0, 128, 255]; var filter:gradientbevelfilter = new gradientbevelfilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.Fil...

  • Page 618

    618 actionscript classes var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0, 128, 255]; var filter:gradientbevelfilter = new gradientbevelfilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.Filters = new array(filter); return ar...

  • Page 619

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 619 art.Filters = new array(filter); return art; } clone (gradientbevelfilter.Clone method) public clone() : gradientbevelfilter returns a copy of this filter object. Availability: actionscript 1.0; flash player 8 returns flash.Filters.Gradient...

  • Page 620

    620 actionscript classes } function getnewfilter():gradientbevelfilter { var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0, 128, 255]; return new gradientbevelfilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); } colors (gradientbe...

  • Page 621

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 621 var w:number = 150; var h:number = 150; art.Beginfill(0xcccccc); art.Lineto(w, 0); art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0, 0); var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0,...

  • Page 622

    622 actionscript classes art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0, 0); var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0, 128, 255]; var filter:gradientbevelfilter = new gradientbevelfilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inne...

  • Page 623

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 623 strength:number [optional] - the strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the bevel and the background. Valid values are 0 to 255. A value of 0 means that the...

  • Page 624

    624 actionscript classes var filter:gradientbevelfilter = new gradientbevelfilter(distance, angleindegrees, colors, alphas, ratios, blurx, blury, strength, quality, type, knockout); var filterarray:array = new array(); filterarray.Push(filter); art.Filters = filterarray; function setupflatrectangle(...

  • Page 625

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 625 example the following example demonstrates how to set the knockout property on an existing object. Import flash.Filters.Gradientbevelfilter; var mc:movieclip = setupfilter("knockoutexample"); mc.Onrelease = function() { var arr:array = this...

  • Page 626

    626 actionscript classes example the following example demonstrates how to set the quality property on an existing object. Import flash.Filters.Gradientbevelfilter; var mc:movieclip = setupfilter("qualityexample"); mc.Onrelease = function() { var arr:array = this.Filters; arr[0].Quality = 1; // low ...

  • Page 627

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 627 ratios (gradientbevelfilter.Ratios property) public ratios : array an array of color distribution ratios for the corresponding colors in the colors array. Valid values for each element in the array are 0 to 255. The ratios property cannot b...

  • Page 628

    628 actionscript classes keep in mind that the spread of the colors in the gradient varies based on the values of the blurx , blury , strength , and quality properties, as well as the ratios values. Availability: actionscript 1.0; flash player 8 example the following example demonstrates how to set ...

  • Page 629

    Gradientbevelfilter (flash.Filters.Gradientbevelfilter) 629 art.Beginfill(0xcccccc); art.Lineto(w, 0); art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0, 0); var colors:array = [0xffffff, 0xcccccc, 0x000000]; var alphas:array = [1, 0, 1]; var ratios:array = [0, 128, 255]; var filter:gradientbevelfilt...

  • Page 630

    630 actionscript classes example the following example demonstrates how to set the strength property on an existing object. Import flash.Filters.Gradientbevelfilter; var mc:movieclip = setupfilter("strengthexample"); mc.Onrelease = function() { var arr:array = this.Filters; arr[0].Strength = 1; this...

  • Page 631

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 631 example the following example demonstrates how to set the type property on an existing object. Import flash.Filters.Gradientbevelfilter; var mc:movieclip = setupfilter("typeexample"); mc.Onrelease = function() { var arr:array = this.Filters; ...

  • Page 632

    632 actionscript classes the gradientglowfilter class lets you apply a gradient glow effect to a variety of objects in flash. A gradient glow is a realistic-looking glow with a color gradient that you can control. You can apply a gradient glow around the inner or outer edge of an object or on top of...

  • Page 633

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 633 property summary properties inherited from class object constructor summary modifiers property description alphas :array an array of alpha transparency values for the corresponding colors in the colors array. Angle :number the angle, in degre...

  • Page 634

    634 actionscript classes method summary methods inherited from class bitmapfilter methods inherited from class object alphas (gradientglowfilter.Alphas property) public alphas : array an array of alpha transparency values for the corresponding colors in the colors array. Valid values for each elemen...

  • Page 635

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 635 alphas.Pop(); alphas.Push(.3); alphas.Push(1); filter.Alphas = alphas; this.Filters = new array(filter); } function creategradientglowrectangle(name:string):movieclip { var art:movieclip = this.Createemptymovieclip(name, this.Getnexthighestde...

  • Page 636

    636 actionscript classes example the following example changes the angle property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowangle"); mc.Onrelease = function() { var filter:gradientglowfilter = this.Fi...

  • Page 637

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 637 example the following example changes the blurx property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowblurx"); mc.Onrelease = function() { var fi...

  • Page 638

    638 actionscript classes example the following example changes the blury property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowblury"); mc.Onrelease = function() { var filter:gradientglowfilter = this.Fi...

  • Page 639

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 639 example the following example creates three gradientglowfilter objects and compares them; filter_1 is created by using the gradientglowfilter construtor; filter_2 is created by setting it equal to filter_1 ; and, clonedfilter is created by cl...

  • Page 640

    640 actionscript classes // >> distance: 0 } to further demonstrate the relationships between filter_1 , filter_2 , and clonedfilter , the following example below modifies the knockout property of filter_1 . Modifying knockout demonstrates that the clone() method creates a new instance based on the ...

  • Page 641

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 641 example the following example changes the colors property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowcolors"); mc.Onrelease = function() { var ...

  • Page 642

    642 actionscript classes distance (gradientglowfilter.Distance property) public distance : number the offset distance of the glow. The default value is 4. Availability: actionscript 1.0; flash player 8 example the following example changes the distance property on an existing movie clip when a user ...

  • Page 643

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 643 gradientglowfilter constructor public gradientglowfilter([distance:number], [angle:number], [colors:array], [alphas:array], [ratios:array], [blurx:number], [blury:number], [strength:number], [quality:number], [type:string], [knockout:boolean]...

  • Page 644

    644 actionscript classes type:string [optional] - the placement of the filter effect. Possible values are: ■ "outer" : glow on the outer edge of the object ■ "inner" : glow on the inner edge of the object; the default ■ "full" : glow on top of the object the default value is "inner" . Knockout:boole...

  • Page 645

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 645 function createrectangle(w:number, h:number, bgcolor:number, name:string):movieclip { var mc:movieclip = this.Createemptymovieclip(name, this.Getnexthighestdepth()); mc.Beginfill(bgcolor); mc.Lineto(w, 0); mc.Lineto(w, h); mc.Lineto(0, h); mc...

  • Page 646

    646 actionscript classes var colors:array = [0xffffff, 0xff0000, 0xffff00, 0x00ccff]; var alphas:array = [0, 1, 1, 1]; var ratios:array = [0, 63, 126, 255]; var filter:gradientglowfilter = new gradientglowfilter(0, 45, colors, alphas, ratios, 55, 55, 2.5, 2, "outer", false); var filterarray:array = ...

  • Page 647

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 647 art.Lineto(0, h); art.Lineto(0, 0); art._x = 20; art._y = 20; var colors:array = [0xffffff, 0xff0000, 0xffff00, 0x00ccff]; var alphas:array = [0, 1, 1, 1]; var ratios:array = [0, 63, 126, 255]; var filter:gradientglowfilter = new gradientglow...

  • Page 648

    648 actionscript classes in the following code and image, a filter is applied to a black circle movie clip, with the type set to "full" . For instructional purposes, the first color in the colors array, pink, has an alpha value of 1, so it shows against the white document background. (in practice, y...

  • Page 649

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 649 if you make two small changes in the code, the effect of the glow can be very different, even with the same ratios and colors arrays. Set the alpha value of the first color in the array to 0, to make the filter blend in with the document's wh...

  • Page 650

    650 actionscript classes function creategradientglowrectangle(name:string):movieclip { var art:movieclip = this.Createemptymovieclip(name, this.Getnexthighestdepth()); var w:number = 100; var h:number = 100; art.Beginfill(0x003366); art.Lineto(w, 0); art.Lineto(w, h); art.Lineto(0, h); art.Lineto(0,...

  • Page 651

    Gradientglowfilter (flash.Filters.Gradientglowfilter) 651 example the following example changes the strength property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowstrength"); mc.Onrelease = function() { ...

  • Page 652

    652 actionscript classes example the following example changes the type property on an existing movie clip when a user clicks it. Import flash.Filters.Gradientglowfilter; var mc:movieclip = creategradientglowrectangle("glowtype"); mc.Onrelease = function() { var filter:gradientglowfilter = this.Filt...

  • Page 654

    654 actionscript classes * not all windows imes support all of these operations. So far the only ime that supports them all is the japanese ime. Every ime differs in its support of the os calls. ** on macintosh these methods are supported only for japanese, and they are not supported for third-party...

  • Page 655

    Ime (system.Ime) 655 property summary properties inherited from class object event summary modifiers property description static alphanumeric_full :st ring a string with the value "alphanumeric_full" for use with setconversionmode() and getconversionmode() . Static alphanumeric_half :st ring a strin...

  • Page 656

    656 actionscript classes method summary methods inherited from class object addlistener (ime.Addlistener method) public static addlistener(listener:object) : void registers an object to receive notification when an ime event handler is invoked by the onimecomposition event. Availability: actionscrip...

  • Page 657

    Ime (system.Ime) 657 parameters listener:object - an object, with an onimecomposition (readingstring) method, that listens for a callback notification from the ime event handlers. The reading string passed to this method is in the composition mode of the ime. For example, if the user enters text in ...

  • Page 658

    658 actionscript classes example the following example sets the ime to alphanumeric_full if the system has an input method editor (ime) installed ( system.Capabilities.Hasime ). If(system.Capabilities.Hasime) { trace(system.Ime.Getconversionmode()); system.Ime.Setconversionmode(system.Ime.Alphanumer...

  • Page 659

    Ime (system.Ime) 659 chinese (ime.Chinese property) public static chinese : string a string with the value "chinese" for use with setconversionmode() and getconversionmode() . This constant is used with simplified and traditional chinese imes. Availability: actionscript 1.0; flash player 8 example t...

  • Page 660

    660 actionscript classes mc.Onpress = function() { if(system.Capabilities.Hasime) { selection.Setfocus(mc.Txt); system.Ime.Setcompositionstring(mc.Txt.Text); trace(system.Ime.Doconversion()); } } getconversionmode (ime.Getconversionmode method) public static getconversionmode() : string indicates th...

  • Page 661

    Ime (system.Ime) 661 see also alphanumeric_full (ime.Alphanumeric_full property) , alphanumeric_half (ime.Alphanumeric_half property) , chinese (ime.Chinese property) , japanese_hiragana (ime.Japanese_hiragana property) , japanese_katakana_full (ime.Japanese_katakana_full property) , japanese_kataka...

  • Page 662

    662 actionscript classes example the following example sets the ime to japanese_hiragana if the system has an input method editor (ime) installed ( system.Capabilities.Hasime ). If(system.Capabilities.Hasime) { trace(system.Ime.Getconversionmode()); system.Ime.Setconversionmode(system.Ime.Japanese_h...

  • Page 663

    Ime (system.Ime) 663 japanese_katakana_half (ime.Japanese_katakana_half property) public static japanese_katakana_half : string a string with the value "japanese_katakana_half" for use with setconversionmode() and getconversionmode() . This constant is used with japanese imes. Availability: actionsc...

  • Page 664

    664 actionscript classes see also setconversionmode (ime.Setconversionmode method) , getconversionmode (ime.Getconversionmode method) onimecomposition (ime.Onimecomposition event listener) onimecomposition = function([readingstring:string]) {} notified when the ime composition string is being set. T...

  • Page 665

    Ime (system.Ime) 665 mc.Txt.Text = "click this text to add a listener."; mc.Onpress = function() { if(system.Capabilities.Hasime) { selection.Setfocus(mc.Txt); system.Ime.Setcompositionstring(mc.Txt.Text); } } see also addlistener (ime.Addlistener method) , setcompositionstring (ime.Setcompositionst...

  • Page 666

    666 actionscript classes mc.Txt.Border = true; mc.Txt.Background = true; mc.Txt.Autosize = "left"; mc.Txt.Text = "click this text to add and remove a listener."; mc.Onpress = function() { if(system.Capabilities.Hasime) { selection.Setfocus(mc.Txt); system.Ime.Setcompositionstring(mc.Txt.Text); } } s...

  • Page 667

    Ime (system.Ime) 667 setconversionmode (ime.Setconversionmode method) public static setconversionmode(mode:string) : boolean sets the conversion mode of the current ime. Availability: actionscript 1.0; flash player 8 parameters mode:string - the conversion mode. Possible values are the ime mode stri...

  • Page 668

    668 actionscript classes setenabled (ime.Setenabled method) public static setenabled(enabled:boolean) : boolean enables or disables the system ime. An enabled ime performs multibyte input; a disabled ime performs alphanumeric input. Availability: actionscript 1.0; flash player 8 parameters enabled:b...

  • Page 669

    Key 669 example the following example sets the ime to unknown if the system has an input method editor (ime) installed ( system.Capabilities.Hasime ). If(system.Capabilities.Hasime) { trace(system.Ime.Getconversionmode()); system.Ime.Setconversionmode(system.Ime.Unknown); trace(system.Ime.Getconvers...

  • Page 670

    670 actionscript classes property summary properties inherited from class object modifiers property description static backspace :number the key code value for the backspace key (8). Static capslock :number the key code value for the caps lock key (20). Static control :number the key code value for ...

  • Page 671

    Key 671 event summary method summary methods inherited from class object event description onkeydown = function() {} notified when a key is pressed. Onkeyup = function() {} notified when a key is released. Modifiers signature description static addlistener (listener :object) : void registers an obje...

  • Page 672

    672 actionscript classes addlistener (key.Addlistener method) public static addlistener(listener:object) : void registers an object to receive onkeydown and onkeyup notification. When a key is pressed or released, regardless of the input focus, all listening objects registered with addlistener() hav...

  • Page 673

    Key 673 key.Addlistener(mylistener); my_btn.Onpress = myonpress; my_btn._accprops.Shortcut = "ctrl+7"; accessibility.Updateproperties(); see also getcode (key.Getcode method) , isdown (key.Isdown method) , onkeydown (key.Onkeydown event listener) , onkeyup (key.Onkeyup event listener) , removelisten...

  • Page 674

    674 actionscript classes example the following example creates a new listener object and defines a function for onkeydown . The last line uses addlistener() to register the listener with the key object so that it can receive notification from the key down event. Var keylistener:object = new object()...

  • Page 675

    Key 675 deletekey (key.Deletekey property) public static deletekey : number the key code value for the delete key (46). Availability: actionscript 1.0; flash player 5 example the following example lets you draw lines with the mouse pointer using the drawing api and listener objects. Press the backsp...

  • Page 676

    676 actionscript classes down (key.Down property) public static down : number the key code value for the down arrow key (40). Availability: actionscript 1.0; flash player 5 example the following example moves a movie clip called car_mc a constant distance (10) when you press an arrow key. A sound pl...

  • Page 677

    Key 677 enter (key.Enter property) public static enter : number the key code value for the enter key (13). Availability: actionscript 1.0; flash player 5 example the following example moves a movie clip called car_mc a constant distance (10) when you press an arrow key. The car_mc instance stops whe...

  • Page 678

    678 actionscript classes escape (key.Escape property) public static escape : number the key code value for the escape key (27). Availability: actionscript 1.0; flash player 5 example the following example sets a timer. When you press escape, the output panel displays information that includes how lo...

  • Page 679

    Key 679 example the following example calls the getascii() method any time a key is pressed. The example creates a listener object named keylistener and defines a function that responds to the onkeydown event by calling key.Getascii() .The keylistener object is then registered to the key object, whi...

  • Page 680

    680 actionscript classes returns number - the key code of the last key pressed. This method returns 0 if no key was pressed or released, or if the key code is not accessible for security reasons. Example the following example calls the getcode() method any time a key is pressed. The example creates ...

  • Page 681

    Key 681 home (key.Home property) public static home : number the key code value for the home key (36). Availability: actionscript 1.0; flash player 5 example the following example attaches a draggable movie clip called car_mc at the x and y coordinates of 0,0. When you press the home key, car_mc ret...

  • Page 682

    682 actionscript classes example the following example creates a new listener object and defines a function for onkeydown . The last line uses addlistener() to register the listener with the key object so that it can receive notification from the key down event and display information in the output ...

  • Page 683

    Key 683 returns boolean - the value true if the key specified in keycode is pressed; false otherwise. Example the following script lets the user control a movie clip's ( car_mc ) location: car_mc.Onenterframe = function() { if (key.Isdown(key.Right)) { this._x += 10; } else if (key.Isdown(key.Left))...

  • Page 684

    684 actionscript classes example the following example calls the istoggled() method any time a key is pressed and executes a trace statement any time the caps lock key is toggled to an active state. The example creates a listener object named keylistener and defines a function that responds to the o...

  • Page 685

    Key 685 left (key.Left property) public static left : number the key code value for the left arrow key (37). Availability: actionscript 1.0; flash player 5 example the following example moves a movie clip called car_mc a constant distance (10) when you press an arrow key. A sound plays when you pres...

  • Page 686

    686 actionscript classes example the following example shows how to use the length property to ascertain the number of listener objects currently registered to the key object. Var mylistener:object = new object(); mylistener.Onkeydown = function () { trace ("you pressed a key."); } key.Addlistener(m...

  • Page 687

    Key 687 onkeyup (key.Onkeyup event listener) onkeyup = function() {} notified when a key is released. To use onkeyup , you must create a listener object. You can then define a function for onkeyup and use addlistener() to register the listener with the key object, as shown in the following example: ...

  • Page 688

    688 actionscript classes pgup (key.Pgup property) public static pgup : number the key code value for the page up key (33). Availability: actionscript 1.0; flash player 5 example the following example rotates a movie clip called car_mc when you press the page down or page up key. Var keylistener:obje...

  • Page 689

    Key 689 break; case key.Right : car_mc._x += 10; break; case key.Escape : key.Removelistener(keylistener); } }; key.Addlistener(keylistener); right (key.Right property) public static right : number the key code value for the right arrow key (39). Availability: actionscript 1.0; flash player 5 exampl...

  • Page 690

    690 actionscript classes shift (key.Shift property) public static shift : number the key code value for the shift key (16). Availability: actionscript 1.0; flash player 5 example the following example scales car_mc when you press shift. Var keylistener:object = new object(); keylistener.Onkeydown = ...

  • Page 691

    Key 691 break; case key.Right : car_mc._x += distance; break; case key.Down : car_mc._y += distance; break; } }; key.Addlistener(keylistener_obj); tab (key.Tab property) public static tab : number the key code value for the tab key (9). Availability: actionscript 1.0; flash player 5 example the foll...

  • Page 692

    692 actionscript classes example the following example moves a movie clip called car_mc a constant distance (10) when you press an arrow key. A sound plays when you press the spacebar. For this example, give a sound in the library a linkage identifier of horn_id . Var distance:number = 10; var horn_...

  • Page 693

    Loadvars 693 the loadvars class lets you send all the variables in an object to a specified url and to load all the variables at a specified url into an object. It also lets you send specific variables, rather than all variables, which can make your application more efficient. You can use the loadva...

  • Page 694

    694 actionscript classes constructor summary method summary methods inherited from class object signature description loadvars () creates a loadvars object. Modifiers signature description addrequestheader (hea der:object, headervalue:string) : void adds or changes http request headers (such as cont...

  • Page 695

    Loadvars 695 addrequestheader (loadvars.Addrequestheader method) public addrequestheader(header:object, headervalue:string) : void adds or changes http request headers (such as content-type or soapaction ) sent with post actions. In the first usage, you pass two strings to the method: header and hea...

  • Page 696

    696 actionscript classes see also addrequestheader (xml.Addrequestheader method) contenttype (loadvars.Contenttype property) public contenttype : string the mime type that is sent to the server when you call loadvars.Send() or loadvars.Sendandload() . The default is application/x-www-form-urlencoded...

  • Page 697

    Loadvars 697 for (var prop in my_lv) { trace(prop+" -> "+my_lv[prop]); } see also ondata (loadvars.Ondata handler) , parsexml (xml.Parsexml method) getbytesloaded (loadvars.Getbytesloaded method) public getbytesloaded() : number returns the number of bytes downloaded by loadvars.Load() or loadvars.S...

  • Page 698

    698 actionscript classes loadvars_pb.Setprogress(my_lv.Getbytesloaded(), my_lv.Getbytestotal()); delete timer_mc.Onenterframe; if (success) { trace("loadvars loaded successfully."); } else { trace("an error occurred while loading variables."); } }; my_lv.Load("[place a valid url pointing to a text f...

  • Page 699

    Loadvars 699 if (lvbytestotal != undefined) { trace("loaded "+lvbytesloaded+" of "+lvbytestotal+" bytes."); loadvars_pb.Setprogress(lvbytesloaded, lvbytestotal); } }; my_lv.Onload = function(success:boolean) { loadvars_pb.Setprogress(my_lv.Getbytesloaded(), my_lv.Getbytestotal()); delete timer_mc.On...

  • Page 700

    700 actionscript classes for more information, see the following: ■ chapter 17, "understanding security," in learning actionscript 2.0 in flash ■ the flash player 8 security white paper at http://www.Macromedia.Com/go/fp8_security ■ the flash player 8 security-related api white paper at http://www.M...

  • Page 701

    Loadvars 701 for another example, see the guestbook.Fla file in the actionscript samples folder. Here are some typical paths to this folder: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applications/macromedia flash 8/sam...

  • Page 702

    702 actionscript classes loadvars constructor public loadvars() creates a loadvars object. You can then use the methods of that loadvars object to send and load data. Availability: actionscript 1.0; flash player 6 example the following example creates a loadvars object called my_lv : var my_lv:loadv...

  • Page 703

    Loadvars 703 return; } content_ta.Text = src; }; my_lv.Load("content.Txt", my_lv, "get"); see also onload (loadvars.Onload handler) , onload (loadvars.Onload handler) , load (loadvars.Load method) , sendandload (loadvars.Sendandload method) onhttpstatus (loadvars.Onhttpstatus handler) onhttpstatus =...

  • Page 704

    704 actionscript classes example the following example shows how to use onhttpstatus() to help with debugging. The example collects http status codes and assigns their value and type to an instance of the loadvars object. (notice that this example creates the instance members this.Httpstatus and thi...

  • Page 705

    Loadvars 705 see also onhttpstatus (xml.Onhttpstatus handler) , load (loadvars.Load method) , sendandload (loadvars.Sendandload method) onload (loadvars.Onload handler) onload = function(success:boolean) {} invoked when a loadvars.Load() or loadvars.Sendandload() operation has ended. If the operatio...

  • Page 706

    706 actionscript classes to view a more robust example, see the login.Fla file in the actionscript samples folder. Here are some typical paths to this folder: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applications/macr...

  • Page 707

    Loadvars 707 when using this method, consider the flash player security model: ■ for flash player 8, the method is not allowed if the calling swf file is in an untrusted local sandbox. ■ for flash player 7 and later, the method is not allowed if the calling swf file is a local file. For more informa...

  • Page 708

    708 actionscript classes see also sendandload (loadvars.Sendandload method) , send (xml.Send method) sendandload (loadvars.Sendandload method) public sendandload(url:string, target:object, [method:string]) : boolean posts variables in the my_lv object to the specified url. The server response is dow...

  • Page 709

    Loadvars 709 parameters url:string - a string; the url to which to upload variables. If the swf file issuing this call is running in a web browser, url must be in the same domain as the swf file. Target:object - the loadvars or xml object that receives the downloaded variables. Method:string [option...

  • Page 710

    710 actionscript classes see also send (loadvars.Send method) , load (loadvars.Load method) , sendandload (xml.Sendandload method) tostring (loadvars.Tostring method) public tostring() : string returns a string containing all enumerable variables in my_lv , in the mime content encoding application/x...

  • Page 711

    Localconnection 711 the primary methods used to send and receive data are localconnection.Send() and localconnection.Connect() . At its most basic, your code will implement the following commands; notice that both the localconnection.Send() and localconnection.Connect() commands specify the same con...

  • Page 712

    712 actionscript classes event summary constructor summary event description allowdomain = function([sendin gdomain:string]) {} invoked whenever receiving_lc receives a request to invoke a method from a sending localconnection object. Allowinsecuredom ain = function([sendin gdomain:string]) {} invok...

  • Page 713

    Localconnection 713 method summary methods inherited from class object allowdomain (localconnection.Allowdomain handler) allowdomain = function([sendingdomain:string]) {} invoked whenever receiving_lc receives a request to invoke a method from a sending localconnection object. Flash expects the code...

  • Page 714

    714 actionscript classes use localconnection.Allowdomain to explicitly permit localconnection objects from specified domains, or from any domain, to execute methods of the receiving localconnection object. If you don't declare the sendingdomain parameter, you probably want to accept commands from an...

  • Page 715

    Localconnection 715 the opposite situation can also occur: you might create a child swf file that wants to accept localconnection calls from its parent but doesn't know the domain of its parent. In this situation, implement this method by checking whether the domain argument matches the domain of _p...

  • Page 716

    716 actionscript classes case 'status' : status_ta.Text = "localconnection connected successfully."; break; case 'error' : status_ta.Text = "localconnection encountered an error."; break; } }; sending_lc.Send("_mylc", "sayhello", name_ti.Text); }; send_button.Addeventlistener("click", sendlistener);...

  • Page 717

    Localconnection 717 allowinsecuredomain (localconnection.Allowinsecuredomain handler) allowinsecuredomain = function([sendingdomain:string]) {} invoked whenever receiving_lc, which is in a swf file hosted at a domain using a secure protocol (https), receives a request to invoke a method from a sendi...

  • Page 718

    718 actionscript classes my_lc.Sayhello = function(name:string) { welcome_txt.Text = "hello, "+name; }; my_lc.Connect("lc_name"); if your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method used in this exampl...

  • Page 719

    Localconnection 719 the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also connect (localconnect...

  • Page 720

    720 actionscript classes if you are implementing communication between swf files in different domains, specifying a string for connectionname that begins with an underscore (_) will make the swf with the receiving localconnection object more portable between domains. Here are the two possible cases:...

  • Page 721

    Localconnection 721 example the following example shows how a swf file in a particular domain can invoke a method named printout in a receiving swf file in the same domain. First, create one swf file with the following code: this.Createtextfield("tf", this.Getnexthighestdepth(), 10, 10, 300, 100); v...

  • Page 722

    722 actionscript classes swf 2 contains a button called play_btn . When you click the button, it connects to swf 1 and passes two variables. The first variable contains the mp3 file to stream, and the second variable is the filename that you display in the label component instance in swf 1. Play_btn...

  • Page 723

    Localconnection 723 the most common way to use this command is to include the domain name of the sending localconnection object as a parameter to the method you plan to invoke in the receiving localconnection object or with localconnection.Allowdomain to accept commands from a specified domain. If y...

  • Page 724

    724 actionscript classes line numbers are included for reference purposes. The sequence of events is described in the following list: ■ the receiving swf file prepares to receive commands on a connection named "sum" (line 11). The flash player resolves the name of this connection to "mydomain.Com:su...

  • Page 725

    Localconnection 725 // determine our domain and see if we need to truncate it 57 var channeldomain:string = lc.Domain(); 58 if (getversion() >= 7 && this.Getswfversion() >= 7) 59 { // split domain name into elements 60 var domainarray:array = channeldomain.Split("."); // if more than two elements ar...

  • Page 726

    726 actionscript classes // code in the sending swf file var sending_lc:localconnection = new localconnection(); sending_lc.Send("lc_name", "methodtoexecute", 5, 7); see also connect (localconnection.Connect method) , send (localconnection.Send method) onstatus (localconnection.Onstatus handler) ons...

  • Page 727

    Localconnection 727 example the following example displays a status message about whether the swf file connects to another local connection object called lc_name . A textinput component called name_ti , a textarea instance called status_ta and a button instance called send_button are used to display...

  • Page 728

    728 actionscript classes as discussed in the entry localconnection.Connect() , flash adds the current superdomain to connectionname by default. If you are implementing communication between different domains, you need to define connectionname in both the sending and receiving localconnection objects...

  • Page 729

    Locale (mx.Lang.Locale) 729 returns boolean - a boolean value: true if flash can carry out the request; false otherwise. Example for an example of communicating between localconnection objects located in the same domain, see localconnection.Connect() . For an example of communicating between localco...

  • Page 730

    730 actionscript classes ■ "via actionscript at runtime" —string id replacement is controlled using actionscript at runtime. This option gives you control over both the timing and language of string id replacement. You can use the properties and methods of this class when you want to replace the str...

  • Page 731

    Locale (mx.Lang.Locale) 731 method summary modifiers signature description static adddelayedinstance (i nstance:object, stringid:string) : void adds the {instance, string id} pair into the internal array for later use. Static addxmlpath (langcode: string, path:string) : void adds the {languagecode a...

  • Page 732

    732 actionscript classes methods inherited from class object adddelayedinstance (locale.Adddelayedinstance method) public static adddelayedinstance(instance:object, stringid:string) : void adds the {instance, string id} pair into the internal array for later use. This is primarily used by flash when...

  • Page 733

    Locale (mx.Lang.Locale) 733 parameters langcode:string - the language code. Path:string - the xml path to add. Example the following example uses the setinterval() method to check whether the language xml file has successfully loaded. Import mx.Lang.Locale; locale.Setloadcallback(localecallback); lo...

  • Page 734

    734 actionscript classes example the following example uses the locale.Autoreplace property to populate the dynamically created greeting_txt text field on the stage with the contents of the ids_greeting string in the english xml file. In the strings panel, click the settings button to open the setti...

  • Page 735

    Locale (mx.Lang.Locale) 735 getdefaultlang (locale.Getdefaultlang method) public static getdefaultlang() : string the default language code as set in the strings panel dialog box or by calling the setdefaultlang() method. Availability: actionscript 2.0; flash player 8 returns string - returns the de...

  • Page 736

    736 actionscript classes example this example shows how to use the initialize() method to automatically populate the greeting_txt text field on the stage with the user's current os language. Instead of using the initialize() method directly, use the string replacement method of "automatically at run...

  • Page 737

    Locale (mx.Lang.Locale) 737 example the following example loads a language xml file based on the current value of a combobox component. You drag a combobox component onto the stage and give it an instance name of lang_cb . Using the text tool, you create a dynamic text field and give it an instance ...

  • Page 738

    738 actionscript classes example the following example uses the loadlanguagexml() method to load the english (en) xml language file. Once the language file loads, the localecallback() method is called and populates the greeting_txt text field on the stage with the contents of the ids_greeting string...

  • Page 739

    Locale (mx.Lang.Locale) 739 function checklocalestatus():void { if (locale.Checkxmlstatus()) { clearinterval(locale_int); trace("clearing interval @ " + gettimer() + " ms"); } } // callback function for locale.Setloadcallback() function localecallback(success:boolean):void { greeting_txt.Text = loca...

  • Page 740

    740 actionscript classes see also loadstring (locale.Loadstring method) setdefaultlang (locale.Setdefaultlang method) public static setdefaultlang(langcode:string) : void sets the default language code. Availability: actionscript 2.0; flash player 7 parameters langcode:string - a string representing...

  • Page 741

    Locale (mx.Lang.Locale) 741 parameters loadcallback:function - the function to call when the xml language file loads. Example the following example uses an interval to check every 10 milliseconds to see if the language file has successfully loaded. Once the xml file has loaded, the greeting_txt text...

  • Page 742

    742 actionscript classes stringidarray (locale.Stringidarray property) public static stringidarray : array [read-only] an array containing all the string ids in the fla file. The string ids are not sorted alphabetically. Availability: actionscript 2.0; flash player 8 example the following example tr...

  • Page 743

    Math 743 to calculate a radian value, use the following formula: radians = degrees * math.Pi/180 the following is an example of passing the equation as a parameter to calculate the sine of a 45° angle: math.Sin(45 * math.Pi/180) is the same as math.Sin(.7854) availability: actionscript 1.0; flash pl...

  • Page 744

    744 actionscript classes properties inherited from class object method summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) modifiers signature description static abs (x:number) : num...

  • Page 745

    Math 745 methods inherited from class object abs (math.Abs method) public static abs(x:number) : number computes and returns an absolute value for the number specified by the parameter x . Availability: actionscript 1.0; flash player 5 - in flash player 4, the methods and properties of the math clas...

  • Page 746

    746 actionscript classes trace(num); // output: -12 trace(numabsolute); // output: 12 acos (math.Acos method) public static acos(x:number) : number computes and returns the arc cosine of the number specified in the parameter x , in radians. Availability: actionscript 1.0; flash player 5 - in flash p...

  • Page 747

    Math 747 returns number - a number between negative pi divided by 2 and positive pi divided by 2. Example the following example displays the arc sine for several values. Trace(math.Asin(-1)); // output: -1.5707963267949 trace(math.Asin(0)); // output: 0 trace(math.Asin(1)); // output: 1.570796326794...

  • Page 748

    748 actionscript classes atan2 (math.Atan2 method) public static atan2(y:number, x:number) : number computes and returns the angle of the point y / x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positiv...

  • Page 749

    Math 749 returns number - an integer that is both closest to, and greater than or equal to, parameter x . Example the following code returns a value of 13: math.Ceil(12.5); see also floor (math.Floor method) , round (math.Round method) cos (math.Cos method) public static cos(x:number) : number compu...

  • Page 750

    750 actionscript classes see also acos (math.Acos method) , asin (math.Asin method) , atan (math.Atan method) , atan2 (math.Atan2 method) , sin (math.Sin method) , tan (math.Tan method) e (math.E property) public static e : number a mathematical constant for the base of natural logarithms, expressed...

  • Page 751

    Math 751 parameters x:number - the exponent; a number or expression. Returns number - a number. Example the following example displays the logarithm for two number values. Trace(math.Exp(1)); // output: 2.71828182845905 trace(math.Exp(2)); // output: 7.38905609893065 see also e (math.E property) flo...

  • Page 752

    752 actionscript classes ln10 (math.Ln10 property) public static ln10 : number a mathematical constant for the natural logarithm of 10, expressed as loge10, with an approximate value of 2.302585092994046. Availability: actionscript 1.0; flash player 5 - in flash player 4, the methods and properties ...

  • Page 753

    Math 753 example the following example displays the logarithm for three numerical values. Trace(math.Log(0)); // output: -infinity trace(math.Log(1)); // output: 0 trace(math.Log(2)); // output: 0.693147180559945 trace(math.Log(math.E)); // output: 1 log10e (math.Log10e property) public static log10...

  • Page 754

    754 actionscript classes max (math.Max method) public static max(x:number, y:number) : number evaluates x and y and returns the larger value. Availability: actionscript 1.0; flash player 5 - in flash player 4, the methods and properties of the math class are emulated using approximations and might n...

  • Page 755

    Math 755 returns number - a number. Example the following example displays sat dec 25 00:00:00 gmt-0700 2004 , which is the smaller of the evaluated expressions. Var date1:date = new date(2004, 11, 25); var date2:date = new date(2004, 11, 30); var mindate:number = math.Min(date1.Gettime(), date2.Get...

  • Page 756

    756 actionscript classes mc.Curveto(r+x, -math.Tan(math.Pi/8)*r+y, r+x, y); } pow (math.Pow method) public static pow(x:number, y:number) : number computes and returns x to the power of y . Availability: actionscript 1.0; flash player 5 - in flash player 4, the methods and properties of the math cla...

  • Page 757

    Math 757 the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. Random (math.Random method) public static...

  • Page 758

    758 actionscript classes returns number - a number; an integer. Example the following example returns a random number between two specified integers. Function randrange(min:number, max:number):number { var randomnum:number = math.Round(math.Random() * (max-min+1) + (min- .5)); return randomnum; } fo...

  • Page 759

    Math 759 mc.Curveto(r+x, math.Tan(math.Pi/8)*r+y, math.Sin(math.Pi/4)*r+x, math.Sin(math.Pi/4)*r+y); mc.Curveto(math.Tan(math.Pi/8)*r+x, r+y, x, r+y); mc.Curveto(-math.Tan(math.Pi/8)*r+x, r+y, -math.Sin(math.Pi/4)*r+x, math.Sin(math.Pi/4)*r+y); mc.Curveto(-r+x, math.Tan(math.Pi/8)*r+y, -r+x, y); mc....

  • Page 760

    760 actionscript classes this.Newy = _ymouse; var miny = math.Min(this.Origy, this.Newy); var nextdepth:number = canvas_mc.Getnexthighestdepth(); var line_mc:movieclip = canvas_mc.Createemptymovieclip("line"+nextdepth+"_mc", nextdepth); line_mc.Moveto(this.Origx, this.Origy); line_mc.Linestyle(2, 0x...

  • Page 761

    Math 761 tan (math.Tan method) public static tan(x:number) : number computes and returns the tangent of the specified angle. To calculate a radian, use the information outlined in the introduction to the math class. Availability: actionscript 1.0; flash player 5 - in flash player 4, the methods and ...

  • Page 763

    Matrix (flash.Geom.Matrix) 763 the matrix class supports the four major types of transformation functions: translation, scaling, rotation, and skewing. There are specialized methods for three of these functions, as described in the following table. Each transformation function alters the current mat...

  • Page 764

    764 actionscript classes availability: actionscript 1.0; flash player 8 see also transform (movieclip.Transform property) , transform (flash.Geom.Transform) , draw (bitmapdata.Draw method) , a (matrix.A property) , b (matrix.B property) , c (matrix.C property) , d (matrix.D property) , tx (matrix.Tx...

  • Page 765

    Matrix (flash.Geom.Matrix) 765 constructor summary method summary signature description matrix ([a:number], [b:number], [c:number], [d:number], [tx:number], [ty:number]) creates a new matrix object with the specified parameters. Modifiers signature description clone () : matrix returns a new matrix ...

  • Page 766

    766 actionscript classes methods inherited from class object a (matrix.A property) public a : number the value in the first row and first column of the matrix object, which affects the positioning of pixels along the x axis when scaling or rotating an image. Availability: actionscript 1.0; flash pla...

  • Page 767

    Matrix (flash.Geom.Matrix) 767 availability: actionscript 1.0; flash player 8 example the following example creates the matrix object mymatrix and sets its b value. Import flash.Geom.Matrix; var mymatrix:matrix = new matrix(); trace(mymatrix.B); // 0 var degrees:number = 45; var radians:number = (de...

  • Page 768

    768 actionscript classes example the following example creates the clonedmatrix variable from the mymatrix variable. The matrix class does not have an equals method, so the following example uses a custom written function to test the equality of two matrixes. Import flash.Geom.Matrix; var mymatrix:m...

  • Page 769

    Matrix (flash.Geom.Matrix) 769 example the following example creates three matrixes that define transformations for three rectangle movie clips. The first two matrixes rotate45matrix and doublescalematrix are applied to the two rectangles rectanglemc_1 and rectanglemc_2 . Then the third matrix is cr...

  • Page 770

    770 actionscript classes function createrectangle(width:number, height:number, color:number):movieclip { var depth:number = this.Getnexthighestdepth(); var mc:movieclip = this.Createemptymovieclip("mc_" + depth, depth); mc.Beginfill(color); mc.Lineto(0, height); mc.Lineto(width, height); mc.Lineto(w...

  • Page 771

    Matrix (flash.Geom.Matrix) 771 example the following example sets the scalex , scaley scale, rotation, x location, and y location of mymatrix by calling its createbox() method. Import flash.Geom.Matrix; import flash.Geom.Transform; var mymatrix:matrix = new matrix(); trace(mymatrix.Tostring()); // (...

  • Page 772

    772 actionscript classes example the following example uses mymatrix as a parameter for the movieclip object's begingradientfill() method. Import flash.Geom.Matrix; var mymatrix:matrix = new matrix(); trace(mymatrix.Tostring()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) mymatrix.Creategradientbox(200, 200...

  • Page 773

    Matrix (flash.Geom.Matrix) 773 deltatransformpoint (matrix.Deltatransformpoint method) public deltatransformpoint(pt:point) : point given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. Unlike the standard transformation applied us...

  • Page 774

    774 actionscript classes var pointmc_1:movieclip = createrectangle(10, 10, 0x00ff00); pointmc_1._x = deltatransformedpoint.X; function createrectangle(width:number, height:number, color:number):movieclip { var depth:number = this.Getnexthighestdepth(); var mc:movieclip = this.Createemptymovieclip("m...

  • Page 775

    Matrix (flash.Geom.Matrix) 775 mymatrix.Translate(100,200); trace(mymatrix.Tostring()); // (a=1.6, b=1.2, c=-1.2, d=1.6, tx=100, ty=200) mymatrix.Scale(2, 2); trace(mymatrix.Tostring()); // (a=3.2, b=2.4, c=-2.4, d=3.2, tx=200, ty=400) mymatrix.Identity(); trace(mymatrix.Tostring()); // (a=1, b=0, c...

  • Page 776

    776 actionscript classes halfscalematrix.Invert(); rectangletrans_2.Matrix = halfscalematrix; rectanglemc_2._x = 200; trace(halfscalematrix.Tostring()); // (a=0.5, b=0, c=0, d=0.5, tx=0, ty=0) var originalandinversematrix:matrix = doublescalematrix.Clone(); originalandinversematrix.Concat(halfscalem...

  • Page 777

    Matrix (flash.Geom.Matrix) 777 in matrix notation the identity matrix looks like this: availability: actionscript 1.0; flash player 8 parameters a:number [optional] - the value in the first row and first column of the new matrix object. B:number [optional] - the value in the first row and second col...

  • Page 778

    778 actionscript classes the rotate() method alters the a and d properties of the matrix object. In matrix notation this is shown as follows: availability: actionscript 1.0; flash player 8 parameters angle:number - the rotation angle in radians. Example the following example shows how the rotate() m...

  • Page 779

    Matrix (flash.Geom.Matrix) 779 mc.Lineto(width, height); mc.Lineto(width, 0); mc.Lineto(0, 0); return mc; } the previous example uses the _x property of the movieclip object to position rectanglemc . Generally, when dealing with matrix object positioning, mixing positioning techniques is considered ...

  • Page 780

    780 actionscript classes scale (matrix.Scale method) public scale(sx:number, sy:number) : void modifies a matrix so that its effect, when applied, is to resize an image. In the resized image, the location of each pixel on the x axis is multiplied by sx ; and on the y axis it is multiplied by sy . Th...

  • Page 781

    Matrix (flash.Geom.Matrix) 781 example the following example creates mymatrix and converts its values to a string in the format of (a=a, b=b, c=c, d=d, tx=tx, ty=ty). Import flash.Geom.Matrix; var mymatrix:matrix = new matrix(); trace("mymatrix: " + mymatrix.Tostring()); // (a=1, b=0, c=0, d=1, tx=0...

  • Page 782

    782 actionscript classes var transformedpoint:point = mymatrix.Transformpoint(mypoint); trace(transformedpoint); // (450, 0) var pointmc_0:movieclip = createrectangle(10, 10, 0xff0000); pointmc_0._x = mypoint.X; var pointmc_1:movieclip = createrectangle(10, 10, 0x00ff00); pointmc_1._x = transformedp...

  • Page 783

    Matrix (flash.Geom.Matrix) 783 example the following example uses the translate() method to position rectanglemc x:100 and y:50. The translate() method affects the translation properties tx and ty , but it doesn't affect the a , b , c , or d properties. Import flash.Geom.Matrix; var mymatrix:matrix ...

  • Page 785

    Microphone 785 properties inherited from class object event summary name :string [read- only] a string that specifies the name of the current sound capture device, as returned by the sound capture hardware. Static names :array [read- only] retrieves an array of strings reflecting the names of all av...

  • Page 786

    786 actionscript classes method summary methods inherited from class object activitylevel (microphone.Activitylevel property) public activitylevel : number [read-only] a numeric value that specifies the amount of sound the microphone is detecting. Values range from 0 (no sound is being detected) to ...

  • Page 787

    Microphone 787 example the following example displays the activity level of the current microphone in a progressbar instance called activitylevel_pb . Var activitylevel_pb:mx.Controls.Progressbar; activitylevel_pb.Mode = "manual"; activitylevel_pb.Label = "activity level: %3%%"; activitylevel_pb.Set...

  • Page 788

    788 actionscript classes gain_pb.Label = "gain: %3"; gain_pb.Mode = "manual"; gain_pb.Setprogress(active_mic.Gain, 100); gain_nstep.Value = active_mic.Gain; function changegain() { active_mic.Setgain(gain_nstep.Value); gain_pb.Setprogress(active_mic.Gain, 100); } gain_nstep.Addeventlistener("change"...

  • Page 789

    Microphone 789 when the user responds to this dialog box, the microphone.Onstatus event handler returns an information object that indicates the user's response. To determine whether the user has denied or allowed access to the camera without processing this event handler, use microphone.Muted . The...

  • Page 790

    790 actionscript classes var active_mic:microphone = microphone.Get(); sound_mc.Attachaudio(active_mic); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class ...

  • Page 791

    Microphone 791 the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also get (microphone.Get method...

  • Page 792

    792 actionscript classes status_ta.Text += "you have "+microphone_array.Length+" device(s) installed."+newline+newline; for (var i = 0; i status_ta.Text += "["+i+"] "+microphone_array[i]+newline; } see also get (microphone.Get method) , names (microphone.Names property) names (microphone.Names prope...

  • Page 793

    Microphone 793 you have 2 device(s) installed. [0] logitech usb headset [1] yamaha ac-xg wdm audio see also name (microphone.Name property) , get (microphone.Get method) onactivity (microphone.Onactivity handler) onactivity = function(active:boolean) {} invoked when the microphone starts or stops de...

  • Page 794

    794 actionscript classes the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also setsilencelevel ...

  • Page 795

    Microphone 795 this.Createtextfield("muted_txt", this.Getnexthighestdepth(), 10, 10, 100, 22); muted_txt.Autosize = true; muted_txt.Html = true; muted_txt.Selectable = false; muted_txt.Htmltext = "click here to allow/deny access."; this.Createemptymovieclip("sound_mc", this.Getnexthighestdepth()); v...

  • Page 796

    796 actionscript classes example the following code lets you use a combobox instance, called rate_cb , to change the rate at which your microphone captures sound. The current rate displays in a label instance called rate_lbl . This.Createemptymovieclip("sound_mc", this.Getnexthighestdepth()); var ac...

  • Page 797

    Microphone 797 parameters gain:number - an integer that specifies the amount by which the microphone should boost the signal. Valid values are 0 to 100. The default value is 50; however, the user may change this value in the flash player microphone settings panel. Example the following example uses ...

  • Page 798

    798 actionscript classes example the following example sets the microphone rate to the user's preference (which you have assigned to the userrate variable) if it is one of the following values: 5, 8, 11, 22, or 44. If it is not, the value is rounded to the nearest acceptable value that the sound cap...

  • Page 799

    Microphone 799 ■ to prevent the microphone from detecting sound at all, pass a value of 100 for level ; microphone.Onactivity is never invoked. ■ to determine the amount of sound the microphone is currently detecting, use microphone.Activitylevel . Activity detection is the ability to detect when au...

  • Page 800

    800 actionscript classes var silencelevel_nstep:mx.Controls.Numericstepper; this.Createemptymovieclip("sound_mc", this.Getnexthighestdepth()); var active_mic:microphone = microphone.Get(); sound_mc.Attachaudio(active_mic); silencelevel_pb.Label = "activity level: %3"; silencelevel_pb.Mode = "manual"...

  • Page 801

    Microphone 801 setuseechosuppression (microphone.Setuseechosuppression method) public setuseechosuppression(useechosuppression:boolean) : void specifies whether to use the echo suppression feature of the audio codec. The default value is false unless the user has selected reduce echo in the flash pl...

  • Page 802

    802 actionscript classes active_mic.Setuseechosuppression(evt.Target.Selected); }; useechosuppression_ch.Addeventlistener("click", chlistener); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the v...

  • Page 803

    Microphone 803 silencelevel_pb.Setprogress(active_mic.Activitylevel, 100); }; active_mic.Onactivity = function(active:boolean) { if (active) { silencelevel_pb.Indeterminate = false; silencelevel_pb.Setstyle("themecolor", "halogreen"); silencelevel_pb.Label = "activity level: %3"; } else { silencelev...

  • Page 804

    804 actionscript classes this.Createemptymovieclip("sound_mc", this.Getnexthighestdepth()); var active_mic:microphone = microphone.Get(); sound_mc.Attachaudio(active_mic); silencelevel_pb.Label = "activity level: %3"; silencelevel_pb.Mode = "manual"; silencetimeout_nstep.Minimum = 0; silencetimeout_...

  • Page 805

    Mouse 805 availability: actionscript 1.0; flash player 6 example the following example turns on echo suppression if the user selects a checkbox instance called useechosuppression_ch . The progressbar instance called activitylevel_pb displays the current activity level of the audio stream. Var useech...

  • Page 806

    806 actionscript classes a flash application can only monitor mouse events that occur within its focus. A flash application cannot detect mouse events in another application. Availability: actionscript 1.0; flash player 5 property summary properties inherited from class object event summary method s...

  • Page 807

    Mouse 807 methods inherited from class object addlistener (mouse.Addlistener method) public static addlistener(listener:object) : void registers an object to receive notifications of the onmousedown , onmousemove , onmouseup , and onmousewheel listeners. (the onmousewheel listener is supported only ...

  • Page 808

    808 actionscript classes _global.Shots++; } }; mouse.Addlistener(mouselistener); to view the entire script, see the animation.Fla file in the actionscript samples folder. The following list shows typical paths to the actionscript samples folder: ■ windows: boot drive\program files\macromedia\flash 8...

  • Page 809

    Mouse 809 updateafterevent(); }; mouse.Addlistener(mouselistener); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighes...

  • Page 810

    810 actionscript classes this.Target_mc.Clear(); this.Target_mc.Linestyle(1, 0xff0000, 100); this.Target_mc.Moveto(this.Orig_x, this.Orig_y); this.Target_mc.Lineto(_xmouse, this.Orig_y); this.Target_mc.Lineto(_xmouse, _ymouse); this.Target_mc.Lineto(this.Orig_x, _ymouse); this.Target_mc.Lineto(this....

  • Page 811

    Mouse 811 var mouselistener:object = new object(); mouselistener.Onmousedown = function() { this.Isdrawing = true; canvas_mc.Linestyle(2, 0xff0000, 100); canvas_mc.Moveto(_xmouse, _ymouse); }; mouselistener.Onmousemove = function() { if (this.Isdrawing) { canvas_mc.Lineto(_xmouse, _ymouse); } update...

  • Page 812

    812 actionscript classes onmouseup (mouse.Onmouseup event listener) onmouseup = function() {} notified when the mouse is released. To use the onmouseup listener, you must create a listener object. You can then define a function for onmouseup and use addlistener() to register the listener with the mo...

  • Page 813

    Mouse 813 onmousewheel (mouse.Onmousewheel event listener) onmousewheel = function([delta:number], [scrolltarget:string]) {} notified when the user rolls the mouse wheel. To use the onmousewheel listener, you must create a listener object. You can then define a function for onmousewheel and use addl...

  • Page 814

    814 actionscript classes mouselistener.Onmousewheel = function(delta:number) { line_mc._rotation += delta; }; mouselistener.Onmousedown = function() { trace("down"); }; mouse.Addlistener(mouselistener); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later....

  • Page 815

    Mouse 815 startdrawing_button.Enabled = false; // this.Createemptymovieclip("canvas_mc", this.Getnexthighestdepth()); var mouselistener:object = new object(); mouselistener.Onmousedown = function() { this.Isdrawing = true; canvas_mc.Linestyle(2, 0xff0000, 100); canvas_mc.Moveto(_xmouse, _ymouse); };...

  • Page 816

    816 actionscript classes show (mouse.Show method) public static show() : number displays the mouse pointer in a swf file. The pointer is visible by default. Availability: actionscript 1.0; flash player 5 returns number - an integer; either 0 or 1 . If the mouse pointer was hidden before the call to ...

  • Page 818

    818 actionscript classes enabled :boolean a boolean value that indicates whether a movie clip is enabled. Filters :array an indexed array containing each filter object currently associated with the movie clip. Focusenabled :boolean if the value is undefined or false, a movie clip cannot receive inpu...

  • Page 819

    Movieclip 819 scrollrect :object the scrollrect property allows you to quickly scroll movie clip content and have a window viewing larger content. _soundbuftime :number specifies the number of seconds a sound prebuffers before it starts to stream. Tabchildren :boolean determines whether the children...

  • Page 820

    820 actionscript classes properties inherited from class object event summary _y :number sets the y coordinate of a movie clip relative to the local coordinates of the parent movie clip. _ymouse :number [read- only] indicates the y coordinate of the mouse position. _yscale :number sets the vertical ...

  • Page 821

    Movieclip 821 method summary onmouseup = function() {} invoked when the mouse button is released. Onpress = function() {} invoked when the user clicks the mouse while the pointer is over a movie clip. Onrelease = function() {} invoked when a user releases the mouse button over a movie clip. Onreleas...

  • Page 822

    822 actionscript classes beginbitmapfill (bmp: bitmapdata, [matrix:matrix], [repeat:boolean], [smoothing:boolean]) : void fills a drawing area with a bitmap image. Beginfill (rgb:number , [alpha:number]) : void indicates the beginning of a new drawing path. Begingradientfill (fi lltype:string, color...

  • Page 823

    Movieclip 823 duplicatemovieclip (n ame:string, depth:number, [initobject:object]) : movieclip creates an instance of the specified movie clip while the swf file is playing. Endfill () : void applies a fill to the lines and curves that were since the last call to beginfill() or begingradientfill(). ...

  • Page 824

    824 actionscript classes globaltolocal (pt:obj ect) : void converts the pt object from stage (global) coordinates to the movie clip's (local) coordinates. Gotoandplay (frame:ob ject) : void starts playing the swf file at the specified frame. Gotoandstop (frame:ob ject) : void brings the playhead to ...

  • Page 825

    Movieclip 825 localtoglobal (pt:obj ect) : void converts the pt object from the movie clip's (local) coordinates to the stage (global) coordinates. Moveto (x:number, y:number) : void moves the current drawing position to (x, y). Nextframe () : void sends the playhead to the next frame and stops it. ...

  • Page 826

    826 actionscript classes methods inherited from class object _alpha (movieclip._alpha property) public _alpha : number the alpha transparency value of the movie clip. Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a movie clip with _alpha set to 0 ...

  • Page 827

    Movieclip 827 see also _alpha (button._alpha property) , _alpha (textfield._alpha property) , _visible (movieclip._visible property) attachaudio (movieclip.Attachaudio method) public attachaudio(id:object) : void specifies the audio source to be played. To stop playing the audio source, pass the val...

  • Page 828

    828 actionscript classes audio_sound.Setvolume(audio_sound.Getvolume()-10); updatevolume(); } }; // updates the volume. This.Createtextfield("volume_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); updatevolume(); function updatevolume() { volume_txt.Text = "volume: "+audio_sound.Getvolume(); } the...

  • Page 829

    Movieclip 829 pixel snapping forces the position of the bitmap to the nearest whole pixel value instead of positioning to be on a partial pixel. There are three pixel snapping modes: ■ auto mode does pixel snapping as long as the bitmap is not stretched or rotated. ■ always mode always does pixel sn...

  • Page 830

    830 actionscript classes parameters id:string - the linkage name of the movie clip symbol in the library to attach to a movie clip on the stage. This is the name that you enter in the identifier field in the linkage properties dialog box. Name:string - a unique instance name for the movie clip being...

  • Page 831

    Movieclip 831 matrix:flash.Geom.Matrix [optional] - a matrix object (of the flash.Geom.Matrix class), which you can use to define transformations on the bitmap. For instance, you can use the following matrix to rotate a bitmap by 45 degrees (pi/4 radians): var matrix = new flash.Geom.Matrix(); matri...

  • Page 832

    832 actionscript classes this.Createemptymovieclip("bmp_fill_mc", this.Getnexthighestdepth()); with (bmp_fill_mc) { matrix = new matrix(); matrix.Rotate(math.Pi/8); repeat = true; smoothing = true; beginbitmapfill(bmpd, matrix, repeat, smoothing); moveto(0, 0); lineto(0, 60); lineto(60, 60); lineto(...

  • Page 833

    Movieclip 833 example the following example creates a square with red fill on the stage: this.Createemptymovieclip("square_mc", this.Getnexthighestdepth()); square_mc.Beginfill(0xff0000); square_mc.Moveto(10, 10); square_mc.Lineto(100, 10); square_mc.Lineto(100, 100); square_mc.Lineto(10, 100); squa...

  • Page 834

    834 actionscript classes availability: actionscript 1.0; flash player 6 - additional parameters spreadmethod, interpolationmethod, and focalpointratio added in flash player 8. Parameters filltype:string - valid values are the string " linear " and the string " radial ". Colors:array - an array of rg...

  • Page 835

    Movieclip 835 with (gradient_mc) { colors = [0xff0000, 0x0000ff]; filltype = "radial" alphas = [100, 100]; ratios = [0, 0xff]; spreadmethod = "reflect"; interpolationmethod = "linearrgb"; focalpointratio = 0.9; matrix = new matrix(); matrix.Creategradientbox(100, 100, math.Pi, 0, 0); begingradientfi...

  • Page 836

    836 actionscript classes colors = [0xff0000, 0x0000ff]; filltype = "radial" alphas = [100, 100]; ratios = [0, 0xff]; spreadmethod = "reflect"; interpolationmethod = "linearrgb"; focalpointratio = 0.9; matrix = {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1}; begingradientfill(filltype, colors,...

  • Page 837

    Movieclip 837 { colors = [0xff0000, 0x0000ff]; filltype = "radial" alphas = [100, 100]; ratios = [0, 0xff]; spreadmethod = "reflect"; interpolationmethod = "linearrgb"; focalpointratio = 0.9; matrix = {matrixtype:"box", x:100, y:100, w:200, h:200, r:(45/ 180)*math.Pi}; begingradientfill(filltype, co...

  • Page 838

    838 actionscript classes this.Lineto(0, 0); this.Endfill(); this example uses "pad" for the spread method, so the gradient fill looks like the following: if you used "reflect" for the spread method, the gradient fill would look like the following: if you used "repeat" for the spread method, the grad...

  • Page 839

    Movieclip 839 focalpointratio:number [optional] - added in flash player 8. A number that controls the location of the focal point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means the foc...

  • Page 840

    840 actionscript classes this draws the following image (the image is scaled by 50%): if your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method, which is used in this example. See also creategradientbox (mat...

  • Page 841

    Movieclip 841 the following table describes the blendmode settings. To set the blendmode property, you can use either an integer from 1 to 14 or a string. The illustrations in the table show blendmode values applied to a circular movie clip (2) superimposed on another onscreen object (1). Integer va...

  • Page 842

    842 actionscript classes 4 "screen" multiplies the complement (inverse) of the movie clip color by the complement of the background color, resulting in a bleaching effect. This setting is commonly used for highlights or to remove black areas of the movie clip. 5 "lighten" selects the lighter of the ...

  • Page 843

    Movieclip 843 7 "difference" compares the constituent colors of the movie clip with those of its background, and subtracts the darker of the values of the two constituent colors from the lighter one. This setting is commonly used for more vibrant colors. For example, if the movie clip has a pixel wi...

  • Page 844

    844 actionscript classes if you attempt to set the blendmode property to any other value, flash player sets it to "normal" . However, if you set the property to an integer, flash player converts the value to the corresponding string version: this.Createemptymovieclip("mclip", this.Getnexthighestdept...

  • Page 845

    Movieclip 845 example the following example sets up two movie clips with gradient fills, and changes the blend mode of the one in the foreground every second. In order to have the "alpha" blend mode show up with an effect, the gradient for the mc2 movie clip includes a range of alpha ratios, and the...

  • Page 846

    846 actionscript classes cacheasbitmap (movieclip.Cacheasbitmap property) public cacheasbitmap : boolean if set to true , flash player caches an internal bitmap representation of the movie clip. This can increase performance for movie clips that contain complex vector content. All vector data for a ...

  • Page 847

    Movieclip 847 example the following example applies a drop shadow to a movie clip instance. It then traces the value of the cacheasbitmap property which is set to true when a filter is applied. Import flash.Filters.Dropshadowfilter; var container:movieclip = setupshape(); trace(container.Cacheasbitm...

  • Page 848

    848 actionscript classes example the following example draws a box on the stage. When the user clicks the box graphic, it removes the graphic from the stage. This.Createemptymovieclip("box_mc", this.Getnexthighestdepth()); box_mc.Onrelease = function() { this.Clear(); }; drawbox(box_mc, 10, 10, 320,...

  • Page 849

    Movieclip 849 you can extend the methods and event handlers of the movieclip class by creating a subclass. Availability: actionscript 1.0; flash player 6 parameters name:string - a string that identifies the instance name of the new movie clip. Depth:number - an integer that specifies the depth of t...

  • Page 850

    850 actionscript classes createtextfield (movieclip.Createtextfield method) public createtextfield(instancename:string, depth:number, x:number, y:number, width:number, height:number) : textfield creates a new, empty text field as a child of the movie clip on which you call this method. You can use t...

  • Page 851

    Movieclip 851 leftmargin = 0 rightmargin = 0 indent = 0 leading = 0 blockindent = 0 bullet = false display = block tabstops = [] // (empty array) you can extend the methods and event handlers of the movieclip class by creating a subclass. Availability: actionscript 1.0; flash player 6 - in flash pla...

  • Page 852

    852 actionscript classes see also getinstanceatdepth (movieclip.Getinstanceatdepth method) , getnexthighestdepth (movieclip.Getnexthighestdepth method) , textformat _currentframe (movieclip._currentframe property) public _currentframe : number [read-only] returns the number of the frame in which the...

  • Page 853

    Movieclip 853 anchory:number - an integer that specifies the vertical position of the next anchor point relative to the registration point of the parent movie clip. Example the following example draws a nearly circular curve with a solid blue hairline stroke and a solid red fill: this.Createemptymov...

  • Page 854

    854 actionscript classes mc.Curveto(r+x, -math.Tan(math.Pi/8)*r+y, r+x, y); } an example is also in the drawingapi.Fla file in the samples\actionscript\drawingapi. The following list gives typical paths to this folder: ■ windows: \program files\macromedia\flash 8\samples and tutorials\samples\ ■ mac...

  • Page 855

    Movieclip 855 } else { this._x = origx; this._y = origy; } }; see also startdrag (movieclip.Startdrag method) , stopdrag (movieclip.Stopdrag method) , eval function duplicatemovieclip (movieclip.Duplicatemovieclip method) public duplicatemovieclip(name:string, depth:number, [initobject:object]) : mo...

  • Page 856

    856 actionscript classes initobject:object [optional] - (supported for flash player 6 and later.) an object that contains properties with which to populate the duplicated movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If initobject is not an object, it ...

  • Page 857

    Movieclip 857 enabled (movieclip.Enabled property) public enabled : boolean a boolean value that indicates whether a movie clip is enabled. The default value of enabled is true . If enabled is set to false , the movie clip's callback methods and onaction event handlers are no longer invoked, and the...

  • Page 858

    858 actionscript classes square_mc.Lineto(10, 10); square_mc.Endfill(); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexth...

  • Page 859

    Movieclip 859 if the filters array is empty, you need not use a temporary array. Instead, you can directly assign an array literal that contains one or more filter objects that you created. To modify an existing filter object, whether it was created at design-time or at runtime, you must use the tec...

  • Page 860

    860 actionscript classes focusenabled (movieclip.Focusenabled property) public focusenabled : boolean if the value is undefined or false , a movie clip cannot receive input focus unless it is a button. If the focusenabled property value is true , a movie clip can receive input focus even if it is no...

  • Page 861

    Movieclip 861 mc3_mc.Onrelease = traceonrelease; function traceonrelease() { trace(this._name); } test the swf file in a browser window by selecting file > publish preview > html. Give the swf focus by clicking it in the browser window, and press tab to focus each instance. You cannot execute code f...

  • Page 862

    862 actionscript classes place your content on or after frame 3. Then add the following code on frame 3: stop(); see also moviecliploader getbounds (movieclip.Getbounds method) public getbounds(bounds:object) : object returns properties that are the minimum and maximum x and y coordinate values of t...

  • Page 863

    Movieclip 863 var bounds_obj:object = square_mc.Getbounds(this); for (var i in bounds_obj) { trace(i+" --> "+bounds_obj[i]); } the following information appears in the output panel: ymax --> 110 ymin --> 10 xmax --> 110 xmin --> 10 see also getrect (movieclip.Getrect method) , globaltolocal (moviecl...

  • Page 864

    864 actionscript classes add the following code on frame 2: if (this._framesloaded this.Gotoandplay(1); } else { this.Gotoandstop(3); } place your content on or after frame 3, and then add the following code on frame 3: stop(); see also getbytestotal (movieclip.Getbytestotal method) getbytestotal (m...

  • Page 865

    Movieclip 865 place your content on or after frame 3. Then add the following code on frame 3: stop(); see also getbytesloaded (movieclip.Getbytesloaded method) getdepth (movieclip.Getdepth method) public getdepth() : number returns the depth of the movie clip instance. Each movie clip, button, and t...

  • Page 866

    866 actionscript classes getinstanceatdepth (movieclip.Getinstanceatdepth method) public getinstanceatdepth(depth:number) : movieclip determines if a particular depth is already occupied by a movie clip. You can use this method before using movieclip.Attachmovie() , movieclip.Duplicatemovieclip() , ...

  • Page 867

    Movieclip 867 getnexthighestdepth (movieclip.Getnexthighestdepth method) public getnexthighestdepth() : number determines a depth value that you can pass to movieclip.Attachmovie() , movieclip.Duplicatemovieclip() , or movieclip.Createemptymovieclip() to ensure that flash renders the movie clip in f...

  • Page 868

    868 actionscript classes mc.Label.Text = mc.Getdepth(); } see also getdepth (movieclip.Getdepth method) , getinstanceatdepth (movieclip.Getinstanceatdepth method) , swapdepths (movieclip.Swapdepths method) , attachmovie (movieclip.Attachmovie method) , duplicatemovieclip (movieclip.Duplicatemoviecli...

  • Page 869

    Movieclip 869 example the following example creates a movie clip and draws inside of it a square with a stroke width of 4 pixels. The example then calls both the movieclip.Getbounds() and movieclip.Getrect() methods to show the difference between the two. The getbounds() method returns the minimum a...

  • Page 870

    870 actionscript classes see also getbounds (movieclip.Getbounds method) , globaltolocal (movieclip.Globaltolocal method) , localtoglobal (movieclip.Localtoglobal method) getswfversion (movieclip.Getswfversion method) public getswfversion() : number returns an integer that indicates the flash player...

  • Page 871

    Movieclip 871 gettextsnapshot (movieclip.Gettextsnapshot method) public gettextsnapshot() : textsnapshot returns a textsnapshot object that contains the text in all the static text fields in the specified movie clip; text in child movie clips is not included. This method always returns a textsnapsho...

  • Page 872

    872 actionscript classes geturl (movieclip.Geturl method) public geturl(url:string, [window:string], [method:string]) : void loads a document from the specified url into the specified window. You can also use the geturl() method to pass variables to another application that is defined at the url by ...

  • Page 873

    Movieclip 873 method:string [optional] - a string (either "get" or "post") that specifies a method for sending variables associated with the swf file to load. If no variables are present, omit this parameter; otherwise, specify whether to load variables using a get or post method. Get appends the va...

  • Page 874

    874 actionscript classes globaltolocal (movieclip.Globaltolocal method) public globaltolocal(pt:object) : void converts the pt object from stage (global) coordinates to the movie clip's (local) coordinates. The movieclip.Globaltolocal() method allows you to convert any given x and y coordinates from...

  • Page 875

    Movieclip 875 the movie clip coordinates were expressed using _x and _y , because those are the movieclip properties that you use to set the x and y values for movieclips. However, your generic object uses x and y without the underscore. The following code converts the x and y values to the local co...

  • Page 876

    876 actionscript classes mouse.Addlistener(mouselistener); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth()...

  • Page 877

    Movieclip 877 see also gotoandplay function , play function gotoandstop (movieclip.Gotoandstop method) public gotoandstop(frame:object) : void brings the playhead to the specified frame of the movie clip and stops it there. To specify a scene in addition to a frame, use the gotoandstop() method. You...

  • Page 878

    878 actionscript classes _height (movieclip._height property) public _height : number the height of the movie clip, in pixels. Availability: actionscript 1.0; flash player 4 example the following code example displays the height and width of a movie clip in the output panel: this.Createemptymoviecli...

  • Page 879

    Movieclip 879 example the following actionscript specifies that best quality anti-aliasing should be applied to the swf file. My_mc._highquality = 2; see also _quality (movieclip._quality property) , _quality property hitarea (movieclip.Hitarea property) public hitarea : object designates another mo...

  • Page 880

    880 actionscript classes hittest (movieclip.Hittest method) public hittest() : boolean evaluates the movie clip to see if it overlaps or intersects with the hit area that the target or x and y coordinate parameters identify. Usage 1: compares the x and y coordinates to the shape or bounding box of t...

  • Page 881

    Movieclip 881 see also getbounds (movieclip.Getbounds method) , globaltolocal (movieclip.Globaltolocal method) , localtoglobal (movieclip.Localtoglobal method) linegradientstyle (movieclip.Linegradientstyle method) public linegradientstyle(filltype:string, colors:array, alphas:array, ratios:array, m...

  • Page 882

    882 actionscript classes for example, for a linear gradient that includes two colors, blue and green, the following figure illustrates the placement of the colors in the gradient based on different values in the ratios array: the values in the array must increase, sequentially; for example, [0, 63, ...

  • Page 883

    Movieclip 883 this code draws the following image onscreen: ■ matrixtype , x , y , w , h , r . The properties indicate the following: matrixtype is the string " box ", x is the horizontal position relative to the registration point of the parent clip for the upper-left corner of the gradient, y is t...

  • Page 884

    884 actionscript classes focalpointratio:number [optional] - a number that controls the location of the focal point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means that the focal point ...

  • Page 885

    Movieclip 885 this code draws the following image (the image is scaled by 50%): see also begingradientfill (movieclip.Begingradientfill method) , linestyle (movieclip.Linestyle method) , lineto (movieclip.Lineto method) , moveto (movieclip.Moveto method) linestyle (movieclip.Linestyle method) public...

  • Page 886

    886 actionscript classes rgb:number - a hexadecimal color value of the line; for example, red is 0xff0000, blue is 0x0000ff, and so on. If a value isn't indicated, flash uses 0x000000 (black). Alpha:number - an integer that indicates the alpha value of the line's color; valid values are 0 to 100. If...

  • Page 887

    Movieclip 887 notice that for jointstyle set to "miter" , you can limit the length of the miter point by using the miterlimit parameter. Miterlimit:number - added in flash player 8. A number that indicates the limit at which a miter is cut off. Valid values range from 1 to 255 (and values outside of...

  • Page 888

    888 actionscript classes if your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method, which is used in this example. See also beginfill (movieclip.Beginfill method) , begingradientfill (movieclip.Begingradient...

  • Page 889

    Movieclip 889 see also beginfill (movieclip.Beginfill method) , createemptymovieclip (movieclip.Createemptymovieclip method) , endfill (movieclip.Endfill method) , linestyle (movieclip.Linestyle method) , moveto (movieclip.Moveto method) loadmovie (movieclip.Loadmovie method) public loadmovie(url:st...

  • Page 890

    890 actionscript classes for flash player 8: ■ loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox. ■ loading is not allowed if the calling swf file is in a network sandbox and the movie clip to be loaded is lo...

  • Page 891

    Movieclip 891 example the following example creates a new movie clip, and then creates child inside of it and loads a png image into the child. This lets the parent retain any instance values that were assigned prior to the call to loadmovie . Var mc:movieclip = this.Createemptymovieclip("mc", this....

  • Page 892

    892 actionscript classes in swf files of any version running in flash player 7 or later, url must be in exactly the same domain as the swf file that is issuing this call. For example, a swf file at www.Somedomain.Com can load data only from sources that are also at www.Somedomain.Com. To load data f...

  • Page 893

    Movieclip 893 the params.Txt file includes the following text: var1="hello"&var2="goodbye"&done="done" the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class in...

  • Page 894

    894 actionscript classes for example, if you create a movie clip that is positioned at the point (_x:100, _y:100), and you pass a local point representing a point near the top-left corner of the movie clip (x:10, y:10) to the localtoglobal() method, the method should convert the x and y values to gl...

  • Page 895

    Movieclip 895 this.Stopdrag(); }; the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also globalt...

  • Page 896

    896 actionscript classes example in the following example, lockroot.Fla has _lockroot applied to the main swf file. If the swf file is loaded into another fla document, _root always refers to the scope of lockroot.Swf, which helps prevent conflicts. Place the following actionscript on the main timel...

  • Page 897

    Movieclip 897 which traces the following information: from current swf file dumproot -> [type function] $version -> win 7,0,19,0 nolockroot_mc -> _level0.Nolockroot_mc lockroot_mc -> _level0.Lockroot_mc from nolockroot.Swf myvar -> 1 i -> lockroot_mc dumproot -> [type function] $version -> win 7,0,1...

  • Page 898

    898 actionscript classes see also _root property , _lockroot (movieclip._lockroot property) , attachmovie (movieclip.Attachmovie method) , loadmovie (movieclip.Loadmovie method) , onloadinit (moviecliploader.Onloadinit event listener) menu (movieclip.Menu property) public menu : contextmenu associat...

  • Page 899

    Movieclip 899 moveto (movieclip.Moveto method) public moveto(x:number, y:number) : void moves the current drawing position to (x, y). If any of the parameters are missing, this method fails and the current drawing position is not changed. You can extend the methods and event handlers of the moviecli...

  • Page 900

    900 actionscript classes example the following example lets you right-click (windows) or control-click (macintosh) a movie clip on the stage and select info from the context menu to view information about that instance. Add several movie clips with instance names, and then add the following actionsc...

  • Page 901

    Movieclip 901 see also nextframe function , prevframe function , prevframe (movieclip.Prevframe method) ondata (movieclip.Ondata handler) ondata = function() {} invoked when a movie clip receives data from a movieclip.Loadvariables() call or a movieclip.Loadmovie() call. You must define a function t...

  • Page 902

    902 actionscript classes ondragout (movieclip.Ondragout handler) ondragout = function() {} invoked when the mouse button is pressed and the pointer rolls outside the object. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in ...

  • Page 903

    Movieclip 903 onenterframe (movieclip.Onenterframe handler) onenterframe = function() {} invoked repeatedly at the frame rate of the swf file. The function that you assign to the onenterframe event handler is processed before any other actionscript code that is attached to the affected frames. You m...

  • Page 904

    904 actionscript classes example the following example defines a function for the onkeydown() method that sends a trace() action to the output panel. Create a movie clip called my_mc and add the following actionscript to your fla or as file: my_mc.Onkeydown = function () { trace ("key was pressed");...

  • Page 905

    Movieclip 905 example the following example defines a function for the onkeyup method that sends a trace() action to the output panel: my_mc.Onkeyup = function () { trace ("onkey called"); } the following example sets input focus: my_mc.Focusenabled = true; selection.Setfocus(my_mc); see also getasc...

  • Page 906

    906 actionscript classes tab between the two instances, and information displays in the output panel. See also onsetfocus (movieclip.Onsetfocus handler) onload (movieclip.Onload handler) onload = function() {} invoked when the movie clip is instantiated and appears in the timeline. You must define a...

  • Page 907

    Movieclip 907 see also loadmovie (movieclip.Loadmovie method) , onclipevent handler , moviecliploader onmousedown (movieclip.Onmousedown handler) onmousedown = function() {} invoked when the mouse button is pressed. You must define a function that executes when the event handler is invoked. You can ...

  • Page 908

    908 actionscript classes availability: actionscript 1.0; flash player 6 example the following example defines a function for the onmouseup() method that sends a trace() action to the output panel: my_mc.Onmouseup = function () { trace ("onmouseup called"); } onpress (movieclip.Onpress handler) onpre...

  • Page 909

    Movieclip 909 onreleaseoutside (movieclip.Onreleaseoutside handler) onreleaseoutside = function() {} invoked after a user presses the mouse button inside the movie clip area and then releases it outside the movie clip area. You must define a function that executes when the event handler is invoked. ...

  • Page 910

    910 actionscript classes onrollover (movieclip.Onrollover handler) onrollover = function() {} invoked when user moves the pointer over a movie clip area. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that ex...

  • Page 911

    Movieclip 911 example the following example displays information about the movie clip that receives keyboard focus, and the instance that previously had focus. Two movie clips, called my_mc and other_mc are on the stage. Add the following actionscript to your as or fla document: my_mc.Onrelease = vo...

  • Page 912

    912 actionscript classes you recognize a greater performance benefit with a movie clip that would have many transparent regions if opaquebackground were not set. Note:the opaque background region is not matched in a hittest() method that has the shapeflag parameter set to true . Availability: action...

  • Page 913

    Movieclip 913 example the following example traces the reference to a movie clip and its parent timeline. Create a movie clip with the instance name my_mc , and add it to the main timeline. Add the following actionscript to your fla or as file: my_mc.Onrelease = function() { trace("you clicked the m...

  • Page 914

    914 actionscript classes see also play function , gotoandplay (movieclip.Gotoandplay method) , gotoandplay function prevframe (movieclip.Prevframe method) public prevframe() : void sends the playhead to the previous frame and stops it. You can extend the methods and event handlers of the movieclip c...

  • Page 915

    Movieclip 915 _quality (movieclip._quality property) public _quality : string sets or retrieves the rendering quality used for a swf file. Device fonts are always aliased and therefore are unaffected by the _quality property. You can set the _quality to the following values: value description graphi...

  • Page 916

    916 actionscript classes availability: actionscript 1.0; flash player 6 example this example sets the rendering quality of a movie clip named my_mc to low : my_mc._quality = "low"; " high " high rendering quality. This setting is the default rendering quality setting that flash uses. Graphics are an...

  • Page 917

    Movieclip 917 see also _quality property removemovieclip (movieclip.Removemovieclip method) public removemovieclip() : void removes a movie clip instance created with duplicatemovieclip() , movieclip.Duplicatemovieclip() , movieclip.Createemptymovieclip() , or movieclip.Attachmovie() . This method d...

  • Page 918

    918 actionscript classes var randnum:number = math.Round(math.Random()*(max-min))+min; return randnum; } var bugnum:number = 0; addbug_btn.Onrelease = addbug; function addbug() { var thisbug:movieclip = this._parent.Attachmovie("bug_id", "bug"+bugnum+"_mc", bugnum, {_x:randrange(50, 500), _y:randran...

  • Page 919

    Movieclip 919 example the following example creates a triangle movie clip instance dynamically. When you run the swf file, click the movie clip to rotate it. This.Createemptymovieclip("triangle", this.Getnexthighestdepth()); triangle.Beginfill(0x0000ff, 100); triangle.Moveto(100, 100); triangle.Line...

  • Page 920

    920 actionscript classes you can think of the eight regions outside of the center (defined by the rectangle) as being like a picture frame that has special rules applied to it when the movie clip is scaled. When the scale9grid property is set and a movie clip is scaled, all text and child movie clip...

  • Page 921

    Movieclip 921 a common use for setting scale9grid is to set up a component in which edge lines retain the same width when the component is scaled. In the macromedia flash authoring environment, you can enable guides for 9-slice scaling for a movie clip symbol in a library. This lets you graphically ...

  • Page 922

    922 actionscript classes example the following creates a movie clip that contains a 20-pixel line (which forms a border) and a gradient fill. The movie clip scales based on the mouse position, and because of the scale9grid set for the movie clip, the thickness of the 20-pixel line does not vary when...

  • Page 923

    Movieclip 923 scrollrect (movieclip.Scrollrect property) public scrollrect : object the scrollrect property allows you to quickly scroll movie clip content and have a window viewing larger content. Text fields and complex content scroll much faster, because pixel level copying is used to scroll data...

  • Page 924

    924 actionscript classes content.Lineto(0, 300); content.Lineto(0, 0); content.Endfill(); content._rotation = -90; mc.Onenterframe = function() { this.Content._y += 1; } return mc; } the setupcontainer() function performs the following steps: ■ create a movieclip named container ■ create a movieclip...

  • Page 925

    Movieclip 925 parameters mc:object - the instance name of a movie clip to be a mask. This can be a string or a movieclip. Example the following code uses the circlemask_mc movie clip to mask the themaskee_mc movie clip: themaskee_mc.Setmask(circlemask_mc); _soundbuftime (movieclip._soundbuftime prop...

  • Page 926

    926 actionscript classes top:number [optional] - value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. Right:number [optional] - value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the mov...

  • Page 927

    Movieclip 927 example the following example shows how to stop a movie clip named amovieclip : amovieclip.Stop(); see also stop function stopdrag (movieclip.Stopdrag method) public stopdrag() : void ends a movieclip.Startdrag() method. A movie clip that was made draggable with that method remains dra...

  • Page 928

    928 actionscript classes swapdepths (movieclip.Swapdepths method) public swapdepths(target:object) : void swaps the stacking, or depth level (z-order), of this movie clip with the movie clip that is specified by the target parameter, or with the movie clip that currently occupies the depth level tha...

  • Page 929

    Movieclip 929 tabchildren (movieclip.Tabchildren property) public tabchildren : boolean determines whether the children of a movie clip are included in the automatic tab ordering. If the tabchildren property is undefined or true , the children of a movie clip are included in automatic tab ordering. ...

  • Page 930

    930 actionscript classes tabenabled (movieclip.Tabenabled property) public tabenabled : boolean specifies whether the movie clip is included in automatic tab ordering. It is undefined by default. If the tabenabled property is undefined , the object is included in automatic tab ordering only if it de...

  • Page 931

    Movieclip 931 the tabindex property must be a positive integer. The objects are ordered according to their tabindex properties, in ascending order. An object with a tabindex value of 1 precedes an object with a tabindex value of 2 . The custom tab ordering disregards the hierarchical relationships o...

  • Page 932

    932 actionscript classes _totalframes (movieclip._totalframes property) public _totalframes : number [read-only] returns the total number of frames in the movie clip instance specified in the movieclip parameter. Availability: actionscript 1.0; flash player 4 example in the following example, two mo...

  • Page 933

    Movieclip 933 example the following example sets the trackasmenu property for three movie clips on the stage. Click a movie clip and release the mouse button on a second movie clip to see which instance receives the event. Mymc1_mc.Trackasmenu = true; mymc2_mc.Trackasmenu = true; mymc3_mc.Trackasmen...

  • Page 934

    934 actionscript classes mynewdisplayobj.Transform = myolddisplayobj.Transform; the new movie clip, mynewdisplayobj , now has the same values for its matrix, color transform, and pixel bounds as the old movie clip, myolddisplayobj . Availability: actionscript 1.0; flash player 8 example the followin...

  • Page 935

    Movieclip 935 unloadmovie (movieclip.Unloadmovie method) public unloadmovie() : void removes the contents of a movie clip instance. The instance properties and clip handlers remain. To remove the instance, including its properties and clip handlers, use movieclip.Removemovieclip() . You can extend t...

  • Page 936

    936 actionscript classes _url (movieclip._url property) public _url : string [read-only] retrieves the url of the swf, jpeg, gif, or png file from which the movie clip was downloaded. Availability: actionscript 1.0; flash player 4 - the ability to retrieve the url of jpeg files from which the movie ...

  • Page 937

    Movieclip 937 the moviecliploader class used in these examples requires flash player 7 or later. The movieclip.Getnexthighestdepth() method used in these examples requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instea...

  • Page 938

    938 actionscript classes example the following example sets the _visible property for two movie clips called mymc1_mc and mymc2_mc . The property is set to true for one instance, and false for the other. Notice that mymc1_mc instance cannot be clicked after the _visible property is set to false . My...

  • Page 939

    Movieclip 939 _x (movieclip._x property) public _x : number an integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip. If a movie clip is in the main timeline, its coordinate system refers to the upper-left corner of the stage as (0, 0). If the ...

  • Page 940

    940 actionscript classes example the following example returns the current x and y coordinates of the mouse on the stage ( _level0 ) and in relation to a movie clip on the stage called my_mc : this.Createtextfield("mouse_txt", this.Getnexthighestdepth(), 0, 0, 150, 66); mouse_txt.Html = true; mouse_...

  • Page 941

    Movieclip 941 with (box_mc) { linestyle(1, 0xcccccc); beginfill(0xeeeeee); moveto(0, 0); lineto(80, 0); lineto(80, 60); lineto(0, 60); lineto(0, 0); endfill(); }; box_mc.Onrollover = function() { this._x -= this._width/2; this._y -= this._height/2; this._xscale = 200; this._yscale = 200; }; box_mc.O...

  • Page 942

    942 actionscript classes example the following example attaches a movie clip with the cursor_id linkage identifier to a swf file. The movie clip is called cursor_mc , and it is used to replace the default mouse pointer. The following actionscript sets the current coordinates of the movie clip instan...

  • Page 943

    Movieclip 943 mouse_txt.Htmltext += ""; }; the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See als...

  • Page 944

    944 actionscript classes this._yscale = 200; }; box_mc.Onrollout = function() { this._xscale = 100; this._yscale = 100; this._x += this._width/2; this._y += this._height/2; }; see also _height (movieclip._height property) , _x (movieclip._x property) , _xscale (movieclip._xscale property) , _y (movi...

  • Page 945

    Moviecliploader 945 availability: actionscript 1.0; flash player 7 property summary properties inherited from class object event summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) e...

  • Page 946

    946 actionscript classes constructor summary method summary methods inherited from class object addlistener (moviecliploader.Addlistener method) public addlistener(listener:object) : boolean registers an object to receive notification when a moviecliploader event handler is invoked. Availability: ac...

  • Page 947

    Moviecliploader 947 parameters listener:object - an object that listens for a callback notification from the moviecliploader event handlers. Returns boolean - a boolean value. Returns true if the listener was established successfully; otherwise false . Example the following example loads an image in...

  • Page 948

    948 actionscript classes getprogress (moviecliploader.Getprogress method) public getprogress(target:object) : object returns the number of bytes loaded and the total number of bytes of a file that is being loaded by using moviecliploader.Loadclip() ; for compressed movies, returns the number of comp...

  • Page 949

    Moviecliploader 949 var progress:object = mcloader.Getprogress(image); trace("bytesloaded: " + progress.Bytesloaded + " bytestotal: " + progress.Bytestotal); if(progress.Bytesloaded == progress.Bytestotal) { clearinterval(interval.Id); } } if your swf file includes a version 2 component, use the ver...

  • Page 950

    950 actionscript classes a swf file or image loaded into a movie clip inherits the position, rotation, and scale properties of the movie clip. You can use the target path of the movie clip to target the loaded movie. You can use the loadclip() method to load one or more files into a single movie cli...

  • Page 951

    Moviecliploader 951 availability: actionscript 1.0; flash player 7 - support for unanimated gif files, png files, and progressive jpeg files is available as of flash player 8. Parameters url:string - the absolute or relative url of the swf, jpeg, gif, or png file to be loaded. A relative path must b...

  • Page 952

    952 actionscript classes moviecliploader constructor public moviecliploader() creates a moviecliploader object that you can use to implement a number of listeners to respond to events while a swf, jpeg, gif, or png file is downloading. Availability: actionscript 1.0; flash player 7 example see movie...

  • Page 953

    Moviecliploader 953 availability: actionscript 1.0; flash player 7 - support for unanimated gif files, png files, and progressive jpeg files is available as of flash player 8. Parameters target_mc:movieclip [optional] - a movie clip loaded by the moviecliploader.Loadclip() method. Httpstatus:number ...

  • Page 954

    954 actionscript classes see also addlistener (moviecliploader.Addlistener method) , loadclip (moviecliploader.Loadclip method) , onloadstart (moviecliploader.Onloadstart event listener) , onloaderror (moviecliploader.Onloaderror event listener) , onloadinit (moviecliploader.Onloadinit event listene...

  • Page 955

    Moviecliploader 955 parameters target_mc:movieclip - a movie clip loaded by the moviecliploader.Loadclip() method. Errorcode:string - a string that explains the reason for the failure, either "urlnotfound" or "loadnevercompleted" . Httpstatus:number [optional] - (flash player 8 only) the http status...

  • Page 956

    956 actionscript classes onloadinit (moviecliploader.Onloadinit event listener) onloadinit = function([target_mc:movieclip]) {} invoked when the actions on the first frame of the loaded clip have been executed. When this listener has been invoked, you can set properties, use methods, and otherwise i...

  • Page 957

    Moviecliploader 957 this.Createemptymovieclip("tester_mc", 1); var mcllistener:object = new object(); mcllistener.Onloadinit = function(target_mc:movieclip) { trace("movie loaded"); } var image_mcl:moviecliploader = new moviecliploader(); image_mcl.Addlistener(mcllistener); image_mcl.Loadclip("http:...

  • Page 958

    958 actionscript classes totalbytes:number - the total number of bytes in the file being loaded. Example the following example creates a movie clip, a new moviecliploader instance, and an anonymous event listener. It periodically outputs the progress of a load and finally provides notification when ...

  • Page 959

    Moviecliploader 959 parameters target_mc:movieclip [optional] - a movie clip loaded by the moviecliploader.Loadclip() method. Example the following example loads an image into a movie clip instance called image_mc . The onloadinit and onloadcomplete events are used to determine how long it takes to ...

  • Page 960

    960 actionscript classes removelistener (moviecliploader.Removelistener method) public removelistener(listener:object) : boolean removes the listener that was used to receive notification when a moviecliploader event handler was invoked. No further loading messages will be received. Availability: ac...

  • Page 961

    Moviecliploader 961 image_mcl.Addlistener(mcllistener); image_mcl.Loadclip("http://www.Helpexamples.Com/flash/images/ image1.Jpg", image_mc); }; stop_button.Clickhandler = function() { trace("stopping..."); start_button.Enabled = true; stop_button.Enabled = false; // image_mcl.Removelistener(mcllist...

  • Page 962

    962 actionscript classes target_mc._y = 100; target_mc.Onrelease = function() { trace("unloading clip..."); trace("\t name: "+target_mc._name); trace("\t url: "+target_mc._url); image_mcl.Unloadclip(target_mc); }; }; var image_mcl:moviecliploader = new moviecliploader(); image_mcl.Addlistener(mcllis...

  • Page 963

    Netconnection 963 constructor summary method summary methods inherited from class object connect (netconnection.Connect method) public connect(targeturi:string) : boolean opens a local connection through which you can play back video (flv) files from an http address or from the local file system. Wh...

  • Page 964

    964 actionscript classes for more information, see the following: ■ chapter 17, "understanding security," in learning actionscript 2.0 in flash ■ the flash player 8 security white paper at http://www.Macromedia.Com/go/fp8_security ■ the flash player 8 security-related api white paper at http://www.M...

  • Page 965

    Netstream 965 netconnection constructor public netconnection() creates a netconnection object that you can use in conjunction with a netstream object to play back local streaming video (flv) files. After creating the netconnection object, use netconnection.Connect() to make the actual connection. Pl...

  • Page 966

    966 actionscript classes property summary properties inherited from class object event summary constructor summary modifiers property description bufferlength :number [read-only] the number of seconds of data currently in the buffer. Buffertime :number [read-only] the number of seconds assigned to t...

  • Page 967

    Netstream 967 method summary methods inherited from class object bufferlength (netstream.Bufferlength property) public bufferlength : number [read-only] the number of seconds of data currently in the buffer. You can use this property in conjunction with netstream.Buffertime to estimate how close the...

  • Page 968

    968 actionscript classes this.Createtextfield("buffer_txt", this.Getnexthighestdepth(), 10, 10, 300, 22); buffer_txt.Html = true; var connection_nc:netconnection = new netconnection(); connection_nc.Connect(null); var stream_ns:netstream = new netstream(connection_nc); stream_ns.Setbuffertime(3); my...

  • Page 969

    Netstream 969 this.Createtextfield("buffer_txt", this.Getnexthighestdepth(), 10, 10, 300, 22); buffer_txt.Html = true; var connection_nc:netconnection = new netconnection(); connection_nc.Connect(null); var stream_ns:netstream = new netstream(connection_nc); stream_ns.Setbuffertime(3); my_video.Atta...

  • Page 970

    970 actionscript classes connection_nc.Connect(null); var stream_ns:netstream = new netstream(connection_nc); my_video.Attachvideo(stream_ns); stream_ns.Play("video1.Flv"); this.Createtextfield("loaded_txt", this.Getnexthighestdepth(), 10, 10, 160, 22); this.Createemptymovieclip("progressbar_mc", th...

  • Page 971

    Netstream 971 see also bytestotal (netstream.Bytestotal property) , bufferlength (netstream.Bufferlength property) bytestotal (netstream.Bytestotal property) public bytestotal : number [read-only] the total size in bytes of the file being loaded into the player. Availability: actionscript 1.0; flash...

  • Page 972

    972 actionscript classes } var loaded_interval:number = setinterval(checkbytesloaded, 500, stream_ns); function checkbytesloaded(my_ns:netstream) { var pctloaded:number = math.Round(my_ns.Bytesloaded/my_ns.Bytestotal 100); loaded_txt.Text = math.Round(my_ns.Bytesloaded/1000)+" of "+math.Round(my_ns....

  • Page 973

    Netstream 973 close_btn.Onrelease = function(){ stream_ns.Close(); }; see also pause (netstream.Pause method) , play (netstream.Play method) currentfps (netstream.Currentfps property) public currentfps : number [read-only] the number of frames per second being displayed. If you are exporting flv fil...

  • Page 974

    974 actionscript classes netstream constructor public netstream(connection:netconnection) creates a stream that can be used for playing flv files through the specified netconnection object. Availability: actionscript 1.0; flash player 7 - note: this class is also supported in flash player 6 when use...

  • Page 975

    Netstream 975 the oncuepoint() event handler receives an object with these properties: you can define cue points in an flv file when you first encode the file, or when you import a video clip in the flash authoring tool by using the video import wizard. The onmetadata() event handler also retrieves ...

  • Page 976

    976 actionscript classes var ns:netstream = new netstream(nc); ns.Oncuepoint = function(infoobject:object) { trace("oncuepoint:"); for (var propname:string in infoobject) { if (propname != "parameters") { trace(propname + " = " + infoobject[propname]); } else { trace("parameters ="); if (infoobject....

  • Page 977

    Netstream 977 time = 16.02 name = point3 --------- the parameter name "lights" is an arbitrary name used by the author of the example video. You can give cue point parameters any name you want. See also onmetadata (netstream.Onmetadata handler) onmetadata (netstream.Onmetadata handler) onmetadata = ...

  • Page 978

    978 actionscript classes ns.Play("http://www.Helpexamples.Com/flash/video/water.Flv"); this causes the following information to be displayed: canseektoend = true videocodecid = 4 framerate = 15 videodatarate = 400 height = 215 width = 320 duration = 7.347 the list of properties will vary depending o...

  • Page 979

    Netstream 979 if you consistently see errors regarding buffer, you should try changing the buffer using the netstream.Setbuffertime() method. Availability: actionscript 1.0; flash player 6 parameters infoobject:object - a parameter defined according to the status message or error message. Example th...

  • Page 980

    980 actionscript classes pause (netstream.Pause method) public pause([flag:boolean]) : void pauses or resumes playback of a stream. The first time you call this method (without sending a parameter), it pauses play; the next time, it resumes play. You might want to attach this method to a button that...

  • Page 981

    Netstream 981 you can play local flv files that are stored in the same directory as the swf file or in a subdirectory; you can't navigate to a higher-level directory. For example, if the swf file is located in a directory named /training, and you want to play a video stored in the /training/ videos ...

  • Page 982

    982 actionscript classes // play a file on a server. My_ns.Play("http://someserver.Somedomain.Com/flash/video/orientation.Flv"); see also attachaudio (movieclip.Attachaudio method) , close (netstream.Close method) , onstatus (netstream.Onstatus handler) , pause (netstream.Pause method) , attachvideo...

  • Page 983

    Netstream 983 // move to a location 30 seconds from the beginning of the stream my_ns.Seek(30); // move backwards three minutes from current location my_ns.Seek(my_ns.Time - 180); see also , time (netstream.Time property) setbuffertime (netstream.Setbuffertime method) public setbuffertime(buffertime...

  • Page 984

    984 actionscript classes example the following example displays the current position of the playhead in a dynamically created text field called time_txt . Select new video from the library options menu to create a video object instance, and give it an instance name my_video . Create a new video obje...

  • Page 986

    986 actionscript classes properties inherited from class object constructor summary method summary methods inherited from class object max_value (number.Max_value property) public static max_value : number the largest representable number (double-precision ieee-754). This number is approximately 1.7...

  • Page 987

    Number 987 this code displays the following values: number.Min_value = 4.94065645841247e-324 number.Max_value = 1.79769313486232e+308 min_value (number.Min_value property) public static min_value : number the smallest representable number (double-precision ieee-754). This number is approximately 5e-...

  • Page 988

    988 actionscript classes example this example compares the result of dividing the following values. Var posresult:number = 1/0; if (posresult == number.Positive_infinity) { trace("posresult = "+posresult); // output: posresult = infinity } var negresult:number = -1/0; if (negresult == number.Negativ...

  • Page 989

    Number 989 example this example compares the result of dividing the following values. Var posresult:number = 1/0; if (posresult == number.Positive_infinity) { trace("posresult = "+posresult); // output: posresult = infinity } var negresult:number = -1/0; if (negresult == number.Negative_infinity) { ...

  • Page 990

    990 actionscript classes valueof (number.Valueof method) public valueof() : number returns the primitive value type of the specified number object. Availability: actionscript 1.0; flash player 5 returns number - a string. Example the following example results in the primative value of the numsocks o...

  • Page 991

    Object 991 constructor summary method summary signature description object () creates an object object and stores a reference to the object's constructor method in the object's constructor property. Modifiers signature description addproperty (name:str ing, getter:function, setter:function) : boolea...

  • Page 992

    992 actionscript classes addproperty (object.Addproperty method) public addproperty(name:string, getter:function, setter:function) : boolean creates a getter/setter property. When flash reads a getter/setter property, it invokes the get function, and the function's return value becomes the value of ...

  • Page 993

    Object 993 setter:function - the function that is invoked to set the value of the property; this parameter is a function object. If you pass the value null for this parameter, the property is read-only. Returns boolean - a boolean value: true if the property is successfully created; false otherwise....

  • Page 994

    994 actionscript classes the previous example works, but the properties bookcount and bookname are added to every instance of the book object, which requires having two properties for every instance of the object. If there are many properties, such as bookcount and bookname, in a class, they could c...

  • Page 995

    Object 995 the following code can then be placed in a fla file and will function the same way as it does in the previous examples: var mybook:book = new book(); mybook.Bookcount = 5; trace("you ordered "+mybook.Bookcount+" copies of "+mybook.Bookname); see also get statement , set statement construc...

  • Page 996

    996 actionscript classes hasownproperty (object.Hasownproperty method) public hasownproperty(name:string) : boolean indicates whether an object has a specified property defined. This method returns true if the target object has a property that matches the string specified by the name parameter, and ...

  • Page 997

    Object 997 var myobj:object = new object(); myobj.Prop1 = "hello"; trace(myobj.Ispropertyenumerable("prop1")); // output: true var myarray = new array(); trace(myarray.Ispropertyenumerable("length")); // output: false see also for..In statement isprototypeof (object.Isprototypeof method) public ispr...

  • Page 998

    998 actionscript classes __proto__ (object.__proto__ property) public __proto__ : object refers to the prototype property of the class (actionscript 2.0) or constructor function (actionscript 1.0) used to create the object. The __proto__ property is automatically assigned to all objects when they ar...

  • Page 999

    Object 999 prototype (object.Prototype property) public static prototype : object a reference to the superclass of a class or function object. The prototype property is automatically created and attached to any class or function object you create. This property is static in that it is specific to th...

  • Page 1000

    1000 actionscript classes registerclass (object.Registerclass method) public static registerclass(name:string, theclass:function) : boolean associates a movie clip symbol with an actionscript object class. If a symbol doesn't exist, flash creates an association between a string identifier and an obj...

  • Page 1001

    Object 1001 returns boolean - a boolean value: if the class registration succeeds, a value of true is returned; false otherwise. See also attachmovie (movieclip.Attachmovie method) , duplicatemovieclip (movieclip.Duplicatemovieclip method) __resolve (object.__resolve property) public __resolve : obj...

  • Page 1002

    1002 actionscript classes usage 2: the following example uses __resolve as a functor, which is a function that generates functions. Using __resolve redirects undefined method calls to a generic function named myfunction . // instantiate a new object var myobject:object = new object(); // define a fu...

  • Page 1003

    Object 1003 myobject.Someothermethod(); // does not call __resolve, no longer undefined usage 4: the following example builds on the previous example by reserving a method name, onstatus() , for local use so that it is not resolved in the same way as other undefined properties. Added code is in bold...

  • Page 1004

    1004 actionscript classes } var f:function = function () { arguments.Unshift(name); this.Myfunction.Apply(this, arguments); }; // create a new object method and assign it the reference this[name] = f; // return the reference to the function return f; }; // test __resolve using undefined method names...

  • Page 1005

    Object 1005 // number.Tostring() returns the number value as a string // because trace() won't tell us whether the value is a string or number // we will also use typeof() to test whether tostring() works. Var mynumber:number = 5; trace(typeof (mynumber)); // output: number trace(mynumber.Tostring()...

  • Page 1006

    1006 actionscript classes parameters name:string - a string; the name of the object property that should no longer be watched. Returns boolean - a boolean value: true if the watchpoint is successfully removed, false otherwise. Example see the example for object.Watch() . See also watch (object.Watch...

  • Page 1007

    Object 1007 trace(mydate.Valueof()); // output: 1075652100000 // create a new array object containing two simple elements // in this case both tostring() and valueof() return the same value: one,two var myarray:array = new array("one", "two"); trace(myarray.Tostring()); // output: one,two trace(myar...

  • Page 1008

    1008 actionscript classes the object.Watch() method cannot watch getter/setter properties. Getter/setter properties operate through lazy evaluation-- the value of the property is not determined until the property is actually queried. Lazy evaluation is often efficient because the property is not con...

  • Page 1009

    Point (flash.Geom.Point) 1009 // return the value of newval. Return newval; } // use watch() to register the event handler, passing as parameters: // - the name of the property to watch: "speed" // - a reference to the callback function speedwatcher // - the speedlimit of 55 as the userdata paramete...

  • Page 1010

    1010 actionscript classes properties inherited from class object constructor summary method summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) signature description point (x:number,...

  • Page 1011

    Point (flash.Geom.Point) 1011 methods inherited from class object add (point.Add method) public add(v:point) : point adds the coordinates of another point to the coordinates of this point to create a new point. Availability: actionscript 1.0; flash player 8 parameters v:flash.Geom.Point - the point ...

  • Page 1012

    1012 actionscript classes example the following example creates a copy of the point object called clonedpoint from the values found in the mypoint object. The clonedpoint object contains all of the values from mypoint , but it is not the same object. Import flash.Geom.Point; var mypoint:point = new ...

  • Page 1013

    Point (flash.Geom.Point) 1013 parameters tocompare:object - the point to be compared. Returns boolean - if the object is equal to this point object, true ; if it is not equal, false . Example the following example determines whether the values of one point are equal to the values of another point. I...

  • Page 1014

    1014 actionscript classes var interpolatedpoint:point = point.Interpolate(point_1, point_2, .5); trace(interpolatedpoint.Tostring()); // (x=-25, y=-25) length (point.Length property) public length : number the length of the line segment from (0,0) to this point. Availability: actionscript 1.0; flash...

  • Page 1015

    Point (flash.Geom.Point) 1015 see also length (point.Length property) offset (point.Offset method) public offset(dx:number, dy:number) : void offsets the point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to t...

  • Page 1016

    1016 actionscript classes example the first example creates a point object point_1 with the default constructor. Import flash.Geom.Point; var point_1:point = new point(); trace(point_1.X); // 0 trace(point_1.Y); // 0 the second example creates a point object point_2 with the coordinates x = 1 and y ...

  • Page 1017

    Point (flash.Geom.Point) 1017 when computers work with transcendental numbers such as pi, some round-off error occurs because floating-point arithmetic has only finite precision. When you use math.Pi , consider using the math.Round() function, as shown in the following example. Import flash.Geom.Poi...

  • Page 1018

    1018 actionscript classes returns string - a string. Example the following example creates a point and converts its values to a string in the format (x=x, y=y). Import flash.Geom.Point; var mypoint:point = new point(1, 2); trace("mypoint: " + mypoint.Tostring()); // (x=1, y=2) x (point.X property) p...

  • Page 1020

    1020 actionscript classes constructor summary method summary methods inherited from class object addpage (printjob.Addpage method) public addpage(target:object, [printarea:object], [options:object], [framenum:number]) : boolean sends the specified level or movie clip as a single page to the print sp...

  • Page 1021

    Printjob 1021 if this method returns false (for example, if you haven't called printjob.Start() or the user canceled the print job), any subsequent calls to printjob.Addpage() will fail. However, if previous calls to printjob.Addpage() were successful, the concluding printjob.Send() command sends th...

  • Page 1022

    1022 actionscript classes ■ 1 inch = 72 points = 1440 twips ■ 1 cm = 567 twips you can't reliably convert between pixels and points; the conversion rate depends on the screen and its resolution. If the screen is set to display 72 pixels per inch, for example, one point is equal to one pixel. If you ...

  • Page 1023

    Printjob 1023 returns boolean - a boolean value: true if the page is successfully sent to the print spooler; false otherwise. Example the following example shows several ways to issue the addpage() command: my_btn.Onrelease = function() { var pagecount:number = 0; var my_pj:printjob = new printjob()...

  • Page 1024

    1024 actionscript classes dance_mc._yscale = 50; if (my_pj.Addpage("dance_mc", {xmin:0,xmax:400,ymin:0,ymax:600},null, 3)){ pagecount++; } dance_mc._xscale = x; dance_mc._yscale = y; } } } } } } // if addpage() was successful at least once, print the spooled pages. If (pagecount > 0){ my_pj.Send(); ...

  • Page 1025

    Printjob 1025 pagewidth (printjob.Pagewidth property) public pagewidth : number [read-only] the width of the actual printable area on the page, in points. Any user-set margins are ignored. Note that this property is only available after a call to the printjob.Start() method. Availability: actionscri...

  • Page 1026

    1026 actionscript classes // add specified area to print job // repeat once for each page to be printed if (my_pj.Addpage([params])) { pagestoprint++; } if (my_pj.Addpage([params])) { pagestoprint++; } if (my_pj.Addpage([params])) { pagestoprint++; } // send pages from the spooler to the printer, bu...

  • Page 1027

    Printjob 1027 var my_pj:printjob = new printjob(); if (my_pj.Start()) { if (my_pj.Addpage(this)) { my_pj.Send(); } } delete my_pj; availability: actionscript 1.0; flash player 7 example see printjob.Addpage() and printjob.Start() . See also addpage (printjob.Addpage method) , start (printjob.Start m...

  • Page 1028

    1028 actionscript classes because the user sees information such as "printing page 1" immediately after clicking ok, you should call the printjob.Addpage() and printjob.Send() commands as soon as possible. If this method returns false (for example, if the user clicks cancel instead of ok in the oper...

  • Page 1029

    Printjob 1029 example the following example shows how you might use the value of the orientation property to adjust the printout: // create printjob object var my_pj:printjob = new printjob(); // display print dialog box if (my_pj.Start()) { // boolean to track whether addpage succeeded, change this...

  • Page 1031

    Rectangle (flash.Geom.Rectangle) 1031 properties inherited from class object constructor summary method summary size :point the size of the rectangle object, expressed as a point object with the values of the width and height properties. Top :number the y coordinate of the top-left corner of the rec...

  • Page 1032

    1032 actionscript classes containsrectangle (re ct:rectangle) : boolean determines whether the rectangle object specified by the rect parameter is contained within this rectangle object. Equals (tocompare:obj ect) : boolean determines whether the object specified in the tocompare parameter is equal ...

  • Page 1033

    Rectangle (flash.Geom.Rectangle) 1033 methods inherited from class object bottom (rectangle.Bottom property) public bottom : number the sum of the y and height properties. Availability: actionscript 1.0; flash player 8 example the following example creates a rectangle object and changes the value of...

  • Page 1034

    1034 actionscript classes bottomright (rectangle.Bottomright property) public bottomright : point the location of the rectangle object's bottom-right corner, determined by the values of the x and y properties. Availability: actionscript 1.0; flash player 8 example the following example sets the rect...

  • Page 1035

    Rectangle (flash.Geom.Rectangle) 1035 returns flash.Geom.Rectangle - a new rectangle object with the same values for the x , y , width , and height properties as the original rectangle object. Example the following example creates three rectangle objects and compares them. Rect_1 is created using th...

  • Page 1036

    1036 actionscript classes for(var i in clonedrect) { trace(">> " + i + ": " + clonedrect[i]); >> tostring: [type function] >> equals: [type function] >> union: [type function] >> intersects: [type function] >> intersection: [type function] >> containsrectangle: [type function] >> containspoint: [typ...

  • Page 1037

    Rectangle (flash.Geom.Rectangle) 1037 trace(clonedrect.X); // 1 see also x (rectangle.X property) , y (rectangle.Y property) , width (rectangle.Width property) , height (rectangle.Height property) contains (rectangle.Contains method) public contains(x:number, y:number) : boolean determines whether t...

  • Page 1038

    1038 actionscript classes containspoint (rectangle.Containspoint method) public containspoint(pt:point) : boolean determines whether the specified point is contained within the rectangular region defined by this rectangle object. This method is similar to the rectangle.Contains() method, except that...

  • Page 1039

    Rectangle (flash.Geom.Rectangle) 1039 parameters rect:flash.Geom.Rectangle - the rectangle object being checked. Returns boolean - if the rectangle object that you specify is contained by this rectangle object, returns true ; otherwise false . Example the following example creates four new rectangle...

  • Page 1040

    1040 actionscript classes import flash.Geom.Rectangle; var rect_1:rectangle = new rectangle(0, 0, 50, 100); var rect_2:rectangle = new rectangle(0, 0, 50, 100); var rect_3:rectangle = new rectangle(10, 10, 60, 110); trace(rect_1.Equals(rect_2)); // true; trace(rect_1.Equals(rect_3)); // false; even ...

  • Page 1041

    Rectangle (flash.Geom.Rectangle) 1041 var rect:rectangle = new rectangle(5, 5, 10, 10); trace(rect.Height); // 10 trace(rect.Bottom); // 15 rect.Height = 20; trace(rect.Height); // 20 trace(rect.Bottom); // 25 see also x (rectangle.X property) , y (rectangle.Y property) , width (rectangle.Width prop...

  • Page 1042

    1042 actionscript classes see also x (rectangle.X property) , y (rectangle.Y property) inflatepoint (rectangle.Inflatepoint method) public inflatepoint(pt:point) : void increases the size of the rectangle object. This method is similar to the rectangle.Inflate() method, except that it takes a point ...

  • Page 1043

    Rectangle (flash.Geom.Rectangle) 1043 intersection (rectangle.Intersection method) public intersection(tointersect:rectangle) : rectangle if the rectangle object specified in the tointersect parameter intersects with this rectangle object, the intersection() method returns the area of intersection a...

  • Page 1044

    1044 actionscript classes availability: actionscript 1.0; flash player 8 parameters tointersect:flash.Geom.Rectangle - the rectangle object to compare against this rectangle object. Returns boolean - if the specified object intersects with this rectangle object, returns true ; otherwise false . Exam...

  • Page 1045

    Rectangle (flash.Geom.Rectangle) 1045 example the following example creates an empty rectangle object and verifies that it is empty. Import flash.Geom.*; var rect:rectangle = new rectangle(1, 2, 0, 0); trace(rect.Tostring()); // (x=1, y=2, w=0, h=0) trace(rect.Isempty()); // true the following examp...

  • Page 1046

    1046 actionscript classes rect.Left = 10; trace(rect.Left); // 10 trace(rect.X); // 10 see also x (rectangle.X property) , y (rectangle.Y property) , width (rectangle.Width property) , height (rectangle.Height property) offset (rectangle.Offset method) public offset(dx:number, dy:number) : void adju...

  • Page 1047

    Rectangle (flash.Geom.Rectangle) 1047 example the following example offsets a rectangle by using the values found in a point. Import flash.Geom.Rectangle; import flash.Geom.Point; var rect:rectangle = new rectangle(1, 2, 4, 8); trace(rect.Tostring()); // (x=1, y=2, w=4, h=8) var mypoint:point = new ...

  • Page 1048

    1048 actionscript classes right (rectangle.Right property) public right : number the sum of the x and width properties. Availability: actionscript 1.0; flash player 8 example the following example creates a rectangle object and changes its right property from 15 to 30. Notice that rect.Width also ch...

  • Page 1049

    Rectangle (flash.Geom.Rectangle) 1049 var rect:rectangle = new rectangle(5, 10, 50, 100); trace(rect.Isempty()); // false rect.Setempty(); trace(rect.Isempty()); // true see also x (rectangle.X property) , y (rectangle.Y property) , width (rectangle.Width property) , height (rectangle.Height propert...

  • Page 1050

    1050 actionscript classes top (rectangle.Top property) public top : number the y coordinate of the top-left corner of the rectangle. Changing the value of the top property of a rectangle object has no effect on the x , width , and height properties. The value of the top property is equal to the valu...

  • Page 1051

    Rectangle (flash.Geom.Rectangle) 1051 topleft (rectangle.Topleft property) public topleft : point the location of the rectangle object's top-left corner determined by the x and y values of the point. Availability: actionscript 1.0; flash player 8 example the following example sets the rectangle obje...

  • Page 1052

    1052 actionscript classes returns string - a string that lists the value of each of the following properties of the rectangle object: x , y , width , and height . Example the following example concatenates a string representation of rect_1 with some helpful debugging text. Import flash.Geom.Rectangl...

  • Page 1053

    Rectangle (flash.Geom.Rectangle) 1053 for example, consider a rectangle with properties x=20 , y=50 , width=60 , and height=30 (20, 50, 60, 30), and a second rectangle with properties (150, 130, 50, 30). The union of these two rectangles is a larger rectangle that encompasses the two rectangles with...

  • Page 1054

    1054 actionscript classes x (rectangle.X property) public x : number the x coordinate of the top-left corner of the rectangle. Changing the value of the x property of a rectangle object has no effect on the y , width , and height properties. The x property is equal to the left property. Availability...

  • Page 1056

    1056 actionscript classes method summary methods inherited from class object allowdomain (security.Allowdomain method) public static allowdomain(domain1:string) : void lets swf files and html files in the identified domains access objects and variables in the swf file that contains the allowdomain()...

  • Page 1057

    Security (system.Security) 1057 in any cross-domain situation, two parties are involved, and it's important to be clear about which side is which. For the purposes of this discussion, the side performing the cross- scripting is called the accessing party (usually the accessing swf), and the other si...

  • Page 1058

    1058 actionscript classes version-specific differences flash player's cross-domain security rules have evolved from version to version. The following table summarizes the differences. The versions that control the behavior of flash player are swf versions (the published version of a swf file), not t...

  • Page 1059

    Security (system.Security) 1059 version 6. Cross-domain scripting security is introduced. By default, flash player forbids cross-domain scripting; system.Security.Allowdomain() can permit it. To determine whether two files are in the same domain, flash player uses each file's superdomain, which is t...

  • Page 1060

    1060 actionscript classes occasionally, you may encounter the following situation: you load a child swf file from a different domain and want to allow the child swf file to script the parent swf file, but you don't know the final domain from which the child swf file will come. This can happen, for e...

  • Page 1061

    Security (system.Security) 1061 ■ (flash player 8 only) "*" you can pass a wildcard ("*") to system.Security.Allowdomain() to allow all domains, including local hosts, access to the calling swf file. Before using the wildcard, be sure that you want to provide such broad access to the calling swf fil...

  • Page 1062

    1062 actionscript classes security considerations: flash player provides allowinsecuredomain() to maximize flexibility, but macromedia recommends against calling this method. Serving a file over https provides several protections for you and your users, and calling allowinsecuredomain weakens one of...

  • Page 1063

    Security (system.Security) 1063 however, suppose that you want to allow buttons in catalog.Swf, served over http, to add items to the shopping cart in cart.Swf, served over https. To accomplish this, cart.Swf calls allowinsecuredomain() , which allows catalog.Swf to script cart.Swf. This action has ...

  • Page 1064

    1064 actionscript classes ■ use https-to-http scripting, rather than http-to-https scripting. In the scenario described, you could store the contents of the user's shopping cart in catalog.Swf, and have cart.Swf manage only the checkout process. At checkout time, cart.Swf could retrieve the cart con...

  • Page 1065

    Security (system.Security) 1065 example in the following example, you host a math test on a secure domain so that only registered students can access it. You have also developed a number of swf files that illustrate certain concepts, which you host on an insecure domain. You want students to access ...

  • Page 1066

    1066 actionscript classes you can use loadpolicyfile() to load any number of policy files. When considering a request that requires a policy file, flash player always waits for the completion of any policy file downloads before denying a request. As a final fallback, if no policy file specified with...

  • Page 1067

    Security (system.Security) 1067 because the ability to connect to ports lower than 1024 is new, a policy file loaded with loadpolicyfile() must always authorize this connection, even when a movie clip is connecting to its own subdomain. For more information, see the following: ■ chapter 17, "underst...

  • Page 1068

    1068 actionscript classes note that this property may be examined from a swf file of any version, but is only supported in flash player 8 or greater. This unusual arrangement means that you can examine this property, for example, from a version 7 swf file playing in flash player 8. This all- version...

  • Page 1069

    Selection 1069 property summary properties inherited from class object event summary method summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) event description onsetfocus = functio...

  • Page 1070

    1070 actionscript classes methods inherited from class object addlistener (selection.Addlistener method) public static addlistener(listener:object) : void registers an object to receive keyboard focus change notifications. When the focus changes (for example, whenever selection.Setfocus() is invoked...

  • Page 1071

    Selection 1071 when you test the swf file, try using tab to move between the two text fields. Make sure that you select control > disable keyboard shortcuts so you can change focus between the two fields using tab. See also setfocus (selection.Setfocus method) getbeginindex (selection.Getbeginindex ...

  • Page 1072

    1072 actionscript classes an example can also be found in the strings.Fla file in the actionscript samples folder. Typical paths to this folder are: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applications/macromedia fla...

  • Page 1073

    Selection 1073 mouse.Addlistener(mouselistener); function getcaretpos() { pos_txt.Text = selection.Getcaretindex(); } the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthm...

  • Page 1074

    1074 actionscript classes // convert the selected text to upper case. Tempstring += target.Text.Substring(beginindex, endindex).Touppercase(); break; case 'lowercase...' : tempstring += target.Text.Substring(beginindex, endindex).Tolowercase(); break; } // append the text after the selected text to ...

  • Page 1075

    Selection 1075 example the following example displays the currently focused selection's target path in a textarea component instance. Add several component instances or button, text field and movie clip instances to the stage. Add several component instances or button, text field and movie clip inst...

  • Page 1076

    1076 actionscript classes example the following example demonstrates how to determine when input focus changes in a swf file between several dynamically created text fields. Enter the following actionscript into a fla or as file and then test the document: this.Createtextfield("one_txt", 1, 0, 0, 10...

  • Page 1077

    Selection 1077 parameters listener:object - the object that will no longer receive focus notifications. Returns boolean - if listener was successfully removed, the method returns a true value. If listener was not successfully removed--for example, if listener was not on the selection object's listen...

  • Page 1078

    1078 actionscript classes availability: actionscript 1.0; flash player 5 - instance names for buttons and movie clips work only in flash player 6 and later. Parameters newfocus:object - an object such as a button, movie clip or text field instance, or a string specifying the path to a button, movie ...

  • Page 1079

    Selection 1079 return false; } if (password_txt.Text.Length == 0) { status_txt.Text = "fill in password"; selection.Setfocus("password_txt"); return false; } status_txt.Text = "success!"; selection.Setfocus(null); return true; } the movieclip.Getnexthighestdepth() method used in this example require...

  • Page 1080

    1080 actionscript classes the following example illustrates how the endindex parameter is not inclusive. In order to select the first character, you must use an endindex of 1, not 0. If you change the endindex parameter to 0, nothing will be selected. This.Createtextfield("mytext_txt", 99, 10, 10, 2...

  • Page 1081

    Sharedobject 1081 local shared objects maintain local persistence. For example, you can call sharedobject.Getlocal() to create a shared object that contains the high score in a game. Because the shared object is locally persistent, flash saves its data attributes on the user's computer when the game...

  • Page 1082

    1082 actionscript classes if your swf file attempts to create or modify local shared objects, make sure that your swf file is at least 215 pixels wide and at least 138 pixels high (the minimum dimensions for displaying the dialog box that prompts users to increase their local shared object storage l...

  • Page 1083

    Sharedobject 1083 method summary methods inherited from class object clear (sharedobject.Clear method) public clear() : void purges all the data from the shared object and deletes the shared object from the disk. The reference to my_so is still active, and my_so is now empty. Availability: actionscr...

  • Page 1084

    1084 actionscript classes for (var prop in my_so.Data) { trace("\t"+prop); } this actionscript displays the following message in the output panel: before my_so.Clear(): name after my_so.Clear(): data (sharedobject.Data property) public data : object the collection of attributes assigned to the data ...

  • Page 1085

    Sharedobject 1085 to create private values for a shared object--values that are available only to the client instance while the object is in use and are not stored with the object when it is closed--create properties that are not named data to store them, as shown in the following example: var my_so...

  • Page 1086

    1086 actionscript classes if this method returns "pending" , flash player shows a dialog box asking the user to increase the amount of disk space available to objects from this domain. To allow space for the shared object to grow when it is saved in the future, which avoids return values of "pending...

  • Page 1087

    Sharedobject 1087 example the following function gets a shared object, my_so, and fills writable properties with user- provided settings. Finally, flush() is called to save the settings and allot a minimum of 1000 bytes of disk space. This.Syncsettingscore = function(soname:string, override:boolean,...

  • Page 1088

    1088 actionscript classes to avoid name collisions, flash looks at the location of the swf file that is creating the shared object. For example, if a swf file at www.Mycompany.Com/apps/stockwatcher.Swf creates a shared object named portfolio , that shared object does not conflict with another object...

  • Page 1089

    Sharedobject 1089 if you publish swf file content to be played back as local files (either locally installed swf files or projectors [exe]), and you need to access a specific shared object from more than one local swf file, be aware that for local files, two different locations may be used to store ...

  • Page 1090

    1090 actionscript classes if your swf file is delivered over a non-https connection and you try to set this parameter to true , the creation of a new shared object (or the access of a previously created secure shared object) fails and null is returned. Regardless of the value of this parameter, the ...

  • Page 1091

    Sharedobject 1091 // assign an empty string to mytext_ti if the shared object is undefined // to prevent the text input box from displaying "undefined" when // this script is first run. If (mytext_ti.Text == undefined) { mytext_ti.Text = ""; } // create a listener object and function for event var t...

  • Page 1092

    1092 actionscript classes example the following example gets the size of the shared object my_so : var items_array:array = new array(101, 346, 483); var currentuserisadmin:boolean = true; var currentusername:string = "ramona"; var my_so:sharedobject = sharedobject.Getlocal("superfoo"); my_so.Data.It...

  • Page 1093

    Sharedobject 1093 parameters infoobject:object - a parameter defined according to the status message. Example the following example displays different messages based on whether the user chooses to allow or deny the sharedobject object instance to write to the disk. Var message_str:string; this.Creat...

  • Page 1094

    1094 actionscript classes the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also getlocal (share...

  • Page 1095

    Sound 1095 event summary constructor summary method summary event description onid3 = function() {} invoked each time new id3 data is available for an mp3 file that you load using sound.Attachsound() or sound.Loadsound(). Onload = function(success :boolean) {} invoked automatically when a sound load...

  • Page 1096

    1096 actionscript classes methods inherited from class object attachsound (sound.Attachsound method) public attachsound(id:string) : void attaches the sound specified in the id parameter to the specified sound object. The sound must be in the library of the current swf file and specified for export ...

  • Page 1097

    Sound 1097 example the following example attaches the sound logoff_id to my_sound . A sound in the library has the linkage identifier logoff_id . Var my_sound:sound = new sound(); my_sound.Attachsound("logoff_id"); my_sound.Start(); duration (sound.Duration property) public duration : number [read-o...

  • Page 1098

    1098 actionscript classes pb._y = 100; with (pb.Bar_mc) { beginfill(0x00ff00); moveto(0, 0); lineto(pb_width, 0); lineto(pb_width, pb_height); lineto(0, pb_height); lineto(0, 0); endfill(); _xscale = 0; } with (pb.Vbar_mc) { linestyle(1, 0x000000); moveto(0, 0); lineto(0, pb_height); } with (pb.Stro...

  • Page 1099

    Sound 1099 see also position (sound.Position property) getbytesloaded (sound.Getbytesloaded method) public getbytesloaded() : number returns the number of bytes loaded (streamed) for the specified sound object. You can compare the value of getbytesloaded() with the value of getbytestotal() to determ...

  • Page 1100

    1100 actionscript classes var pos:number = math.Round(the_sound.Position/the_sound.Duration 100); status_txt.Text = the_sound.Getbytesloaded()+" of "+the_sound.Getbytestotal()+" bytes ("+pct+"%)"+newline; status_txt.Text += the_sound.Position+" of "+the_sound.Duration+" milliseconds ("+pos+"%)"+newl...

  • Page 1101

    Sound 1101 example the following example creates a slider bar using the drawing api. When the user drags the slider bar, the pan level of the loaded sound changes. The current pan level is displayed in a dynamically created text field. Add the following actionscript to your fla or as file: var bar_w...

  • Page 1102

    1102 actionscript classes my_sound.Loadsound("song2.Mp3", true); this.Createtextfield("pan_txt", this.Getnexthighestdepth(), knob_mc._x, knob_mc._y+knob_mc._height, 20, 22); pan_txt.Selectable = false; pan_txt.Autosize = "center"; pan_txt.Text = my_sound.Getpan(); the movieclip.Getnexthighestdepth()...

  • Page 1103

    Sound 1103 var knob_lr:movieclip = transform_mc.Attachmovie("knob_id", "lr_mc", transform_mc.Getnexthighestdepth(), {_x:30, _y:30}); var knob_rl:movieclip = transform_mc.Attachmovie("knob_id", "rl_mc", transform_mc.Getnexthighestdepth(), {_x:60, _y:30}); var knob_rr:movieclip = transform_mc.Attachmo...

  • Page 1104

    1104 actionscript classes this.Stopdrag(); updatetransformtxt(); } function updatetransformtxt() { var ll_num:number = 30+100-knob_ll._y; var lr_num:number = 30+100-knob_lr._y; var rl_num:number = 30+100-knob_rl._y; var rr_num:number = 30+100-knob_rr._y; my_sound.Settransform({ll:ll_num, lr:lr_num, ...

  • Page 1105

    Sound 1105 knob_mc.Top = knob_mc._y; knob_mc.Bottom = knob_mc._y; knob_mc._x = my_sound.Getvolume(); with (knob_mc) { linestyle(0, 0x000000); beginfill(0xcccccc); moveto(0, 0); lineto(4, 0); lineto(4, 18); lineto(0, 18); lineto(0, 0); endfill(); } knob_mc.Createtextfield("volume_txt", knob_mc.Getnex...

  • Page 1106

    1106 actionscript classes id3 (sound.Id3 property) public id3 : object [read-only] provides access to the metadata that is part of an mp3 file. Mp3 sound files can contain id3 tags, which provide metadata about the file. If an mp3 sound that you load using sound.Attachsound() or sound.Loadsound() co...

  • Page 1107

    Sound 1107 flash player 6 supported several id31.0 tags. If these tags are in not in the mp3 file, but corresponding id3 2.0 tags are, the id3 2.0 tags are copied into the id3 1.0 properties, as shown in the following table. This process provides backward compatibility with scripts that you may have...

  • Page 1108

    1108 actionscript classes example the following example traces the id3 properties of song.Mp3 to the output panel: var my_sound:sound = new sound(); my_sound.Onid3 = function(){ for( var prop in my_sound.Id3 ){ trace( prop + " : "+ my_sound.Id3[prop] ); } } my_sound.Loadsound("song.Mp3", false); see...

  • Page 1109

    Sound 1109 ■ the flash player 8 security-related api white paper at http://www.Macromedia.Com/go/ fp8_security_apis availability: actionscript 1.0; flash player 6 parameters url:string - the location on a server of an mp3 sound file. Isstreaming:boolean - a boolean value that indicates whether the s...

  • Page 1110

    1110 actionscript classes property_dgc.Width = 100; property_dgc.Headertext = "id3 property"; var value_dgc:datagridcolumn = id3_dg.Addcolumn(new datagridcolumn("value")); value_dgc.Width = id3_dg._width-property_dgc.Width; value_dgc.Headertext = "id3 value"; var my_sound:sound = new sound(); my_sou...

  • Page 1111

    Sound 1111 var my_sound:sound = new sound(); // if the sound loads, play it; if not, trace failure loading my_sound.Onload = function(success:boolean) { if (success) { my_sound.Start(); status_txt.Text = "sound loaded"; } else { status_txt.Text = "sound failed"; } }; // load the sound my_sound.Loads...

  • Page 1112

    1112 actionscript classes my_sound.Attachsound("mysoundid"); my_sound.Onsoundcomplete = callback1; my_sound.Start(); see also onload (sound.Onload handler) position (sound.Position property) public position : number [read-only] the number of milliseconds a sound has been playing. If the sound is loo...

  • Page 1113

    Sound 1113 see also attachsound (sound.Attachsound method) , getpan (sound.Getpan method) , settransform (sound.Settransform method) , setvolume (sound.Setvolume method) , start (sound.Start method) settransform (sound.Settransform method) public settransform(transformobject:object) : void sets the ...

  • Page 1114

    1114 actionscript classes mono sounds play all sound input in the left speaker and have the following transform settings by default: ll = 100 lr = 100 rr = 0 rl = 0 availability: actionscript 1.0; flash player 5 parameters transformobject:object - an object created with the constructor for the gener...

  • Page 1115

    Sound 1115 var mysoundtransformobjecthalf:object = {ll:50, lr:0, rr:100, rl:50}; also see the example for sound.Gettransform() . See also object , gettransform (sound.Gettransform method) setvolume (sound.Setvolume method) public setvolume(value:number) : void sets the volume for the sound object. A...

  • Page 1116

    1116 actionscript classes the following example creates a new sound object, passes it the target movie clip my_mc , and calls the start method, which starts any sound in my_mc . Var movie_sound:sound = new sound(my_mc); movie_sound.Start(); start (sound.Start method) public start([secondoffset:numbe...

  • Page 1117

    Sound 1117 the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also stop (sound.Stop method) stop ...

  • Page 1119

    Stage 1119 method summary methods inherited from class object addlistener (stage.Addlistener method) public static addlistener(listener:object) : void detects when a swf file is resized (but only if stage.Scalemode = "noscale" ). The addlistener() method doesn't work with the default movie clip scal...

  • Page 1120

    1120 actionscript classes stagelistener.Onresize = function() { stagesize_txt.Text = "w:"+stage.Width+", h:"+stage.Height; }; stage.Scalemode = "noscale"; stage.Addlistener(stagelistener); see also onresize (stage.Onresize event listener) , removelistener (stage.Removelistener method) align (stage.A...

  • Page 1121

    Stage 1121 example the following example demonstrates different alignments of the swf file. Add a combobox instance to your document with the instance name stagealign_cb . Add the following actionscript to your fla or as file: var stagealign_cb:mx.Controls.Combobox; stagealign_cb.Dataprovider = ['t'...

  • Page 1122

    1122 actionscript classes onresize (stage.Onresize event listener) onresize = function() {} invoked when stage.Scalemode is set to noscale and the swf file is resized. You can use this event handler to write a function that lays out the objects on the stage when a swf file is resized. Mylistener.Onr...

  • Page 1123

    Stage 1123 example the following example displays the stage dimensions in a dynamically created text field. When you resize the stage, the values in the text field update. Create a button with an instance name remove_btn . Add the following actionscript to frame 1 of the timeline. This.Createtextfie...

  • Page 1124

    1124 actionscript classes ■ noscale makes the size of the flash content fixed, so that it remains unchanged even as the size of the player window changes. Cropping may occur if the player window is smaller than the flash content. Availability: actionscript 1.0; flash player 6 example the following e...

  • Page 1125

    Stage 1125 example the following example creates a clickable text link that lets the user enable and disable the flash player context menu. This.Createtextfield("showmenu_txt", this.Getnexthighestdepth(), 10, 10, 100, 22); showmenu_txt.Html = true; showmenu_txt.Autosize = true; showmenu_txt.Htmltext...

  • Page 1127

    String 1127 property summary properties inherited from class object constructor summary method summary modifiers property description length :number an integer specifying the number of characters in the specified string object. Constructor (object.Constructor property) , __proto__ (object.__proto__ ...

  • Page 1128

    1128 actionscript classes methods inherited from class object charat (string.Charat method) public charat(index:number) : string returns the character in the position specified by the parameter index . If index is not a number from 0 to string.Length - 1, an empty string is returned. This method is ...

  • Page 1129

    String 1129 returns string - the character at the specified index. Or an empty string if the specified index is outside the range of this string 's indeces. Example in the following example, this method is called on the first letter of the string " chris ": var my_str:string = "chris"; var firstchar...

  • Page 1130

    1130 actionscript classes concat (string.Concat method) public concat(value:object) : string combines the value of the string object with the parameters and returns the newly formed string; the original value, my_str , is unchanged. Availability: actionscript 1.0; flash player 5 parameters value:obj...

  • Page 1131

    String 1131 indexof (string.Indexof method) public indexof(value:string, [startindex:number]) : number searches the string and returns the position of the first occurrence of value found at or after startindex within the calling string. This index is zero-based, meaning that the first character in a...

  • Page 1132

    1132 actionscript classes lastindexof (string.Lastindexof method) public lastindexof(value:string, [startindex:number]) : number searches the string from right to left and returns the index of the last occurrence of value found before startindex within the calling string. This index is zero-based, m...

  • Page 1133

    String 1133 length (string.Length property) public length : number an integer specifying the number of characters in the specified string object. Because all string indexes are zero-based, the index of the last character for any string x is x.Length - 1 . Availability: actionscript 1.0; flash player...

  • Page 1134

    1134 actionscript classes slice (string.Slice method) public slice(start:number, end:number) : string returns a string that includes the start character and all characters up to, but not including, the end character. The original string object is not modified. If the end parameter is not specified, ...

  • Page 1135

    String 1135 trace("slice(1,1): "+my_str.Slice(1, 1)); // slice(1,1): trace("slice(3,2): "+my_str.Slice(3, 2)); // slice(3,2): trace("slice(-2,2): "+my_str.Slice(-2, 2)); // slice(-2,2): // slices that omit the end parameter use string.Length, which equals 5 trace("slice(0): "+my_str.Slice(0)); // sl...

  • Page 1136

    1136 actionscript classes trace(my_array[i]); } // output: p a t s y the following example returns an array with two elements, "p" and "a" : var my_str:string = "p,a,t,s,y"; var my_array:array = my_str.Split(",", 2); trace(my_array); // output: p,a the following example shows that if you use an empt...

  • Page 1137

    String 1137 availability: actionscript 1.0; flash player 5 parameters value:string - the initial value of the new string object. Substr (string.Substr method) public substr(start:number, length:number) : string returns the characters in a string from the index specified in the start parameter throug...

  • Page 1138

    1138 actionscript classes an example is also in the strings.Fla file in the actionscript samples folder. The following list gives typical paths to this folder: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applications/mac...

  • Page 1139

    String 1139 the following example shows what happens if a negative start parameter is used: var my_str:string = "hello world"; var mysubstring:string = my_str.Substring(-5,5); trace(mysubstring); // output: hello an example is also in the strings.Fla file in the actionscript samples folder. The foll...

  • Page 1140

    1140 actionscript classes tostring (string.Tostring method) public tostring() : string returns an object's properties as strings regardless of whether the properties are strings. Availability: actionscript 1.0; flash player 5 returns string - the string. Example the following example outputs an uppe...

  • Page 1141

    String 1141 example the following example creates a string with all lowercase characters and then creates a copy of that string using touppercase() : var lowercase:string = "lorem ipsum dolor"; var uppercase:string = lowercase.Touppercase(); trace("lowercase: " + lowercase); // output: lowercase: lo...

  • Page 1143

    Stylesheet (textfield.Stylesheet) 1143 availability: actionscript 1.0; flash player 7 font-size fontsize only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. Font-style fontstyle recognized values are normal and italic. Font-weight fontweight r...

  • Page 1144

    1144 actionscript classes property summary properties inherited from class object event summary constructor summary method summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) event d...

  • Page 1145

    Stylesheet (textfield.Stylesheet) 1145 methods inherited from class object clear (stylesheet.Clear method) public clear() : void removes all styles from the specified stylesheet object. Availability: actionscript 1.0; flash player 7 example the following example loads a stylesheet called styles.Css ...

  • Page 1146

    1146 actionscript classes } trace(""); }; getstyle (stylesheet.Getstyle method) public getstyle(name:string) : object returns a copy of the style object associated with the specified style ( name ). If there is no style object associated with name , the method returns null . Availability: actionscri...

  • Page 1147

    Stylesheet (textfield.Stylesheet) 1147 trace("this is an empty style sheet."); } else { for (var i = 0; i var stylename:string = stylenames[i]; trace("style "+stylename+":"); var styleobject:object = my_stylesheet.Getstyle(stylename); for (var propname in styleobject) { var propvalue = styleobject[p...

  • Page 1148

    1148 actionscript classes getstylenames (stylesheet.Getstylenames method) public getstylenames() : array returns an array that contains the names (as strings) of all of the styles registered in this style sheet. Availability: actionscript 1.0; flash player 7 returns array - an array of style names (...

  • Page 1149

    Stylesheet (textfield.Stylesheet) 1149 returns boolean - false if no parameter ( null ) is passed; true otherwise. Use the onload() callback handler to check the success of a loaded stylesheet. Example for an example of asynchronously loading style sheets using actionscript 2.0, see the example for ...

  • Page 1150

    1150 actionscript classes parameters success:boolean - a boolean value that indicates whether the css file loaded successfully ( true ) or not ( false ). Example the following example loads the css file named styles.Css into the stylesheet object my_stylesheet . When the file has finished loading su...

  • Page 1151

    Stylesheet (textfield.Stylesheet) 1151 parameters csstext:string - the css text to parse. Returns boolean - a boolean value that indicates whether the text was parsed successfully ( true ) or not ( false ). Example the following example parses the css in css_str . The script displays information abo...

  • Page 1152

    1152 actionscript classes parameters name:string - the name of the style to add to the stylesheet. Style:object - an object that describes the style, or null . Example the following example adds a style named emphasized to the stylesheet mystylesheet . The style includes two style properties: color ...

  • Page 1153

    Stylesheet (textfield.Stylesheet) 1153 stylesheet constructor public stylesheet() creates a stylesheet object. Availability: actionscript 1.0; flash player 7 example the following example loads in a style sheet and traces the styles that load into the document. Add the following actionscript to your...

  • Page 1154

    1154 actionscript classes parameters style:object - an object that describes the style, containing style rules as properties of the object, or null . Returns textformat - a textformat object containing the result of the mapping of css rules to text format properties. Example the following example ex...

  • Page 1155

    System 1155 property summary properties inherited from class object event summary method summary methods inherited from class object modifiers property description static exactsettings :boolea n a boolean value that specifies whether to use superdomain (false) or exact domain (true) matching rules w...

  • Page 1156

    1156 actionscript classes exactsettings (system.Exactsettings property) public static exactsettings : boolean a boolean value that specifies whether to use superdomain ( false ) or exact domain ( true ) matching rules when accessing local settings (such as camera or microphone access permissions) or...

  • Page 1157

    System 1157 usually you should find that the default value of system.Exactsettings is fine. Often your only requirement is that when a swf file saves a shared object in one session, the same swf file can retrieve the same shared object in a later session. This situation will always be true, regardle...

  • Page 1158

    1158 actionscript classes in addition to these specific onstatus methods, flash also provides a super function called system.Onstatus , which serves as a secondary error message handler. If an instance of the localconnection, netstream, or sharedobject class passes an information object with a level...

  • Page 1159

    System 1159 setclipboard (system.Setclipboard method) public static setclipboard(text:string) : void replaces the contents of the clipboard with a specified text string. Availability: actionscript 1.0; flash player 7 - swf files published for flash player 6 or later, playing in flash player 7 or lat...

  • Page 1160

    1160 actionscript classes showsettings (system.Showsettings method) public static showsettings([tabid:number]) : void shows the specified flash player settings panel. The panel lets users do any of the following actions: ■ allow or deny access to the camera and microphone ■ specify the local disk sp...

  • Page 1161

    System 1161 usecodepage (system.Usecodepage property) public static usecodepage : boolean a boolean value that tells flash player whether to use unicode or the traditional code page of the operating system running the player to interpret external text files. The default value of system.Usecodepage i...

  • Page 1163

    Textfield 1163 autosize :object controls automatic sizing and alignment of text fields. Background :boolean specifies if the text field has a background fill. Backgroundcolor :numb er the color of the text field background. Border :boolean specifies if the text field has a border. Bordercolor :numbe...

  • Page 1164

    1164 actionscript classes maxscroll :number [read-only] indicates the maximum value of textfield.Scroll. Menu :contextmenu associates the contextmenu object contextmenu with the text field my_txt. Mousewheelenabled :bo olean a boolean value that indicates whether flash player should automatically sc...

  • Page 1165

    Textfield 1165 textcolor :number indicates the color of the text in a text field. Textheight :number indicates the height of the text. Textwidth :number indicates the width of the text. Thickness :number the thickness of the glyph edges in this textfield instance. Type :string specifies the type of ...

  • Page 1166

    1166 actionscript classes properties inherited from class object event summary method summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) event description onchanged = function(chang...

  • Page 1167

    Textfield 1167 methods inherited from class object addlistener (textfield.Addlistener method) public addlistener(listener:object) : boolean registers an object to receive textfield event notifications. The object will receive event notifications whenever the onchanged and onscroller event handlers h...

  • Page 1168

    1168 actionscript classes a reference to the text field instance is passed as a parameter to the onscroller and onchanged handlers by the event source. You can capture this data by putting a parameter in the event handler method. For example, the following code uses txt as the parameter that is pass...

  • Page 1169

    Textfield 1169 see also onchanged (textfield.Onchanged handler) , onscroller (textfield.Onscroller handler) , removelistener (textfield.Removelistener method) _alpha (textfield._alpha property) public _alpha : number sets or retrieves the alpha transparency value of the text field. Valid values are ...

  • Page 1170

    1170 actionscript classes antialiastype (textfield.Antialiastype property) public antialiastype : string the type of anti-aliasing used for this textfield instance. Advanced anti-aliasing is available only in flash player 8 and later. You can control this setting only if the font is embedded (with t...

  • Page 1171

    Textfield 1171 my_text1.Embedfonts = true; my_text1.Settextformat(my_format); var my_text2:textfield = this.Createtextfield("my_text2", this.Getnexthighestdepth(), 10, 50, 300, 30); my_text2.Text = "this text uses normal anti-aliasing." my_text2.Antialiastype = "normal"; my_text2.Border = true; my_t...

  • Page 1172

    1172 actionscript classes if autosize is set to "center" , then the text is treated as center-justified text, meaning any resizing of a single line text field will be equally distributed to both the right and left sides. If the text includes a line break (for example, "" or "\r") , then the bottom...

  • Page 1173

    Textfield 1173 false_txt.Text = "this is much longer text"; }; // register the listener object with the mouse object mouse.Addlistener(mymouselistener); background (textfield.Background property) public background : boolean specifies if the text field has a background fill. If true , the text field ...

  • Page 1174

    1174 actionscript classes see also background (textfield.Background property) border (textfield.Border property) public border : boolean specifies if the text field has a border. If true , the text field has a border. If false , the text field has no border. Availability: actionscript 1.0; flash pla...

  • Page 1175

    Textfield 1175 see also border (textfield.Border property) bottomscroll (textfield.Bottomscroll property) public bottomscroll : number [read-only] an integer (one-based index) that indicates the bottommost line that is currently visible the text field. Think of the text field as a window onto a bloc...

  • Page 1176

    1176 actionscript classes condensewhite (textfield.Condensewhite property) public condensewhite : boolean a boolean value that specifies whether extra white space (spaces, line breaks, and so on) in an html text field should be removed when the field is rendered in a browser. The default value is fa...

  • Page 1177

    Textfield 1177 embedfonts (textfield.Embedfonts property) public embedfonts : boolean specifies whether to render using embedded font outlines. A boolean value that, when true , renders the text field using embedded font outlines. If false , it renders the text field using device fonts. If you set e...

  • Page 1178

    1178 actionscript classes filters can be applied in the flash authoring tool at design-time, or at runtime using actionscript code. To apply a filter using actionscript, you must make a temporary copy of the entire textfield.Filters array, modify the temporary array, and then assign the value of the...

  • Page 1179

    Textfield 1179 mytextfield.Filters = myfilters; the following example changes the quality setting of the first filter in the array to 15 (this example works only if at least one filter object has been associated with the mytextfield text field). Var mylist:array = mytextfield.Filters; mylist[0].Qual...

  • Page 1180

    1180 actionscript classes getfontlist (textfield.Getfontlist method) public static getfontlist() : array returns the names of fonts on the player's host system as an array. (this method does not return names of all fonts in currently loaded swf files.) the names are of type string . This method is a...

  • Page 1181

    Textfield 1181 trace("textformat has the following properties:"); for (var prop in my_fmt) { trace(prop+": "+my_fmt[prop]); } the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 component...

  • Page 1182

    1182 actionscript classes returns textformat - the textformat object that represents the formatting properties for the specified text. Example the following actionscript code traces all of the formatting information for a text field that is created at runtime. This.Createtextfield("dyn_txt", this.Ge...

  • Page 1183

    Textfield 1183 availability: actionscript 1.0; flash player 8 example this example shows three text fields that use the different gridfittype settings. It assumes that you have a font embedded in the library with the linkage identifier set to "times-12" . To embed the font, follow these steps: ■ ope...

  • Page 1184

    1184 actionscript classes my_text2.Text = "this.Gridfittype = advanced"; my_text2.Embedfonts = true; my_text2.Antialiastype = "advanced"; my_text2.Gridfittype = "pixel"; my_text2.Settextformat(my_format); var my_text3:textfield = this.Createtextfield("my_text3", this.Getnexthighestdepth(), 9.5, 70, ...

  • Page 1185

    Textfield 1185 availability: actionscript 1.0; flash player 6 see also _quality (textfield._quality property) hscroll (textfield.Hscroll property) public hscroll : number indicates the current horizontal scrolling position. If the hscroll property is 0, the text is not horizontally scrolled. The uni...

  • Page 1186

    1186 actionscript classes example the following example scrolls the my_txt text field horizontally using two buttons called scrollleft_btn and scrollright_btn . The amount of scroll displays in a text field called scroll_txt . Add the following actionscript to your fla or as file: this.Createtextfie...

  • Page 1187

    Textfield 1187 my_txt.Html = true; my_txt.Htmltext = " this is bold text "; the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getn...

  • Page 1188

    1188 actionscript classes example the following example outputs the number of characters in the date_txt text field, which displays the current date. Var today:date = new date(); this.Createtextfield("date_txt", this.Getnexthighestdepth(), 10, 10, 100, 22); date_txt.Autosize = true; date_txt.Text = ...

  • Page 1189

    Textfield 1189 example see the example for textfield.Hscroll . Maxscroll (textfield.Maxscroll property) public maxscroll : number [read-only] indicates the maximum value of textfield.Scroll . Availability: actionscript 1.0; flash player 6 example the following example sets the maximum value for the ...

  • Page 1190

    1190 actionscript classes this property works only with selectable (editable) text fields; it has no effect on nonselectable text fields. Availability: actionscript 1.0; flash player 7 example the following example assigns the contextmenu object menu_cm to the text field news_txt . The contextmenu o...

  • Page 1191

    Textfield 1191 mousewheelenabled (textfield.Mousewheelenabled property) public mousewheelenabled : boolean a boolean value that indicates whether flash player should automatically scroll multiline text fields when the mouse pointer clicks a text field and the user rolls the mouse wheel. By default, ...

  • Page 1192

    1192 actionscript classes multiline (textfield.Multiline property) public multiline : boolean indicates whether the text field is a multiline text field. If the value is true , the text field is multiline; if the value is false , the text field is a single-line text field. Availability: actionscript...

  • Page 1193

    Textfield 1193 when you test the document, the instance name and depth is displayed in the output panel. The movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class ...

  • Page 1194

    1194 actionscript classes onkillfocus (textfield.Onkillfocus handler) onkillfocus = function(newfocus:object) {} invoked when a text field loses keyboard focus. The onkillfocus method receives one parameter, newfocus , which is an object representing the new object receiving the focus. If no object ...

  • Page 1195

    Textfield 1195 mytextfield.Onscroller = function (my_txt:textfield) { trace (my_txt._name + " scrolled"); }; the textfield.Onscroller event handler is commonly used to implement scroll bars. Scroll bars typically have a thumb or other indicator that shows the current horizontal or vertical scrolling...

  • Page 1196

    1196 actionscript classes scrolldown_btn.Onrelease = function() { my_txt.Scroll++; }; my_txt.Onscroller = function() { trace("onscroller called"); scroll_txt.Text = my_txt.Scroll+" of "+my_txt.Maxscroll; }; the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or la...

  • Page 1197

    Textfield 1197 _parent (textfield._parent property) public _parent : movieclip a reference to the movie clip or object that contains the current text field or object. The current object is the one containing the actionscript code that references _parent . Use _parent to specify a relative path to mo...

  • Page 1198

    1198 actionscript classes password (textfield.Password property) public password : boolean specifies whether the text field is a password text field. If the value of password is true , the text field is a password text field and hides the input characters using asterisks instead of the actual charac...

  • Page 1199

    Textfield 1199 _quality (textfield._quality property) public _quality : string the rendering quality used for a swf file. Device fonts are always aliased and, therefore, are unaffected by the _quality property. The _quality property can be set to the following values: ■ " low " low rendering quality...

  • Page 1200

    1200 actionscript classes returns boolean - if listener was successfully removed, the method returns a true value. If listener was not successfully removed (for example, if listener was not on the textfield object's listener list), the method returns a value of false . Example the following example ...

  • Page 1201

    Textfield 1201 example the following example creates a text field that you can remove from the stage when you click the remove_btn instance. Create a button and call it remove_btn , and then add the following actionscript to your fla or as file. This.Createtextfield("my_txt", this.Getnexthighestdept...

  • Page 1202

    1202 actionscript classes my_txt.Multiline = true; my_txt.Type = "input"; my_txt.Text = "select some sample text from the text field and then right- click/control click " + "and select 'enter current date' from the context menu to replace the " + "currently selected text with the current date."; var...

  • Page 1203

    Textfield 1203 example the following example creates a text field called my_txt and assigns the text dog@house.Net to the field. The indexof() method is used to find the first occurrence of the specified symbol ( @ ). If the symbol is found, the specified text (between the index of 0 and the symbol)...

  • Page 1204

    1204 actionscript classes example the following example allows only uppercase characters, spaces, and numbers to be entered into a text field: my_txt.Restrict = "a-z 0-9"; the following example includes all characters, but excludes lowercase letters: my_txt.Restrict = "^a-z"; you can use a backslash...

  • Page 1205

    Textfield 1205 this.Createtextfield("my_txt", this.Getnexthighestdepth(), 10, 10, 160, 120); my_txt.Wordwrap = true; my_txt.Embedfonts = true; my_txt.Text = "hello world"; my_txt.Settextformat(my_fmt); my_txt._rotation = 45; apply additional formatting for the text field using the textformat class ....

  • Page 1206

    1206 actionscript classes my_txt.Wordwrap = true; for (var i = 0; i my_txt.Text += "lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy " + "nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."; } scrollup_btn.Onrelease = function() { my_txt.Scroll--; scroll_...

  • Page 1207

    Textfield 1207 this.Createtextfield("date_txt", this.Getnexthighestdepth(), 10, 10, 100, 22); date_txt.Autosize = true; date_txt.Selectable = true; var date_interval:number = setinterval(updatetime, 500, date_txt); function updatetime(my_txt:textfield) { my_txt.Text = new date().Tostring(); } the mo...

  • Page 1208

    1208 actionscript classes see also getnewtextformat (textfield.Getnewtextformat method) , gettextformat (textfield.Gettextformat method) , settextformat (textfield.Settextformat method) settextformat (textfield.Settextformat method) public settextformat([beginindex:number], [endindex:number], textfo...

  • Page 1209

    Textfield 1209 notice that any text inserted manually by the user, or replaced by means of textfield.Replacesel() , receives the text field's default formatting for new text, and not the formatting specified for the text insertion point. To set a text field's default formatting for new text, use tex...

  • Page 1210

    1210 actionscript classes see also textformat , setnewtextformat (textfield.Setnewtextformat method) sharpness (textfield.Sharpness property) public sharpness : number the sharpness of the glyph edges in this textfield instance. This property applies only if the antialiastype property of the text fi...

  • Page 1211

    Textfield 1211 my_text2.Embedfonts = true; my_text2.Antialiastype = "advanced"; my_text2.Gridfittype = "pixel"; my_text2.Sharpness = 0; my_text2.Settextformat(my_format); var my_text3:textfield = this.Createtextfield("my_text3", this.Getnexthighestdepth(), 10, 70, 400, 100); my_text3.Text = "this te...

  • Page 1212

    1212 actionscript classes stylesheet (textfield.Stylesheet property) public stylesheet : stylesheet attaches a style sheet to the text field. For information on creating style sheets, see the textfield.Stylesheet class entry. The style sheet associated with a text field may be changed at any time. I...

  • Page 1213

    Textfield 1213 css2_btn.Onrelease = function() { var styleobj:textfield.Stylesheet = new textfield.Stylesheet(); styleobj.Onload = function(success:boolean) { if (success) { news_txt.Stylesheet = styleobj; news_txt.Htmltext = newstext; } }; styleobj.Load("styles2.Css"); }; clearcss_btn.Onrelease = f...

  • Page 1214

    1214 actionscript classes if your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method, which is used in this example. See also stylesheet (textfield.Stylesheet) tabenabled (textfield.Tabenabled property) publi...

  • Page 1215

    Textfield 1215 the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. See also tabenabled (button.Tabenab...

  • Page 1216

    1216 actionscript classes two_txt.Type = "input"; this.Createtextfield("three_txt", this.Getnexthighestdepth(), 10, 70, 100, 22); three_txt.Border = true; three_txt.Type = "input"; this.Createtextfield("four_txt", this.Getnexthighestdepth(), 10, 100, 100, 22); four_txt.Border = true; four_txt.Type =...

  • Page 1217

    Textfield 1217 text (textfield.Text property) public text : string indicates the current text in the text field. Lines are separated by the carriage return character ("\r", ascii 13). This property contains the normal, unformatted text in the text field, without html tags, even if the text field is ...

  • Page 1218

    1218 actionscript classes availability: actionscript 1.0; flash player 6 example the following actionscript creates a text field and changes its color property to red. This.Createtextfield("my_txt", 99, 10, 10, 100, 300); my_txt.Text = "this will be red text"; my_txt.Textcolor = 0xff0000; the moviec...

  • Page 1219

    Textfield 1219 textwidth (textfield.Textwidth property) public textwidth : number indicates the width of the text. Availability: actionscript 1.0; flash player 6 example see the example for textfield.Textheight . See also textheight (textfield.Textheight property) thickness (textfield.Thickness prop...

  • Page 1220

    1220 actionscript classes var my_text1:textfield = this.Createtextfield("my_text1", this.Getnexthighestdepth(), 10, 10, 300, 30); my_text1.Text = "thickness = 200"; my_text1.Antialiastype = "advanced"; my_text1.Border = true; my_text1.Thickness = 200; my_text1.Embedfonts = true; my_text1.Settextform...

  • Page 1221

    Textfield 1221 this.Createtextfield("password_txt", this.Getnexthighestdepth(), 10, 40, 100, 22); password_txt.Border = true; password_txt.Type = "input"; password_txt.Maxchars = 16; password_txt.Password = true; password_txt.Text = "world"; the movieclip.Getnexthighestdepth() method used in this ex...

  • Page 1222

    1222 actionscript classes example the following example creates a text field called my_txt and associates the variable today_date with the text field. When you change the variable today_date , then the text that displays in my_txt updates. This.Createtextfield("my_txt", 1, 10, 10, 200, 22); my_txt.V...

  • Page 1223

    Textfield 1223 example the following example creates two text fields that you can use to change the width and height of a third text field on the stage. Add the following actionscript to a fla or as file. This.Createtextfield("my_txt", this.Getnexthighestdepth(), 10, 40, 160, 120); my_txt.Background...

  • Page 1224

    1224 actionscript classes wordwrap (textfield.Wordwrap property) public wordwrap : boolean a boolean value that indicates if the text field has word wrap. If the value of wordwrap is true , the text field has word wrap; if the value is false , the text field does not have word wrap. Availability: ac...

  • Page 1225

    Textfield 1225 var mouselistener:object = new object(); mouselistener.Onmousedown = function() { coords_txt.Text = "x:"+math.Round(_xmouse)+", y:"+math.Round(_ymouse); coords_txt._x = _xmouse; coords_txt._y = _ymouse; }; mouse.Addlistener(mouselistener); the movieclip.Getnexthighestdepth() method us...

  • Page 1226

    1226 actionscript classes } mouse.Addlistener(mouselistener); the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdept...

  • Page 1227

    Textfield 1227 _y (textfield._y property) public _y : number the y coordinate of a text field relative to the local coordinates of the parent movie clip. If a text field is in the main timeline, then its coordinate system refers to the upper left corner of the stage as (0, 0). If the text field is i...

  • Page 1229

    Textformat 1229 when textfield.Gettextformat() is invoked, a textformat object is returned with all of its properties defined; no property is null . Availability: actionscript 1.0; flash player 6 see also settextformat (textfield.Settextformat method) , gettextformat (textfield.Gettextformat method)...

  • Page 1230

    1230 actionscript classes properties inherited from class object constructor summary method summary target :string indicates the target window where the hyperlink is displayed. Underline :boolean a boolean value that indicates whether the text that uses this text format is underlined (true) or not (...

  • Page 1231

    Textformat 1231 methods inherited from class object align (textformat.Align property) public align : string a string that indicates the alignment of the paragraph. You can apply this property to static and dynamic text. The following list shows possible values for this property: ■ "left" —the paragr...

  • Page 1232

    1232 actionscript classes the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. Blockindent (textformat....

  • Page 1233

    Textformat 1233 my_txt.Border = true; my_txt.Text = "this is my test field object text"; my_txt.Settextformat(my_fmt); bullet (textformat.Bullet property) public bullet : boolean a boolean value that indicates that the text is part of a bulleted list. In a bulleted list, each paragraph of text is in...

  • Page 1234

    1234 actionscript classes my_txt.Wordwrap = true; my_txt.Border = true; my_txt.Text = "this is my first test field object text"; my_txt.Settextformat(my_fmt); font (textformat.Font property) public font : string the name of the font for text in this text format, as a string. The default value is nul...

  • Page 1235

    Textformat 1235 the width and height measurements provide the width and height of the text string. The textfieldheight and textfieldwidth measurements provide the height and width required for a text field object to display the entire text string. Text fields have a 2-pixel-wide gutter around them, ...

  • Page 1236

    1236 actionscript classes example this example creates a single-line text field that's just big enough to display a text string using the specified formatting. Var my_str:string = "small string"; // create a textformat object, // and apply its properties. Var my_fmt:textformat = new textformat(); wi...

  • Page 1237

    Textformat 1237 my_txt.Wordwrap = true; my_txt.Border = true; // assign the text and the textformat object to the textobject: my_txt.Text = texttodisplay; my_txt.Settextformat(my_fmt); indent (textformat.Indent property) public indent : number an integer that indicates the indentation from the left ...

  • Page 1238

    1238 actionscript classes example the following example creates a text field and sets the text style to italic. This.Createtextfield("mytext",1,100,100,100,100); mytext.Multiline = true; mytext.Wordwrap = true; mytext.Border = true; var myformat:textformat = new textformat(); myformat.Italic = true;...

  • Page 1239

    Textformat 1239 fmt2.Size = 50; fmt2.Color = 0x0000ff; fmt2.Kerning = true; this.Createtextfield("tf1", this.Getnexthighestdepth(), 10, 10, 400, 100); tf1.Embedfonts = true; tf1.Text = "text 7ava-7ava"; tf1.Settextformat(fmt1); this.Createtextfield("tf2", this.Getnexthighestdepth(), 10, 40, 400, 100...

  • Page 1240

    1240 actionscript classes leftmargin (textformat.Leftmargin property) public leftmargin : number the left margin of the paragraph, in points. The default value is null , which indicates that the property is undefined. Availability: actionscript 1.0; flash player 6 example the following example creat...

  • Page 1241

    Textformat 1241 var format2:textformat = new textformat(); format2.Letterspacing = 10; mytext.Text = "eat at joe's."; mytext.Settextformat(0, 7, format1); mytext.Settextformat(8, 12, format2); if your swf file includes a version 2 component, use the version 2 components depthmanager class instead ...

  • Page 1242

    1242 actionscript classes var myformat:textformat = new textformat(); myformat.Size = 20; mytext.Text = "this is my first text field object text"; mytext.Settextformat(myformat); tabstops (textformat.Tabstops property) public tabstops : array specifies custom tab stops as an array of non-negative in...

  • Page 1243

    Textformat 1243 availability: actionscript 1.0; flash player 6 example the following example creates a text field with a hyperlink to the macromedia website. The example uses textformat.Target to display the macromedia website in a new browser window. Var myformat:textformat = new textformat(); myfo...

  • Page 1244

    1244 actionscript classes underline:boolean [optional] - a boolean value that indicates whether the text is underlined. Url:string [optional] - the url to which the text in this text format hyperlinks. If url is an empty string, the text does not have a hyperlink. Target:string [optional] - the targ...

  • Page 1245

    Textformat 1245 underline (textformat.Underline property) public underline : boolean a boolean value that indicates whether the text that uses this text format is underlined ( true ) or not ( false ). This underlining is similar to that produced by the tag, but the latter is not true underlining, be...

  • Page 1247

    Textrenderer (flash.Text.Textrenderer) 1247 properties inherited from class object method summary methods inherited from class object maxlevel (textrenderer.Maxlevel property) public static maxlevel : number the adaptively sampled distance fields (adfs) quality level for advanced anti-aliasing. The ...

  • Page 1248

    1248 actionscript classes example the following example specifies the maxlevel value for the entire swf file, and then displays a text field with the value set. For the text in this example to display correctly, there must be a font symbol available with a linkage identifier of "customfont" . Import...

  • Page 1249

    Textrenderer (flash.Text.Textrenderer) 1249 parameters fontname:string - the name of the font for which you are applying settings. Fontstyle:string - the font style can be "bold" , "bolditalic" , "italic" , and "none" . Colortype:string - this value can be either "dark" or "light" . Advancedantialia...

  • Page 1250

    1250 actionscript classes example the following example creates two anti-alias entries and two text fields to illustrate them. For this example to work, the swf file must have a shared font embedded with a linkage identifier of "myarial" . To embed the font, follow these steps: ■ open your library. ...

  • Page 1252

    1252 actionscript classes method summary modifiers signature description findtext (startindex: number, texttofind:string, casesensitive:boolea n) : number searches the specified textsnapshot object and returns the position of the first occurrence of texttofind found at or after startindex. Getcount ...

  • Page 1253

    Textsnapshot 1253 methods inherited from class object findtext (textsnapshot.Findtext method) public findtext(startindex:number, texttofind:string, casesensitive:boolean) : number searches the specified textsnapshot object and returns the position of the first occurrence of texttofind found at or af...

  • Page 1254

    1254 actionscript classes example the following example illustrates how to use this method. To use this code, place a static text field that contains the text "textsnapshot example" on the stage. Var my_mc:movieclip = this; var my_snap:textsnapshot = my_mc.Gettextsnapshot(); var index1:number = my_s...

  • Page 1255

    Textsnapshot 1255 getselected (textsnapshot.Getselected method) public getselected(start:number, [end:number]) : boolean returns a boolean value that specifies whether a textsnapshot object contains selected text in the specified range. To search all characters, pass a value of 0 for start , and tex...

  • Page 1256

    1256 actionscript classes see also getcount (textsnapshot.Getcount method) , gettext (textsnapshot.Gettext method) , getselectedtext (textsnapshot.Getselectedtext method) , setselected (textsnapshot.Setselected method) getselectedtext (textsnapshot.Getselectedtext method) public getselectedtext([inc...

  • Page 1257

    Textsnapshot 1257 when you test the swf file, a colored rectangle surrounds the specified characters. See also getselected (textsnapshot.Getselected method) , setselected (textsnapshot.Setselected method) gettext (textsnapshot.Gettext method) public gettext(start:number, end:number, [includelineendi...

  • Page 1258

    1258 actionscript classes example the following example illustrates how you can return the number of characters in a specified textsnapshot object. To use this code, place a static text field that contains the text "textsnapshot example" on the stage. Var my_mc:movieclip = this; var my_snap:textsnap...

  • Page 1259

    Textsnapshot 1259 returns array - an array of objects in which each object contains information about a specific character in the specified range. Each object contains the following properties: ■ indexinrun a zero-based integer index of the character (relative to the entire string rather than the se...

  • Page 1260

    1260 actionscript classes trace("matrix_a: " + myarray[i].Matrix_a); trace("matrix_b: " + myarray[i].Matrix_b); trace("matrix_c: " + myarray[i].Matrix_c); trace("matrix_d: " + myarray[i].Matrix_d); trace("matrix_ty: " + myarray[i].Matrix_tx); trace("matrix_tx: " + myarray[i].Matrix_ty); trace(" "); ...

  • Page 1261

    Textsnapshot 1261 see also matrix (flash.Geom.Matrix) hittesttextnearpos (textsnapshot.Hittesttextnearpos method) public hittesttextnearpos(x:number, y:number, [closedist:number]) : number lets you determine which character within a textsnapshot object is on or near the specified x, y coordinates of...

  • Page 1262

    1262 actionscript classes example the following example illustrates how to use this method. To use this code, place a static text field that contains the text "textsnapshot example" on the stage. In the library, include the font used by the static text field, and in linkage options for the font, sel...

  • Page 1263

    Textsnapshot 1263 parameters color:number - the color used for the border placed around characters that have been selected by the corresponding textsnapshot.Setselected() method, expressed in 0xrrggbb format. Example the following example illustrates how to use this method. To use this code, place a...

  • Page 1264

    1264 actionscript classes this method works correctly only with fonts that include character metric information; by default, flash does not include this information for static text fields. Therefore, text that is selected might not appear to be selected onscreen. To ensure that all selected text app...

  • Page 1266

    1266 actionscript classes constructor summary method summary methods inherited from class object colortransform (transform.Colortransform property) public colortransform : colortransform a colortransform object containing values that universally adjust the colors in the movie clip. Availability: act...

  • Page 1267

    Transform (flash.Geom.Transform) 1267 // (redmultiplier=0, greenmultiplier=1, bluemultiplier=1, alphamultiplier=1, redoffset=0, greenoffset=0, blueoffset=255, alphaoffset=0) } function createrectangle(width:number, height:number, color:number, scope:movieclip):movieclip { scope = (scope == undefined...

  • Page 1268

    1268 actionscript classes var parenttrans:transform = new transform(parentrect); var childtrans:transform = new transform(childrect); var bluecolortransform:colortransform = new colortransform(0, 1, 1, 1, 0, 0, 255, 0); parenttrans.Colortransform = bluecolortransform; trace(childtrans.Concatenatedco...

  • Page 1269

    Transform (flash.Geom.Transform) 1269 example the following example applies two transform objects to both a child and parent movieclip object. A scalematrix is then applied to the transform object parenttrans , which scales both parent and child movieclip objects. You can see how child.Concatenatedm...

  • Page 1270

    1270 actionscript classes example the following example applies the matrix object scalematrix to the transform object trans . This matrix scales the movieclip rect by a factor of two. Import flash.Geom.Transform; import flash.Geom.Matrix; var rect:movieclip = createrectangle(20, 80, 0xff0000); var t...

  • Page 1271

    Transform (flash.Geom.Transform) 1271 example the following example creates a transform object trans and traces out its pixelbounds property. Notice that pixelbounds returns a bounding box with values equal to the movieclip object's getbounds() and getrect() methods. Import flash.Geom.Transform; var...

  • Page 1272

    1272 actionscript classes example the following example creates the transform trans and applies it to the movieclip rect. You can see that the transform object's trans and rect.Transform do not evaluate as equals even though they contain the same values. Import flash.Geom.Transform; var rect:moviecl...

  • Page 1274

    1274 actionscript classes a video object can be used like a movie clip. As with other objects you place on the stage, you can control various properties of video objects. For example, you can move the video object around on the stage by using its _x and _y properties, you can change its size using i...

  • Page 1275

    Video 1275 properties inherited from class object method summary _visible :boolean indicates whether the video object specified by my_video is visible. _width :number indicates the width of the video object, in pixels. Width :number [read- only] an integer specifying the width of the video stream, i...

  • Page 1276

    1276 actionscript classes methods inherited from class object _alpha (video._alpha property) public _alpha : number indicates the alpha transparency value of the video object specified. Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a movie clip wi...

  • Page 1277

    Video 1277 parameters source:object - a camera object that is capturing video data or a netstream object. To drop the connection to the video object, pass null for source . Example the following example plays live video locally: var my_video:video; //my_video is a video object on the stage var activ...

  • Page 1278

    1278 actionscript classes see also attachvideo (video.Attachvideo method) deblocking (video.Deblocking property) public deblocking : number indicates the type of deblocking filter applied to decoded video as part of postprocessing. Two deblocking filters are available: one in the sorenson codec and ...

  • Page 1279

    Video 1279 deblocking_cb.Additem({data:1, label:'no'}); deblocking_cb.Additem({data:2, label:'yes'}); var cblistener:object = new object(); cblistener.Change = function(evt:object) { my_video.Deblocking = evt.Target.Selecteditem.Data; }; deblocking_cb.Addeventlistener("change", cblistener); use the ...

  • Page 1280

    1280 actionscript classes netconn.Connect(null); var netstrm:netstream = new netstream(netconn); myvideo.Attachvideo(netstrm); netstrm.Play("video.Flv"); netstrm.Onstatus = function(infoobject:object) { switch (infoobject.Code) { case 'netstream.Play.Start' : case 'netstream.Buffer.Full' : myvideo._...

  • Page 1281

    Video 1281 _rotation (video._rotation property) public _rotation : number indicates the rotation of the video object, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are...

  • Page 1282

    1282 actionscript classes the movieclip.Getnexthighestdepth() method used in this example requires flash player 7 or later. If your swf file includes a version 2 component, use the version 2 components depthmanager class instead of the movieclip.Getnexthighestdepth() method. _visible (video._visible...

  • Page 1283

    Video 1283 _x (video._x property) public _x : number indicates the x coordinate of a video object relative to the local coordinates of the parent movie clip. If a video object is in the main timeline, then its coordinate system refers to the upper left corner of the stage as (0, 0). If the video obj...

  • Page 1284

    1284 actionscript classes _y (video._y property) public _y : number indicates the y coordinate of a video object relative to the local coordinates of the parent movie clip. If a video object is in the main timeline, then its coordinate system refers to the upper left corner of the stage as (0, 0). I...

  • Page 1286

    1286 actionscript classes see also appendchild (xmlnode.Appendchild method) , attributes (xmlnode.Attributes property) , childnodes (xmlnode.Childnodes property) , clonenode (xmlnode.Clonenode method) , firstchild (xmlnode.Firstchild property) , haschildnodes (xmlnode.Haschildnodes method) , insertb...

  • Page 1287

    Xml 1287 properties inherited from class xmlnode properties inherited from class object event summary constructor summary attributes (xmlnode.Attributes property) , childnodes (xmlnode.Childnodes property) , firstchild (xmlnode.Firstchild property) , lastchild (xmlnode.Lastchild property) , localnam...

  • Page 1288

    1288 actionscript classes method summary modifiers signature description addrequestheader (hea der:object, headervalue:string) : void adds or changes http request headers (such as content-type or soapaction) sent with post actions. Createelement (name:s tring) : xmlnode creates a new xml element wit...

  • Page 1289

    Xml 1289 methods inherited from class xmlnode methods inherited from class object addrequestheader (xml.Addrequestheader method) public addrequestheader(header:object, headervalue:string) : void adds or changes http request headers (such as content-type or soapaction ) sent with post actions. In the...

  • Page 1290

    1290 actionscript classes example the following example adds a custom http header named soapaction with a value of foo to an xml object named my_xml : my_xml.Addrequestheader("soapaction", "'foo'"); the following example creates an array named headers that contains two alternating http headers and t...

  • Page 1291

    Xml 1291 createelement (xml.Createelement method) public createelement(name:string) : xmlnode creates a new xml element with the name specified in the parameter. The new element initially has no parent, no children, and no siblings. The method returns a reference to the newly created xml object that...

  • Page 1292

    1292 actionscript classes createtextnode (xml.Createtextnode method) public createtextnode(value:string) : xmlnode creates a new xml text node with the specified text. The new node initially has no parent, and text nodes cannot have children or siblings. This method returns a reference to the xml ob...

  • Page 1293

    Xml 1293 trace(doc); // output (with line breaks added between tags): // // textnode1 string value // textnode2 string value // see also createelement (xml.Createelement method) doctypedecl (xml.Doctypedecl property) public doctypedecl : string specifies information about the xml document's doctype ...

  • Page 1294

    1294 actionscript classes getbytesloaded (xml.Getbytesloaded method) public getbytesloaded() : number returns the number of bytes loaded (streamed) for the xml document. You can compare the value of getbytesloaded() with the value of getbytestotal() to determine what percentage of an xml document ha...

  • Page 1295

    Xml 1295 getbytestotal (xml.Getbytestotal method) public getbytestotal() : number returns the size, in bytes, of the xml document. Availability: actionscript 1.0; flash player 6 returns number - an integer. Example see example for xml.Getbytesloaded() . See also getbytesloaded (xml.Getbytesloaded me...

  • Page 1296

    1296 actionscript classes information technology you must use the parsexml() method on the xml object for the idmap property to be instantiated. If there is more than one xmlnode with the same id value, the matching property of the idnode object is that of the last node parsed, as follows: var x1:xm...

  • Page 1297

    Xml 1297 then you can create a swf file in the same directory as the xml file. You can include the following script in the swf. Var readxml = new xml(); readxml.Load("idmaptest.Xml"); readxml.Onload = function(success) { myxml = new xml(); myxml.Parsexml(readxml); for (var x in myxml.Idmap){ trace('...

  • Page 1298

    1298 actionscript classes availability: actionscript 1.0; flash player 5 example the following example loads an xml file with a text node that contains only white space; the foyer tag comprises fourteen space characters. To run this example, create a text file named flooring.Xml, and copy the follow...

  • Page 1299

    Xml 1299 ceramic tile linoleum the xml_blogtracker.Fla and xml_languagepicker.Fla files in the actionscript samples folder also contain a code example. The following are typical paths to this folder: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ ...

  • Page 1300

    1300 actionscript classes for more information, see the following: ■ chapter 17, "understanding security," in learning actionscript 2.0 in flash ■ the flash player 8 security white paper at http://www.Macromedia.Com/go/fp8_security ■ the flash player 8 security-related api white paper at http://www....

  • Page 1301

    Xml 1301 example the following code example uses the xml.Load() method: // create a new xml object. Var flooring:xml = new xml(); // set the ignorewhite property to true (default value is false). Flooring.Ignorewhite = true; // after loading is complete, trace the xml object. Flooring.Onload = funct...

  • Page 1302

    1302 actionscript classes information is displayed in the output panel when flash invokes the onload() handler. If the call completes successfully, true is displayed for the loaded status in the output panel. Success: true loaded: true status: 0 see also load (xml.Load method) , onload (xml.Onload h...

  • Page 1303

    Xml 1303 see also onload (xml.Onload handler) onhttpstatus (xml.Onhttpstatus handler) onhttpstatus = function(httpstatus:number) {} invoked when flash player receives an http status code from the server. This handler lets you capture and act on http status codes. The onhttpstatus handler is invoked ...

  • Page 1304

    1304 actionscript classes this.Httpstatus = httpstatus; if(httpstatus this.Httpstatustype = "flasherror"; } else if(httpstatus this.Httpstatustype = "informational"; } else if(httpstatus this.Httpstatustype = "successful"; } else if(httpstatus this.Httpstatustype = "redirection"; } else if(httpstatu...

  • Page 1305

    Xml 1305 onload (xml.Onload handler) onload = function(success:boolean) {} invoked by flash player when an xml document is received from the server. If the xml document is received successfully, the success parameter is true . If the document was not received, or if an error occurred in receiving th...

  • Page 1306

    1306 actionscript classes see also load (xml.Load method) , sendandload (xml.Sendandload method) , function statement parsexml (xml.Parsexml method) public parsexml(value:string) : void parses the xml text specified in the value parameter, and populates the specified xml object with the resulting xm...

  • Page 1307

    Xml 1307 for more information, see the following: ■ chapter 17, "understanding security," in learning actionscript 2.0 in flash ■ the flash player 8 security white paper at http://www.Macromedia.Com/go/fp8_security ■ the flash player 8 security-related api white paper at http://www.Macromedia.Com/go...

  • Page 1308

    1308 actionscript classes sendandload (xml.Sendandload method) public sendandload(url:string, resultxml:xml) : void encodes the specified xml object into an xml document, sends it to the specified url using the post method, downloads the server's response, and loads it into the resultxmlobject speci...

  • Page 1309

    Xml 1309 parameters url:string - a string; the destination url for the specified xml object. If the swf file issuing this call is running in a web browser, url must be in the same domain as the swf file; for details, see the description section. Resultxml:xml - a target xml object created with the x...

  • Page 1310

    1310 actionscript classes status (xml.Status property) public status : number automatically sets and returns a numeric value that indicates whether an xml document was successfully parsed into an xml object. The following are the numeric status codes, with descriptions: ■ 0 no error; parse was compl...

  • Page 1311

    Xml 1311 case -4 : errormessage = "the doctype declaration was not properly terminated."; break; case -5 : errormessage = "a comment was not properly terminated."; break; case -6 : errormessage = "an xml element was malformed."; break; case -7 : errormessage = "out of memory."; break; case -8 : erro...

  • Page 1312

    1312 actionscript classes example the following example creates a new, empty xml object: var my_xml:xml = new xml(); the following example creates an xml object by parsing the xml text specified in the source parameter, and populates the newly created xml object with the resulting xml document tree:...

  • Page 1313

    Xmlnode 1313 my_txt.Setnewtextformat(my_fmt); var my_xml:xml = new xml(); my_xml.Ignorewhite = true; my_xml.Onload = function(success:boolean) { var endtime:number = gettimer(); var elapsedtime:number = endtime-starttime; if (success) { my_txt.Text = "xmldecl:"+newline+my_xml.Xmldecl+newline+newline...

  • Page 1314

    1314 actionscript classes property summary properties inherited from class object modifiers property description attributes :object an object containing all of the attributes of the specified xml instance. Childnodes :array [read-only] an array of the specified xml object's children. Firstchild :xml...

  • Page 1315

    Xmlnode 1315 constructor summary method summary methods inherited from class object signature description xmlnode (type:number, value:string) the xmlnode constructor lets you instantiate an xml node based on a string specifying its contents and on a number representing its node type. Modifiers signa...

  • Page 1316

    1316 actionscript classes appendchild (xmlnode.Appendchild method) public appendchild(newchild:xmlnode) : void appends the specified node to the xml object's child list. This method operates directly on the node referenced by the childnode parameter; it does not append a copy of the node. If the nod...

  • Page 1317

    Xmlnode 1317 trace ("doc2: " + doc2); // output: doc2: // create a new node to append to root node (named clone) of doc1 var newnode:xmlnode = doc1.Createelement("newbie"); clone.Appendchild(newnode); trace ("doc1: " + doc1); // output: doc1: attributes (xmlnode.Attributes property) public attribute...

  • Page 1318

    1318 actionscript classes availability: actionscript 1.0; flash player 5 example the following example shows how to use the xml.Childnodes property to return an array of child nodes: // create a new xml document var doc:xml = new xml(); // create a root node var rootnode:xmlnode = doc.Createelement(...

  • Page 1319

    Xmlnode 1319 the clone of the node that is returned is no longer associated with the tree of the cloned item. Consequently, nextsibling , parentnode , and previoussibling all have a value of null . If the deep parameter is set to false , or the my_xml node has no child nodes, firstchild and lastchil...

  • Page 1320

    1320 actionscript classes // // // // // create a copy of rootnode using clonenode() to demonstrate a deep copy var rootclone:xmlnode = rootnode.Clonenode(true); // insert the clone, which contains all child nodes, to rootnode rootnode.Appendchild(rootclone); trace(rootnode); // output (with line br...

  • Page 1321

    Xmlnode 1321 var oldest:xmlnode = doc.Createelement("oldest"); var middle:xmlnode = doc.Createelement("middle"); var youngest:xmlnode = doc.Createelement("youngest"); // add the rootnode as the root of the xml document tree doc.Appendchild(rootnode); // add each of the child nodes as children of roo...

  • Page 1322

    1322 actionscript classes getnamespaceforprefix (xmlnode.Getnamespaceforprefix method) public getnamespaceforprefix(prefix:string) : string returns the namespace uri that is associated with the specified prefix for the node. To determine the uri, getprefixfornamespace() searches up the xml hierarchy...

  • Page 1323

    Xmlnode 1323 getprefixfornamespace (xmlnode.Getprefixfornamespace method) public getprefixfornamespace(nsuri:string) : string returns the prefix that is associated with the specified namespace uri for the node. To determine the prefix, getprefixfornamespace() searches up the xml hierarchy from the n...

  • Page 1324

    1324 actionscript classes trace(xmldoc.Getprefixfornamespace("http://www.Example.Com/util")); // output: exu trace(xmldoc.Getprefixfornamespace("http://www.Example.Com/other")); // output: null var child1:xmlnode = xmldoc.Firstchild; trace(child1.Getprefixfornamespace("http://www.Example.Com/child")...

  • Page 1325

    Xmlnode 1325 insertbefore (xmlnode.Insertbefore method) public insertbefore(newchild:xmlnode, insertpoint:xmlnode) : void inserts a newchild node into the xml object's child list, before the insertpoint node. If insertpoint is not a child of the xmlnode object, the insertion fails. Availability: act...

  • Page 1326

    1326 actionscript classes // create a root node var rootnode:xmlnode = doc.Createelement("rootnode"); // create three child nodes var oldest:xmlnode = doc.Createelement("oldest"); var middle:xmlnode = doc.Createelement("middle"); var youngest:xmlnode = doc.Createelement("youngest"); // add the rootn...

  • Page 1327

    Xmlnode 1327 localname (xmlnode.Localname property) public localname : string [read-only] the local name portion of the xml node's name. This is the element name without the namespace prefix. For example, the node bob@example.Com contact:mailbox> has the local name "mailbox", and the prefix "contact...

  • Page 1328

    1328 actionscript classes namespaceuri (xmlnode.Namespaceuri property) public namespaceuri : string [read-only] if the xml node has a prefix, namespaceuri is the value of the xmlns declaration for that prefix (the uri), which is typically called the namespace uri. The xmlns declaration is in the cur...

  • Page 1329

    Xmlnode 1329 trace("w:gettemperature namespaceuri: " + tempnode.Namespaceuri); // output: ... Http://www.Example.Com/weather trace("w:gettemperature soap namespace: " + tempnode.Getnamespaceforprefix("soap")); // output: ... Http://www.W3.Org/2001/12/soap-envelope var soapbodynode:xmlnode = xmldoc.C...

  • Page 1330

    1330 actionscript classes see also getnamespaceforprefix (xmlnode.Getnamespaceforprefix method) , getprefixfornamespace (xmlnode.Getprefixfornamespace method) nextsibling (xmlnode.Nextsibling property) public nextsibling : xmlnode [read-only] an xmlnode value that references the next sibling in the ...

  • Page 1331

    Xmlnode 1331 example the following example creates an element node and a text node, and checks the node name of each: // create an xml document var doc:xml = new xml(); // create an xml node using createelement() var mynode:xmlnode = doc.Createelement("rootnode"); // place the new node into the xml ...

  • Page 1332

    1332 actionscript classes nodetype (xmlnode.Nodetype property) public nodetype : number [read-only] a nodetype value, either 1 for an xml element or 3 for a text node. The nodetype is a numeric value from the nodetype enumeration in the w3c dom level 1 recommendation: www.W3.Org/tr/1998/rec-dom-leve...

  • Page 1333

    Xmlnode 1333 example the following example creates an element node and a text node, and checks the node type of each: // create an xml document var doc:xml = new xml(); // create an xml node using createelement() var mynode:xmlnode = doc.Createelement("rootnode"); // place the new node into the xml ...

  • Page 1334

    1334 actionscript classes // place the new node into the xml tree doc.Appendchild(mynode); // create an xml text node using createtextnode() var mytextnode:xmlnode = doc.Createtextnode("textnode"); // place the new node into the xml tree mynode.Appendchild(mytextnode); trace(mynode.Nodevalue); trace...

  • Page 1335

    Xmlnode 1335 parentnode (xmlnode.Parentnode property) public parentnode : xmlnode [read-only] an xmlnode value that references the parent node of the specified xml object, or returns null if the node has no parent. This is a read-only property and cannot be used to manipulate child nodes; use the ap...

  • Page 1336

    1336 actionscript classes the nodename property of an xml node object returns the full name (including the prefix and the local name). You can access the local name portion of the element's name via the localname property. Availability: actionscript 1.0; flash player 8 example a directory contains a...

  • Page 1337

    Xmlnode 1337 example the following example is an excerpt from the example for the xml.Lastchild property, and shows how you can use the xml.Previoussibling property to loop through an xml node's child nodes: for (var anode:xmlnode = rootnode.Lastchild; anode != null; anode = anode.Previoussibling) {...

  • Page 1338

    1338 actionscript classes tostring (xmlnode.Tostring method) public tostring() : string evaluates the specified xml object, constructs a textual representation of the xml structure, including the node, children, and attributes, and returns the result as a string. For top-level xml objects (those cre...

  • Page 1339

    Xmlnode 1339 parameters type:number - an integer representing the node type: in flash player, the xml class only supports node types 1 (element_node) and 3 (text_node). Value:string - for a text node, this is the text of the node; for an element node, this is the contents of the tag. Example var ele...

  • Page 1341

    Xmlsocket 1341 the following restrictions apply to how and where an xmlsocket object can connect to the server: ■ the xmlsocket.Connect() method can connect only to tcp port numbers greater than or equal to 1024. One consequence of this restriction is that the server daemons that communicate with th...

  • Page 1342

    1342 actionscript classes constructor summary method summary methods inherited from class object ondata = function(src:str ing) {} invoked when a message has been downloaded from the server, terminated by a zero (0) byte. Onxml = function(src:xml ) {} invoked by flash player when the specified xml o...

  • Page 1343

    Xmlsocket 1343 close (xmlsocket.Close method) public close() : void closes the connection specified by xmlsocket object. Availability: actionscript 1.0; flash player 5 example the following simple example creates an xmlsocket object, attempts to connect to the server, and then closes the connection....

  • Page 1344

    1344 actionscript classes when load() is executed, the xml object property loaded is set to false . When the xml data finishes downloading, the loaded property is set to true , and the onload event handler is invoked. The xml data is not parsed until it is completely downloaded. If the xml object pr...

  • Page 1345

    Xmlsocket 1345 example the following example uses xmlsocket.Connect() to connect to the host where the swf file resides and uses trace to display the return value indicating the success or failure of the connection: var socket:xmlsocket = new xmlsocket() socket.Onconnect = function (success:boolean)...

  • Page 1346

    1346 actionscript classes onconnect (xmlsocket.Onconnect handler) onconnect = function(success:boolean) {} invoked by flash player when a connection request initiated through xmlsocket.Connect() has succeeded or failed. If the connection succeeded, the success parameter is true ; otherwise the succe...

  • Page 1347

    Xmlsocket 1347 gotoandstop("waitforconnection"); } see also connect (xmlsocket.Connect method) , function statement ondata (xmlsocket.Ondata handler) ondata = function(src:string) {} invoked when a message has been downloaded from the server, terminated by a zero (0) byte. You can override xmlsocket...

  • Page 1348

    1348 actionscript classes the default implementation of this method performs no actions. To override the default implementation, you must assign a function containing actions that you define. Availability: actionscript 1.0; flash player 5 parameters src:xml - an xml object that contains a parsed xml...

  • Page 1349

    Xmlui 1349 parameters data:object - an xml object or other data to transmit to the server. Example the following example shows how you could specify a user name and password to send the xml object my_xml to the server: var myxmlsocket:xmlsocket = new xmlsocket(); var my_xml:xml = new xml(); var mylo...

  • Page 1350

    1350 actionscript classes macromedia flash comes with several extensibility features including behaviors, commands (javascript api), effects, and tools. With these features, advanced users can extend or automate the authoring tool's functionality. The xml to ui engine works with each of these extens...

  • Page 1351

    Xmlui 1351 accept (xmlui.Accept method) public static accept() : void makes the current xmlui dialog exit with an "accept" state. Identical to the user clicking the ok button. Availability: actionscript 1.0; flash player 7 cancel (xmlui.Cancel method) public static cancel() : void makes the current ...

  • Page 1352

    1352 actionscript classes.

  • Page 1353

    1353 3 chapter 3 deprecated actionscript the evolution of actionscript has deprecated many elements of the language. This section lists the deprecated items and suggests alternatives when available. While deprecated elements still work in flash player 8, macromedia recommends that you do not continu...

  • Page 1354

    1354 deprecated actionscript length(expression:str ing, variable:object) deprecated since flash player 5. This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the string class and the string.Length property to perform the same ope...

  • Page 1355

    Deprecated operator summary 1355 deprecated property summary deprecated operator summary modifiers property name description button._highquality deprecated since flash player 7. This property was deprecated in favor of button._quality. Movieclip._highqualit y deprecated since flash player 7. This pr...

  • Page 1356

    1356 deprecated actionscript le (less than or equal to (strings)) deprecated since flash player 5. This operator was deprecated in flash 5 in favor of the equal to) operator. Lt (less than (strings)) deprecated since flash player 5. This operator was deprecated in favor of the ne (not equal (strings...

  • Page 1357

    1357 index type operator 189 inequality operator 167 symbols 140, 141, 169, 170 ! Logical not operator 174 != inequality operator 166 !== strict inequality operator 186 " string delimiter operator 187 #endinitclip directive 31 #include directive 32 #initclip directive 33 % modulo operator 177 %= mod...

  • Page 1359

    Index 1359 b b property 766 background property 1173 backgroundcolor property 1173 backspace property 673 bandwidth property 384 beginbitmapfill() method 830 beginfill() method 832 begingradientfill() method 833 bevelfilter angle property 275 bevelfilter() constructor 276 blurx property 278 blury pr...

  • Page 1360

    1360 index button _alpha property 347 _focusrect property 357 _height property 358 _highquality property 359 _name property 360 _parent property 367 _quality property 368 _rotation property 368 _soundbuftime property 370 _target property 372 _url property 374 _visible property 375 _width property 37...

  • Page 1361

    Index 1361 playertype property 415 screencolor property 415 screendpi property 415 screenresolutionx property 416 screenresolutiony property 416 serverstring property 416 version property 417 capabilities class 404 capslock property 673 caption property 451 case statement 195 caseinsensitive propert...

  • Page 1362

    1362 index containspoint() method 1038 containsrectangle() method 1038 contenttype property 696, 1290 contextmenu builtinitems property 444 contextmenu() constructor 445 copy() method 446 customitems property 447 hidebuiltinitems() method 448 contextmenu class 442 onselect event 448 contextmenu() co...

  • Page 1363

    Index 1363 setutcmonth() method 502 setutcseconds() method 502 setyear() method 503 tostring() method 504 utc() method 504 valueof() method 505 date class 475 date() constructor 480 deblocking property 1278 decode() method 696 default statement 200 delete statement 201 deletekey property 675 deltatr...

  • Page 1364

    1364 index cancel() method 563 creationdate property 564 creator property 565 download() method 565 filereference() constructor 568 modificationdate property 569 name property 569 removelistener() method 578 size property 579 type property 580 upload() method 580 filereference class 555 oncancel eve...

  • Page 1365

    Index 1365 gettext() method 1257 gettextextent() method 1234 gettextformat() method 1181 gettextruninfo() method 1258 gettextsnapshot() method 871 gettime() method 486 gettimer function 59 gettimezoneoffset() method 487 gettransform() method 420, 1102 geturl function 59 geturl() method 872 getutcdat...

  • Page 1366

    1366 index hideobject property 540 highlightalpha property 283 highlightcolor property 284 hitarea property 879 hittest() method 315, 880 hittesttextnearpos() method 1261 home property 681 hscroll property 1185 html property 1186 htmltext property 1187 i id3 property 1106 identity() method 774 idmap...

  • Page 1367

    Index 1367 istoggled() method 683 left property 685 pgdn property 687 pgup property 688 removelistener() method 688 right property 689 shift property 690 space property 690 tab property 691 up property 691 key class 669 onkeydown event 686 onkeyup event 687 knockout property 285, 542, 609, 624, 645 ...

  • Page 1368

    1368 index log10e property 753 log2e property 753 lt less than (strings) operator 170 m manufacturer property 414 mapbitmap property 520 mappoint property 522 math abs() method 745 acos() method 746 asin() method 746 atan() method 747 atan2() method 748 ceil() method 748 cos() method 749 e property ...

  • Page 1369

    Index 1369 motionlevel property 391 motiontimeout property 393 mouse addlistener() method 807 hide() method 808 removelistener() method 814 show() method 816 mouse class 805 onmousedown event 809 onmousemove event 810 onmouseup event 812 onmousewheel event 813 mousewheelenabled property 1191 moveto(...

  • Page 1370

    1370 index ondragout event 902 ondragover event 902 onenterframe event 903 onkeydown event 903 onkeyup event 904 onkillfocus event 905 onload event 906 onmousedown event 907 onmousemove event 907 onmouseup event 907 onpress event 908 onrelease event 908 onreleaseoutside event 909 onrollout event 909...

  • Page 1371

    Index 1371 o object __proto__ property 998 __resolve property 1001 addproperty() method 992 constructor property 995 hasownproperty() method 996 ispropertyenumerable() method 996 isprototypeof() method 997 object() constructor 997 prototype property 999 registerclass() method 1000 tostring() method ...

  • Page 1372

    1372 index play() method 913, 980 playertype property 415 point add() method 1011 clone() method 1011 distance() method 1012 equals() method 1012 interpolate() method 1013 length property 1014 normalize() method 1014 offset() method 1015 point() constructor 1015 polar() method 1016 subtract() method...

  • Page 1373

    Index 1373 replacesel() method 1201 replacetext() method 1202 restrict property 1203 return statement 223 returnindexedarray property 254 reverse() method 254 rgb property 440 right property 689 right property 1048 rightmargin property 1241 rotate() method 777 round() method 757 s sandboxtype proper...

  • Page 1374

    1374 index setutcmonth() method 502 setutcseconds() method 502 setvolume() method 1115 setyear() method 503 shadowalpha property 287 shadowcolor property 288 sharedobject clear() method 1083 data property 1084 flush() method 1085 getlocal() method 1087 getsize() method 1091 sharedobject class 1080 o...

  • Page 1375

    Index 1375 stylesheet clear() method 1145 getstyle() method 1146 getstylenames() method 1148 load() method 1148 parsecss() method 1150 setstyle() method 1151 stylesheet() constructor 1153 transform() method 1153 stylesheet class 1142 onload event 1149 stylesheet property 1212 stylesheet() constructo...

  • Page 1376

    1376 index tabindex property 1215 text property 1217 textcolor property 1217 textheight property 1218 textwidth property 1219 thickness property 1219 type property 1220 variable property 1221 wordwrap property 1224 textfield class 1162 onchanged event 1193 onkillfocus event 1194 onscroller event 119...

  • Page 1377

    Index 1377 unloadmovie function 110 unloadmovie() method 935 unloadmovienum function 111 unshift() method 265 unwatch() method 1005 up property 691 updateafterevent function 112 updateproperties() method 241 upload() method 580 url property 1245 usecodepage property 1161 useechosuppression property ...

  • Page 1378

    1378 index nodetype property 1332 nodevalue property 1333 parentnode property 1335 prefix property 1335 previoussibling property 1336 removenode() method 1337 tostring() method 1338 xmlnode() constructor 1338 xmlnode class 1313 xmlnode() constructor 1338 xmlsocket close() method 1343 connect() metho...