MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference

Summary of FLASHLITE2 ACTIONSCRIPT-LANGUAGE

  • Page 1

    Flash lite 2.X actionscript 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 endocer, flex, flex builder, f...

  • Page 3

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

  • Page 4

    4 contents loadmovienum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 loadvariables function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 loadvariablesnum function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 5

    Contents 5 _capsmaf property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 _capsms property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 _capstreamsound property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents >= greater than or equal to operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 ge greater than or equal to (strings) operator . . . . . . . . . . . . . . . . . . 149 ++ increment operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 != i...

  • Page 7

    Contents 7 for statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 for..In statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 function statement. . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 8

    8 contents setfocusrectcolor fscommand2 command . . . . . . . . . . . . . . . . 240 setinputtexttype fscommand2 command . . . . . . . . . . . . . . . . . . 240 setsoftkeys fscommand2 command . . . . . . . . . . . . . . . . . . . . . . . . 241 startvibrate fscommand2 command . . . . . . . . . . . . ....

  • Page 9

    Contents 9 ondragover (button.Ondragover handler) . . . . . . . . . . . . . . . . . . . 280 onkeydown (button.Onkeydown handler) . . . . . . . . . . . . . . . . . . . 280 onkeyup (button.Onkeyup handler) . . . . . . . . . . . . . . . . . . . . . . . . .281 onkillfocus (button.Onkillfocus handler) . ...

  • Page 10

    10 contents hasmidi (capabilities.Hasmidi property) . . . . . . . . . . . . . . . . . . . . . 309 hasmms (capabilities.Hasmms property). . . . . . . . . . . . . . . . . . . . 309 hasmouse (capabilities.Hasmouse property) . . . . . . . . . . . . . . . . . 309 hasmp3 (capabilities.Hasmp3 property). . ...

  • Page 11

    Contents 11 getlocalelongdate (date.Getlocalelongdate method) . . . . . . 334 getlocaleshortdate (date.Getlocaleshortdate method). . . . . . 334 getlocaletime (date.Getlocaletime method). . . . . . . . . . . . . . . . 335 getmilliseconds (date.Getmilliseconds method). . . . . . . . . . . . . . . 335...

  • Page 12

    12 contents extendedkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362 soft1 (extendedkey.Soft1 property) . . . . . . . . . . . . . . . . . . . . . .364 soft10 (extendedkey.Soft10 property). . . . . . . . . . . . . . . . . . . .364 soft11 (extended...

  • Page 13

    Contents 13 loadvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 addrequestheader (loadvars.Addrequestheader method) . . . . . . . . . . . . . . . . . . . 392 contenttype (loadvars.Contenttype property) . . . . . . . . . . . . . . . 394 d...

  • Page 14

    14 contents round (math.Round method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 sin (math.Sin method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426 sqrt (math.Sqrt method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 15

    Contents 15 hitarea (movieclip.Hitarea property). . . . . . . . . . . . . . . . . . . . . . . . . 480 hittest (movieclip.Hittest method) . . . . . . . . . . . . . . . . . . . . . . . . . . 480 linestyle (movieclip.Linestyle method) . . . . . . . . . . . . . . . . . . . . . . . 482 lineto (movieclip....

  • Page 16

    16 contents trackasmenu (movieclip.Trackasmenu property) . . . . . . . . . . . . . . 519 unloadmovie (movieclip.Unloadmovie method) . . . . . . . . . . . . . . 520 _url (movieclip._url property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 _visible (movieclip._visible property...

  • Page 17

    Contents 17 registerclass (object.Registerclass method) . . . . . . . . . . . . . . . . . . 559 __resolve (object.__resolve property) . . . . . . . . . . . . . . . . . . . . . . . . 560 tostring (object.Tostring method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 unwatch (object.Unwatc...

  • Page 18

    18 contents start (sound.Start method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616 stop (sound.Stop method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 19

    Contents 19 _highquality (textfield._highquality property) . . . . . . . . . . . . . . . . . .661 hscroll (textfield.Hscroll property) . . . . . . . . . . . . . . . . . . . . . . . . . . .661 html (textfield.Html property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662 htmltext (te...

  • Page 20

    20 contents textformat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 align (textformat.Align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .697 blockindent (textformat.Blockindent property) . . . . . . . . . . . . . . .698 bol...

  • Page 21

    Contents 21 xmlnode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 appendchild (xmlnode.Appendchild method) . . . . . . . . . . . . . . . 740 attributes (xmlnode.Attributes property) . . . . . . . . . . . . . . . . . . . . 742 childnodes (xml...

  • Page 22

    22 contents.

  • Page 23

    23 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 24

    24 actionscript language elements #include directive #include "[path]filename.As" — do not place a semicolon (;) at the end of the line that contains the #include statement. Compiler directive: includes the contents of the specified file, as if the commands in the file are part of the calling script...

  • Page 25

    Compiler directives 25 parameters [path]filename.As - 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 be incl...

  • Page 26

    26 actionscript language elements initialization actions execute only once when a swf file plays; use them for one-time initializations, such as class definition and registration. Availability: actionscript 1.0; flash lite 2.0 parameters order - a non-negative integer that specifies the execution or...

  • Page 27

    Constants 27 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 28

    28 actionscript language elements example this example shows how automatic data typing converts false to a number and to a string: var bool1:boolean = boolean(false); // converts it to the number 0 trace(1 + bool1); // outputs 1 // converts it to a string trace("string: " + bool1); // outputs string...

  • Page 29

    Constants 29 newline constant inserts a carriage return character ( \r ) that generates a blank line in text output generated by your code. Use newline to make space for information that is retrieved by a function or statement in your code. Availability: actionscript 1.0; flash lite 1.1 example the ...

  • Page 30

    30 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 lite 1.1 example the followi...

  • Page 31

    Constants 31 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 32

    32 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 33

    Global functions 33 fscommand (command: string , parameters: string ) lets a swf file communicate with the flash lite player or the environment for a mobile device (such as an operating system). Fscommand2 (command: string , parameters: string ) lets the swf file communicate with the flash lite play...

  • Page 34

    34 actionscript language elements int (value: number ) : number deprecated since flash player 5. This function was deprecated in favor of math.Round(). Converts a decimal number to an integer value by truncating the decimal value. Isfinite (expression: object ) : boolean evaluates expression and ret...

  • Page 35

    Global functions 35 mbchr (number: number ) deprecated since flash player 5. This function was deprecated in favor of the string.Fromcharcode() method. Converts an ascii code number to a multibyte character. Mblength (string: string ) : number deprecated since flash player 5. This function was depre...

  • Page 36

    36 actionscript language elements ord (character: string ) : number deprecated since flash player 5. This function was deprecated in favor of the methods and properties of the string class. Converts characters to ascii code numbers. Parsefloat (string: string ) : number converts a string to a floati...

  • Page 37

    Global functions 37 stopdrag () stops the current drag operation. String (expression: object ) : string returns a string representation of the specified parameter. Substring (string: string , index: number , count: number ) : string deprecated since flash player 5. This function was deprecated in fa...

  • Page 38

    38 actionscript language elements array function array(): array array(numelements:number): array array( [element0:object [, element1, element2, ...Elementn] ]) : array creates a new array of length zero or more, or an array populated by a list of specified elements, possibly of different data types....

  • Page 39

    Global functions 39 usage 3: the following example creates an array with three defined elements: var myarray:array = array("firstelement", "secondelement", "thirdelement"); trace (myarray); // traces firstelement,secondelement,thirdelement unlike the array class constructor, the array() function doe...

  • Page 40

    40 actionscript language elements example trace(boolean(-1)); // output: true trace(boolean(0)); // output: false trace(boolean(1)); // output: true trace(boolean(true)); // output: true trace(boolean(false)); // output: false trace(boolean("true")); // output: true trace(boolean("false")); // outpu...

  • Page 41

    Global functions 41 executes the script in the called frame without moving the playhead to that frame. Local variables do not exist after the script executes. ■ if variables are not declared inside a block ( {} ) but the action list was executed with a call() action, the variables are local and expi...

  • Page 42

    42 actionscript language elements clearinterval function clearinterval(intervalid:number) : void cancels an interval created by a call to setinterval(). Availability: actionscript 1.0; flash lite 2.0 parameters intervalid: number - a numeric (integer) identifier returned from a call to setinterval()...

  • Page 43

    Global functions 43 parameters target: object - the target path of the movie clip to duplicate. This parameter can be either a string (e.G. "my_mc") or a direct reference to the movie clip instance (e.G. My_mc). Parameters that can accept more than one data type are listed as type object . Newname: ...

  • Page 44

    44 actionscript language elements parameters expression: string - the expression to convert into a string and encode in a url-encoded format. Returns string - url-encoded string. Example the following code produces the result someuser%40somedomain%2ecom : var email:string = "someuser@somedomain.Com"...

  • Page 45

    Global functions 45 in flash 5 or later, you cannot use eval() to dynamically set and retrieve the value of a variable or instance name, because you cannot use eval() on the left side of an equation. For example, replace the code eval ("var" + i) = "first"; with this: this["var"+i] = "first" or this...

  • Page 46

    46 actionscript language elements fscommand function fscommand(command:string, parameters:string) : void the fscommand() function lets a swf file communicate with the flash lite player or the environment for a mobile device (such as an operating system). The parameters define the name of the applica...

  • Page 47

    Global functions 47 fscommand2 function fscommand2(command:string, parameter1:string,...Parametern:string) : void lets the swf file communicate with the flash lite player or a host application on a mobile device. The fscommand2() function is similar to the fscommand() function, with the following di...

  • Page 48

    48 actionscript language elements availability: actionscript 1.0; flash lite 1.1 parameters command: string - a string passed to the host application for any use, or a command passed to the flash lite player. Parameters: string - a string passed to the host application for any use, or a value passed...

  • Page 49

    Global functions 49 gettimer function gettimer() : number returns the number of milliseconds that have elapsed since the swf file started playing. Availability: actionscript 1.0; flash lite 1.0 returns number - the number of milliseconds that have elapsed since the swf file started playing. Example ...

  • Page 50

    50 actionscript language elements method: string [optional] - a get or post method for sending variables. If there are no variables, omit this parameter. The get method appends the variables to the end of the url, and is used for small numbers of variables. The post method sends the variables in a s...

  • Page 51

    Global functions 51 getversion function getversion() : string returns a string containing flash player version and platform information. The getversion function returns information only for flash player 5 or later versions of flash player. Availability: actionscript 1.0; flash lite 2.0 returns strin...

  • Page 52

    52 actionscript language elements example in the following example, a document has two scenes: sceneone and scenetwo . Scene one contains a frame label on frame 10 called newframe and two buttons, mybtn_btn and myotherbtn_btn . This actionscript is placed on frame 1, scene 1 of the main timeline. St...

  • Page 53

    Global functions 53 example in the following example, a document has two scenes: sceneone and scenetwo . Scene one contains a frame label on frame 10 called newframe , and two buttons, mybtn_btn and myotherbtn_btn . This actionscript is placed on frame 1, scene 1 of the main timeline: stop(); mybtn_...

  • Page 54

    54 actionscript language elements see also addlistener (moviecliploader.Addlistener method) int function int(value) : number deprecated since flash player 5. This function was deprecated in favor of math.Round() . Converts a decimal number to an integer value by truncating the decimal value. This fu...

  • Page 55

    Global functions 55 example the following example shows return values for isfinite : isfinite(56) // returns true isfinite(number.Positive_infinity) //returns false isnan function isnan(expression:object) : boolean evaluates the parameter and returns true if the value is nan (not a number). This fun...

  • Page 56

    56 actionscript language elements the following example shows how you can use isnan() to check whether a mathematical expression contains an error: var dividend:number; var divisor:number; divisor = 1; trace( isnan(dividend/divisor) ); // output: true // the output is true because the variable divid...

  • Page 57

    Global functions 57 loadmovie function loadmovie(url:string, target:object [, method:string]) : voidloadmovie(url:string, target:string [, method:string]) : void loads a swf or jpeg file into flash player while the original swf file plays. Jpeg files saved in progressive format are not supported. Ti...

  • Page 58

    58 actionscript language elements 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", _le...

  • Page 59

    Global functions 59 normally, flash player displays a single swf file and then closes. The loadmovienum() action lets you display several swf files at once and switch among swf files without loading another html document. If you want to specify a target instead of a level, use loadmovie() instead of...

  • Page 60

    60 actionscript language elements method: string [optional] - specifies an http method for sending variables. The parameter must be the string get or post . If there are no variables to be sent, omit this parameter. The get method appends the variables to the end of the url and is used for small num...

  • Page 61

    Global functions 61 if you want to load variables into a specific level, use loadvariablesnum() instead of loadvariables() . Availability: actionscript 1.0; flash lite 1.1 - behavior changed in flash player 7. Parameters url: string - an absolute or relative url where the variables are located. If t...

  • Page 62

    62 actionscript language elements see also loadvariablesnum function , loadmovie function , loadmovienum function , geturl function , loadmovie (movieclip.Loadmovie method) , loadvariables (movieclip.Loadvariables method) , load (loadvars.Load method) loadvariablesnum function loadvariablesnum(url:s...

  • Page 63

    Global functions 63 method: string [optional] - specifies an http method for sending variables. The parameter must be the string get or post . If there are no variables to be sent, omit this parameter. The get method appends the variables to the end of the url and is used for small numbers of variab...

  • Page 64

    64 actionscript language elements availability: actionscript 1.0; flash lite 1.0 parameters number: number - the number to convert to a multibyte character. See also fromcharcode (string.Fromcharcode method) mblength function mblength(string) : number deprecated since flash player 5. This function w...

  • Page 65

    Global functions 65 returns number - the converted character. See also charcodeat (string.Charcodeat method) mbsubstring function mbsubstring(value, index, count) : string deprecated since flash player 5. This function was deprecated in favor of string.Substr() method. Extracts a new multibyte chara...

  • Page 66

    66 actionscript language elements nextframe function nextframe() : void sends the playhead to the next frame. Availability: actionscript 1.0; flash lite 1.0 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...

  • Page 67

    Global functions 67 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.Createemptymovieclip...

  • Page 68

    68 actionscript language elements number function number(expression) : number converts the parameter expression to a number and returns a value as described in the following list: ■ if expression is a number, the return value is expression . ■ if expression is a boolean value, the return value is 1 ...

  • Page 69

    Global functions 69 object function object( [value] ) : 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"). Availability: act...

  • Page 70

    70 actionscript language elements 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 p...

  • Page 71

    Global functions 71 example in the following script, the startdrag() function executes when the mouse is pressed, and the conditional script is executed when the mouse is released and the object is dropped: on (press) { startdrag(this); } on (release) { trace("x:"+this._x); trace("y:"+this._y); stop...

  • Page 72

    72 actionscript language elements ■ mousedown the action is initiated when the left mouse button is pressed. Note: this event is supported in flash lite only if system.Capabilities.Hasmouse is true or system.Capabilities.Hasstylus is true . ■ mouseup the action is initiated when the left mouse butto...

  • Page 73

    Global functions 73 see also key , _xmouse (movieclip._xmouse property) , _ymouse (movieclip._ymouse property) , on handler ord function ord(character) : number deprecated since flash player 5. This function was deprecated in favor of the methods and properties of the string class. Converts characte...

  • Page 74

    74 actionscript language elements example the following examples use the parsefloat() function to evaluate various types of numbers: trace(parsefloat("-2")); // output: -2 trace(parsefloat("2.5")); // output: 2.5 trace(parsefloat(" 2.5")); // output: 2.5 trace(parsefloat("3.5e6")); // output: 350000...

  • Page 75

    Global functions 75 the following example returns 4: parseint("4foo") the following example shows a hexadecimal conversion that returns 1016: parseint("0x3f8") the following example shows a hexadecimal conversion using the optional radix parameter that returns 1000: parseint("3e8", 16) the following...

  • Page 76

    76 actionscript language elements prevframe function prevframe() : void sends the playhead to the previous frame. If the current frame is frame 1, the playhead does not move. Availability: actionscript 1.0; flash lite 1.0 example when the user clicks a button called mybtn_btn and the following actio...

  • Page 77

    Global functions 77 returns number - a random integer. 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; ...

  • Page 78

    78 actionscript language elements see also duplicatemovieclip function , duplicatemovieclip (movieclip.Duplicatemovieclip method) , attachmovie (movieclip.Attachmovie method) , removemovieclip (movieclip.Removemovieclip method) , createemptymovieclip (movieclip.Createemptymovieclip method) setinterv...

  • Page 79

    Global functions 79 example usage 1: the following example calls an anonymous function every 1000 milliseconds (1 second). Setinterval( function(){ trace("interval called"); }, 1000 ); usage 2: the following example defines two event handlers and calls each of them. The first call to setinterval() c...

  • Page 80

    80 actionscript language elements when working with this function, you need to be careful about the memory you use in a swf file. For example, when you remove a movie clip from the swf file, it will not remove any setinterval() function running within it. Always remove the setinterval() function by ...

  • Page 81

    Global functions 81 then create a file called user.As in the same directory as your fla file. Enter the following actionscript: class user { var intervalid:number; var username:string; function user(param_username:string) { trace("welcome, "+param_username); this.Username = param_username; this.Inte...

  • Page 82

    82 actionscript language elements see also getproperty function 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...

  • Page 83

    Global functions 83 see also stopdrag function , _droptarget (movieclip._droptarget property) , startdrag (movieclip.Startdrag method) 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: ac...

  • Page 84

    84 actionscript language elements /* get the current offset. If you stop all sounds and click the play button, the mp3 continues from where it was stopped, instead of restarting from the beginning. */ var numsecondsoffset:number = (bg_sound.Position/1000); bg_sound.Start(numsecondsoffset); }; this.S...

  • Page 85

    Global functions 85 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 string...

  • Page 86

    86 actionscript language elements substring function substring("string", index, count) : 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 zero-based. Availab...

  • Page 87

    Global functions 87 returns string - a string containing the target path of the specified object. 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.Myc...

  • Page 88

    88 actionscript language elements example this telltarget statement controls the movie clip instance ball on the main timeline. Frame 1 of the ball instance is blank and has a stop() action so it isn't visible on the stage. When you click the button with the following action, telltarget tells the pl...

  • Page 89

    Global functions 89 example the following code could be applied to a button that, when clicked, would toggle anti- aliasing on and off: on(release) { togglehighquality(); } see also _quality property trace function trace(expression:object) you can use flash debug player to capture output from the tr...

  • Page 90

    90 actionscript language elements example the following example uses a trace() statement to display in the output panel the methods and properties of the dynamically created text field called error_txt : this.Createtextfield("error_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); for (var i in erro...

  • Page 91

    Global functions 91 unloadmovie function unloadmovie(target:movieclip) : void unloadmovie(target:string) : void removes a movie clip that was loaded by means of loadmovie() from flash player. To unload a movie clip that was loaded by means of loadmovienum() , use unloadmovienum() instead of unloadmo...

  • Page 92

    92 actionscript language elements availability: actionscript 1.0; flash lite 1.1 parameters level: number - the level ( _level n ) of a loaded movie. Example the following example loads an image into a swf file. When you click unload_btn , the loaded content is removed. Loadmovienum("yourimage.Jpg",...

  • Page 93

    Global properties 93 _capcompoundsound deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Hascompoundsound property. Indicates whether flash lite can process compound sound data. _capemail deprecated since flash lite player 2.0. This action was dep...

  • Page 94

    94 actionscript language elements _capsmaf deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Hassmaf property. Indicates whether the device can play multimedia files in the synthetic music mobile application format (smaf). If so, this variable is ...

  • Page 95

    Global properties 95 $version property $version deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Version property. String variable; contains the version number of flash lite. It contains a major number, minor number, build number, and an internal...

  • Page 96

    96 actionscript language elements _cap4waykeyas property _cap4waykeyas deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Has4waykeyas property. Numeric variable; indicates whether flash lite executes actionscript expressions attached to key event ...

  • Page 97

    Global properties 97 numeric variable; indicates whether flash lite can process compound sound data. If so, this variable is defined and has a value of 1; if not, this variable is undefined. For example, a single flash file can contain the same sound represented in both midi and mfi formats. The pla...

  • Page 98

    98 actionscript language elements see also capabilities (system.Capabilities) _caploaddata property _caploaddata deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Hasdataloading property. Numeric variable; indicates whether the host application ca...

  • Page 99

    Global properties 99 example if the device can play mfi sound data, the following example sets canmfi to 1 : canmfi = _capmfi; if (canmfi == 1) { // send movieclip buttons to frame with buttons that trigger events sounds telltarget("buttons") { gotoandplay(2); } } _capmidi property _capmidi deprecat...

  • Page 100

    100 actionscript language elements deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Hasmms property. Numeric variable; indicates whether flash lite can send multimedia messaging service (mms) messages by using the geturl() actionscript command. I...

  • Page 101

    Global properties 101 example the following example sets cansmaf to 1 in flash lite 1.1, but leaves it undefined in flash lite 1.0 (however, not all flash lite 1.1 phones can send smaf messages, so this code is still dependent on the phone): cansmaf = _capsmaf; if (cansmaf) { // send movieclip butto...

  • Page 102

    102 actionscript language elements see also capabilities (system.Capabilities) _capstreamsound property _capstreamsound deprecated since flash lite player 2.0. This action was deprecated in favor of the system.Capabilities.Hasstreamingaudio property. Numeric variable; indicates whether the device ca...

  • Page 103

    Global properties 103 if the global _focusrect property is set to false , the default behavior for all buttons and movieclips is that keyboard navigation is limited to the tab key. All other keys, including the enter and arrow keys, are ignored. To restore full keyboard navigation, you must set _foc...

  • Page 104

    104 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 105

    Global properties 105 _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 the best quality. Specify 1 (high quality) to apply an...

  • Page 106

    106 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 107

    Global properties 107 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 108

    108 actionscript language elements _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...

  • Page 109

    Global properties 109 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 field begins displaying content; after you set it, flash playe...

  • Page 110

    110 actionscript language elements 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 o...

  • Page 111

    Global properties 111 because this is evaluated in the context of the script that contains it, you can't use this in a script to refer to a variable defined in a class file. Create applythis.As, and enter the following code: class applythis { var str:string = "defined in applythis.As"; function conc...

  • Page 112

    112 actionscript language elements example 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 as...

  • Page 113

    Operators 113 = ( assignment ) assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1 . & ( bitwise and ) converts expression1 and expression2 to 32-bit unsigned integers, and performs a boolean and operation on each bit of the intege...

  • Page 114

    114 actionscript language elements ^ ( bitwise xor ) converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2 , but not both, are 1. ^= ( bitwise xor assignment ) assigns expression1 the value of...

  • Page 115

    Operators 115 gt ( greater than (strings) ) deprecated since flash player 5. This operator was deprecated in favor of the > (greater than) operator. Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than express...

  • Page 116

    116 actionscript language elements 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. Returns true if expression1 is less than or equal to expression2 , false otherwise. // ( line comment delimiter ) ind...

  • Page 117

    Operators 117 + 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 either or both expressi...

  • Page 118

    118 actionscript language elements note: flash lite 2.0 supports the addition ( + ) operator for adding numeric expressions and concatenating strings. Flash lite 1.X only supports the addition ( + ) operator for adding numeric expressions (such as var1 = 1 + 2 // output: 3 ). For flash lite 1.X, you...

  • Page 119

    Operators 119 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 120

    120 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 121

    Operators 121 var my_array:array = new array(); my_array[0] = 15; my_array[1] = "hello"; my_array[2] = true; you can use brackets ([]) to add a fourth element, as shown in the following example: my_array[3] = "george"; you can use brackets ([]) to access an element in a multidimensional array. The f...

  • Page 122

    122 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 123

    Operators 123 = 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 124

    124 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 125

    Operators 125 note: the behavior of this operator is different for flash lite, depending on the version. For example, flash lite 2.0 supports the and ( & ) operator as a bitwise and. To concatenate strings in flash lite 2.0, you must use the addition ( + ) operator. However, flash lite 1.X supports ...

  • Page 126

    126 actionscript language elements &= bitwise and assignment operator expression1 &= expression2 assigns expression1 the value of expression1& expression2 . For example, the following two expressions are equivalent: x &= y; x = x & y; availability: actionscript 1.0; flash lite 2.0 operands expressio...

  • Page 127

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

  • Page 128

    128 actionscript language elements expression1 expression2 this operator performs a bitwise left shift ( in expression1 . The following two expressions are equivalent: a availability: actionscript 1.0; flash lite 2.0 operands expression1 : number - a number or expression to be shifted left. Expressi...

  • Page 129

    Operators 129 in hexadecimal, this is 0x8888. Therefore, ~0x7777 is 0x8888. The most common use of bitwise operators is for representing flag bits (boolean values packed into 1 bit each). Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive inte...

  • Page 132

    132 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 133

    Operators 133 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); // outputs -1 the following example shows the result of the previous example: var x:number = -1; this is because -1 decimal equals 11111111111111111111111111111111 ...

  • Page 134

    134 actionscript language elements string result = (lsb ? "1" : "0")+result; // shift numbertoconvert right by one bit, to see next bit numbertoconvert >>= 1; } return result; } trace(converttobinary(479)); // returns the string 00000000000000000000000111011111 // this string is the binary represent...

  • Page 135

    Operators 135 this is because -1 decimal is 11111111111111111111111111111111 binary (thirty-two 1s), and when you shift right (unsigned) by 1 bit, the least significant (rightmost) bit is discarded, and the most significant (leftmost) bit is filled with a 0. The result is 011111111111111111111111111...

  • Page 136

    136 actionscript language elements ^ bitwise xor operator expression1 ^ expression2 converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2 , but not both, are 1. Floating-point numbers are conv...

  • Page 137

    Operators 137 ^= bitwise xor assignment operator expression1 ^= expression2 assigns expression1 the value of expression1 ^ expression2 . For example, the following two statements are equivalent: x ^= y x = x ^ y availability: actionscript 1.0; flash lite 2.0 operands expression1 : number - integers ...

  • Page 138

    138 actionscript language elements 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 ignored by the actionscript interpreter. Use the // (comment delimiter) to identif...

  • Page 139

    Operators 139 operands expression1 : number - an expression to be evaluated. Expression2 : number - an expression to be evaluated. Expressionn : number - any number of additional expressions to be evaluated. Returns object - the value of expression1 , expression2 , and so on. Example the following e...

  • Page 140

    140 actionscript language elements the following example is identical to the previous example except for the addition of the parentheses () operator and illustrates once again that, when used with the parentheses () operator, the comma (,) operator returns the value of the last expression in the ser...

  • Page 141

    Operators 141 ?: 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 value of expression3 . Availability: actionscript 1.0; flash lite 1.0 opera...

  • Page 142

    142 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 143

    Operators 143 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 144

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

  • Page 145

    Operators 145 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 146

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

    Operators 147 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 lite 1.0 operands expression1 : object - numbers, strings, or vari...

  • Page 148

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

  • Page 149

    Operators 149 availability: actionscript 1.0; flash lite 1.0 - 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 e...

  • Page 150

    150 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 151

    Operators 151 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 152

    152 actionscript language elements this script displays the following result in the output panel: 0,1,2,3,4,5,6,7,8,9 != 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...

  • Page 153

    Operators 153 the following example illustrates the use of the inequality ( != ) operator in an if statement: var a:string = "david"; var b:string = "fool"; if (a != b) { trace("david is not a fool"); } the following example illustrates comparison by reference with two functions: var a:function = fu...

  • Page 154

    154 actionscript language elements 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 being compared: ■ numbers, strings, and boolean value...

  • Page 155

    Operators 155 returns boolean - if object is an instance of or a subclass of classconstructor , instanceof returns true , otherwise it returns false . Also, _global instanceof object returns false . See also typeof operator expression1 expression2 compares two expressions and determines whether expr...

  • Page 156

    156 actionscript language elements example the following examples show true and false returns for both numeric and string comparisons: trace(3 trace(10 trace("allen" trace("jack" trace("11" trace("11" trace("c" trace("a" lt less than (strings) operator expression1 lt expression2 deprecated since fla...

  • Page 157

    Operators 157 availability: actionscript 1.0; flash lite 1.0 - in flash 4, is a numeric operator. In flash 5 or later, the less 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 environmen...

  • Page 158

    158 actionscript language elements operands expression1 : object - numbers, strings, or variables. Expression2 : object - numbers, strings, or variables. Returns boolean - the result of the comparison. See also // line comment delimiter operator // comment indicates the beginning of a script comment...

  • Page 159

    Operators 159 performs a boolean operation on the values of one or both of the expressions. Evaluates expression1 (the expression on the left side of the operator) and returns false if the expression evaluates to false . If expression1 evaluates to true , expression2 (the expression on the right sid...

  • Page 160

    160 actionscript language elements and logical and operator condition1 and condition2 deprecated since flash player 5. Macromedia recommends that you use the logical and ( &&) operator. Performs a logical and ( &&) operation in flash player 4. If both expressions evaluate to true , the entire expres...

  • Page 161

    Operators 161 example in the following example, the variable happy is set to false . The if condition evaluates the condition !Happy , and if the condition is true , the trace() statement sends a string to the output panel. Var happy:boolean = false; if (!Happy) { trace("don't worry, be happy"); //t...

  • Page 162

    expression2 evaluates expression1 (the expression on the left side of the operator) and returns true if the expression evaluates to true . If expression1 evaluates to false , expression2 (the expression on the right side of the...

  • Page 163

    Operators 163 the following example demonstrates how using a function call as expression2 can lead to unexpected results. If the expression on the left of the operator evaluates to true , that result is returned without evaluating the expression on the right (the function fx2() is not called). Funct...

  • Page 164

    164 actionscript language elements % modulo operator expression1 % expression2 calculates the remainder of expression1 divided by expression2 . If either of the expression parameters are non-numeric, the modulo ( % ) operator attempts to convert them to numbers. The expression can be a number or str...

  • Page 165

    Operators 165 availability: actionscript 1.0; flash lite 1.0 - in flash 4 files, the % operator is expanded in the swf file as x - int(x/y) * y and may not be as fast or as accurate in later versions of flash player. Operands expression1 : number - a number or expression that evaluates to a number. ...

  • Page 166

    166 actionscript language elements the result, 6, is an integer. Usage 2: this statement multiplies the floating-point numbers 2.0 and 3.1416: trace(2.0 * 3.1416); // output: 6.2832 the result, 6.2832, is a floating-point number. *= multiplication assignment operator expression1 *= expression2 assig...

  • Page 167

    Operators 167 new operator new constructor() creates a new, initially anonymous, object and calls the function identified by the constructor parameter. The new operator passes to the function any optional parameters in parentheses, as well as the newly created object, which is referenced using the k...

  • Page 168

    168 actionscript language elements operands expression1 : object - numbers, strings, or variables. Expression2 : object - numbers, strings, or variables. Returns boolean - returns true if expression1 is not equal to expression2; false otherwise. See also != inequality operator {} object initializer ...

  • Page 169

    Operators 169 the following example creates an object account and initializes the properties name , address , city , state , zip , and balance with accompanying values: var account:object = {name:"macromedia, inc.", address:"600 townsend street", city:"san francisco", state:"california", zip:"94103"...

  • Page 170

    170 actionscript language elements usage 1: controls the order in which the operators execute in the expression. Parentheses override the normal precedence order and cause the expressions within the parentheses to be evaluated first. When parentheses are nested, the contents of the innermost parenth...

  • Page 171

    Operators 171 see also with statement === strict equality operator expression1 === expression2 tests two expressions for equality; the strict equality ( === )operator performs in the same way as the equality ( == ) operator, except that data types are not converted. The result is true if both expres...

  • Page 172

    172 actionscript language elements example the comments in the following code show the returned value of operations that use the equality and strict equality operators: // both return true because no conversion is done var string1:string = "5"; var string2:string = "5"; trace(string1 == string2); //...

  • Page 173

    Operators 173 !== strict inequality operator expression1 !== expression2 tests for the exact opposite of the strict equality ( === )operator. The strict inequality operator performs the same as the inequality operator except that data types are not converted. If expression1 is equal to expression2 ,...

  • Page 174

    logical or operator , == equality operator , === strict equality operator " string delimiter operator "text" when used before and after characters, quotation marks (") indicate ...

  • Page 175

    Operators 175 availability: actionscript 1.0; flash lite 1.0 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 - an integer or floating-point number. Example usage 1: the followi...

  • Page 176

    176 actionscript language elements example the following example uses the subtraction assignment ( -=) operator to subtract 10 from 5 and assign the result to the variable x : var x:number = 5; var y:number = 10; x -= y; trace(x); // output: -5 the following example shows how strings are converted t...

  • Page 177

    Operators 177 example usage 1: the following example declares a public variable named username whose type is string and assigns an empty string to it: var username:string = ""; usage 2: the following example shows how to specify a function's parameter type by defining a function named randomint() th...

  • Page 178

    178 actionscript language elements see also instanceof operator void operator void expression the void operator evaluates an expression and then discards its value, returning undefined . The void operator is often used in comparisons using the == operator to test for undefined values. Availability: ...

  • Page 179

    Statements 179 class defines a custom class, which lets you instantiate objects that share methods and properties that you define. Continue jumps past all remaining statements in the innermost loop and starts the next iteration of the loop as if control had passed through to the end of the loop norm...

  • Page 180

    180 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 181

    Statements 181 example the following example uses the break statement to exit an otherwise infinite loop: var i:number = 0; while (true) { trace(i); if (i >= 10) { break; // this will terminate/exit the loop } i++; } which traces the following output: 0 1 2 3 4 5 6 7 8 9 10 see also for statement ca...

  • Page 182

    182 actionscript language elements parameters expression: string - any expression. Example the following example defines conditions for the switch statement thismonth . If thismonth equals the expression in the case statement, the statement executes. Var thismonth:number = new date().Getmonth(); swi...

  • Page 183

    Statements 183 the name of the class must match the name of the external file that contains the class. The name of the external file must be the name of the class with the file extension .As appended. For example, if you name a class student, the file that defines the class must be named student.As....

  • Page 184

    184 actionscript language elements 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...

  • Page 185

    Statements 185 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.Com/flash/ images/imag...

  • Page 186

    186 actionscript language elements in a for loop, continue causes the flash interpreter to skip the rest of the loop body. In the following example, if the i modulo 3 equals 0, then the trace(i) statement is skipped: trace("example 3"); for (var i = 0; i if (i % 3 == 0) { continue; } trace(i); } in ...

  • Page 187

    Statements 187 example in the following example, the expression a does not equal the expressions b or d, so the statement following the default keyword is run and the trace() statement is sent to the output panel. Var dayofweek:number = new date().Getday(); switch (dayofweek) { case 1 : trace("monda...

  • Page 188

    188 actionscript language elements the delete operator can fail and return false if the reference parameter does not exist or cannot be deleted. You cannot delete predefined objects and properties, nor can you delete variables that are declared within a function with the var statement. You cannot us...

  • Page 189

    Statements 189 usage 4: the following example shows the behavior of delete on object references: var ref1:object = new object(); ref1.Name = "jody"; // copy the reference variable into a new variable // and delete ref1 ref2 = ref1; delete ref1; trace("ref1.Name "+ref1.Name); //output: ref1.Name unde...

  • Page 190

    190 actionscript language elements example the following example uses a do..While loop to evaluate whether a condition is true, and traces myvar until myvar is greater than 5. When myvar is greater than 5, the loop ends. Var myvar:number = 0; do { trace(myvar); myvar++; } while (myvar /* output: 0 1...

  • Page 191

    Statements 191 example in the following example, class person2 has not yet been marked as dynamic, so calling an undeclared function on it generates an error at compile time: class person2 { var name:string; var age:number; function person2(param_name:string, param_age:number) { trace ("anything"); ...

  • Page 192

    192 actionscript language elements else statement if (condition){ statement(s); } else { statement(s); } specifies the statements to run if the condition in the if statement returns false . The curly braces ( {} ) used to enclose the block of statements to be executed by the else statement are not n...

  • Page 193

    Statements 193 parameters condition: boolean - an expression that evaluates to true or false . 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>6...

  • Page 194

    194 actionscript language elements the following example shows the contents of a file called vehicle.As, which defines the vehicle class: class vehicle { var numdoors:number; var color:string; function vehicle(param_numdoors:number, param_color:string) { this.Numdoors = param_numdoors; this.Color = ...

  • Page 195

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

  • Page 196

    196 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 197

    Statements 197 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 enu...

  • Page 198

    198 actionscript language elements the following example shows using 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 myar...

  • Page 199

    Statements 199 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 200

    200 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 201

    Statements 201 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 202

    202 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 203

    Statements 203 import statement import classname import packagename.* note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla file's publish settings dialog box. This statement is supported in the actions panel as well as in external clas...

  • Page 204

    204 actionscript language elements interface statement interface interfacename [extends interfacename ] {} note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla file's publish settings dialog box. This keyword is supported only when use...

  • Page 205

    Statements 205 interface ib { function o():void; } class d implements ia, ib { function k():number { 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...

  • Page 206

    206 actionscript language elements intrinsic statement intrinsic class classname [extends superclass] [implements interfacename [, interfacename...] ] { //class definition here } allows compile-time type checking of previously defined classes. Flash uses intrinsic class declarations to enable compil...

  • Page 207

    Statements 207 return math.Pi*this.Radius*this.Radius; }; this.Getdiameter = function() { return 2*this.Radius; }; this.Setradius = function(param_radius) { this.Radius = param_radius; } } // actionscript 2.0 code that uses the circle class var mycircle:circle = new circle(5); trace(mycircle.Getarea...

  • Page 208

    208 actionscript language elements example the following example demonstrates how you can hide certain properties within a class using the private keyword. Create a new as file called login.As. Class login { private var loginusername:string; private var loginpassword:string; public function login(pa...

  • Page 209

    Statements 209 specifies that a variable or function is available to any caller. Because variables and functions are public by default, this keyword is used primarily for stylistic reasons. For example, you might want to use it for reasons of consistency in a block of code that also contains private...

  • Page 210

    210 actionscript language elements availability: actionscript 1.0; flash lite 2.0 returns string - the evaluated expression parameter, if provided. Parameters expression - a string, number, boolean, array, or object to evaluate and return as a value of the function. This parameter is optional. Examp...

  • Page 211

    Statements 211 example the following example creates a login class that demonstrates how the set keyword can be used to set private variables: class login { private var loginusername:string; private var loginpassword:string; public function login(param_username:string, param_password:string) { this....

  • Page 212

    212 actionscript language elements variables can hold any data type (for example, string, number, boolean, object, or movieclip). The timeline of each swf file and movie clip has its own set of variables, and each variable has its own value independent of variables on other timelines. Strict data ty...

  • Page 213

    Statements 213 see also var statement static statement class someclassname{ static var name; static function name() { // your statements here } } note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla file's publish settings dialog box. ...

  • Page 214

    214 actionscript language elements create a fla or as document in the same directory, and enter the following actionscript in frame 1 of the timeline: trace(users.Instances); var user1:users = new users(); trace(users.Instances); var user2:users = new users(); trace(users.Instances); see also privat...

  • Page 215

    Statements 215 switch statement switch (expression){caseclause: [defaultclause:] } creates a branching structure for actionscript statements. As with the if statement, the switch statement tests a condition and executes statements if the condition returns a value of true . All switch statements shou...

  • Page 216

    216 actionscript language elements see also === strict equality operator throw statement throw expression generates, or throws, an error that can be handled, or caught, by a catch{} code block. If an exception is not caught by a catch block, the string representation of the thrown value is sent to t...

  • Page 217

    Statements 217 in a fla or as file, enter the following actionscript in frame 1 of the timeline: import invalidemailaddress; function checkemail(email:string) { if (email.Indexof("@") == -1) { throw new invalidemailaddress(); } } try { checkemail("joe smith"); } catch (e) { this.Createtextfield("err...

  • Page 218

    218 actionscript language elements if the exception thrown is an object, the type will match if the thrown object is a subclass of the specified type. If an error of a specific type is thrown, the catch block that handles the corresponding error is executed. If an exception that is not of the specif...

  • Page 219

    Statements 219 in the following example, the finally block is used to delete an actionscript object, regardless of whether an error occurred. Create a new as file called account.As. Class account { var balance:number = 1000; function getaccountinfo():number { return (math.Round(math.Random() * 10) %...

  • Page 220

    220 actionscript language elements the following example shows a try code block with multiple, typed catch code blocks. Depending on the type of error that occurred, the try code block throws a different type of object. In this case, myrecordset is an instance of a (hypothetical) class named records...

  • Page 221

    Statements 221 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 recordset(); try { myrecords...

  • Page 222

    222 actionscript language elements 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 v...

  • Page 223

    Statements 223 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 , the loop exits. Va...

  • Page 224

    224 actionscript language elements the scope chain used by the with statement to resolve identifiers starts with the first item in the following list and continues to the last item: ■ the object specified in the object parameter in the innermost with statement. ■ the object specified in the object p...

  • Page 225

    Fscommand2 commands 225 the with statement is useful for accessing multiple items in a scope chain list simultaneously. In the following example, the built-in math object is placed at the front of the scope chain. Setting math as a default object resolves the identifiers cos , sin , and pi to math.C...

  • Page 226

    226 actionscript language elements getmaxsignallevel returns the maximum signal strength level as a numeric value. Getmaxvolumelevel returns the maximum volume level of the device as a numeric value. Getnetworkconnectionname returns the name of the active or default network connection. Getnetworkcon...

  • Page 227

    Fscommand2 commands 227 extendbacklightduration fscommand2 command extendbacklightduration extends the duration of a backlight for a specified period of time. If the duration is greater than zero, this command specifies the amount of time in seconds (maximum of 60 seconds) that the backlight should ...

  • Page 228

    228 actionscript language elements example the following example sets the size of the display area to the full screen: status = fscommand2("fullscreen", true); getbatterylevel fscommand2 command getbatterylevel returns the current battery level. It is a numeric value that ranges from 0 to the maximu...

  • Page 229

    Fscommand2 commands 229 some sample results and the devices they signify follow: d506i a mitsubishi 506i phone. Dfoma1 a mitsubishi foma1 phone. F506i a fujitsu 506i phone. Ffoma1 a fujitsu foma1 phone. N506i an nec 506i phone. Nfoma1 an nec foma1 phone. Nokia3650 a nokia 3650 phone. P506i a panason...

  • Page 230

    230 actionscript language elements example the following example sets status equal to the amount of free memory: status = fscommand2("getfreeplayermemory"); getmaxbatterylevel fscommand2 command getmaxbatterylevel returns the maximum battery level of the device. It is a numeric value greater than 0....

  • Page 231

    Fscommand2 commands 231 getmaxvolumelevel fscommand2 command getmaxvolumelevel returns the maximum volume level of the device as a numeric value. Availability: actionscript 1.0; flash lite 1.1 example the following example sets the maxvolume variable to the maximum volume level of the device: maxvol...

  • Page 232

    232 actionscript language elements getnetworkconnectstatus fscommand2 command getnetworkconnectstatus returns a value that indicates the current network connection status. Availability: actionscript 1.0; flash lite 1.1 example the following example assigns the network connection status to the connec...

  • Page 233

    Fscommand2 commands 233 getnetworkgeneration fscommand2 command getnetworkgeneration returns the generation of the current mobile wireless network, such as 2g (second generation of mobile wireless). Availability: actionscript 1.0; flash lite 2.0 example the following example shows syntax for returni...

  • Page 234

    234 actionscript language elements getnetworkrequeststatus fscommand2 command getnetworkrequeststatus returns a value indicating the status of the most recent http request. Availability: actionscript 1.0; flash lite 1.1 example the following example assigns the status of the most recent http request...

  • Page 235

    Fscommand2 commands 235 case 2: _root.Mytext += "pending request, contacting network" + ""; break; case 3: _root.Mytext += "pending request, resolving domain" + ""; break; case 4: _root.Mytext += "failed, network error" + ""; break; case 5: _root.Mytext += "failed, couldn't reach server" + "...

  • Page 236

    236 actionscript language elements networkstatus = fscommand2("getnetworkstatus"); switch(networkstatus) { case -1: _root.Mytext += "network status not supported" + ""; break; case 0: _root.Mytext += "no network registered" + ""; break; case 1: _root.Mytext += "on home network" + ""; break; ca...

  • Page 237

    Fscommand2 commands 237 getpowersource fscommand2 command getpowersource returns a value that indicates whether the power source is currently supplied from a battery or from an external power source. Availability: actionscript 1.0; flash lite 1.1 example the following example sets the mypower variab...

  • Page 238

    238 actionscript language elements gettotalplayermemory fscommand2 command gettotalplayermemory returns the total amount of heap memory, in kilobytes, allocated to flash lite. Availability: actionscript 1.0; flash lite 1.1 example the following example sets the status variable to the total amount of...

  • Page 239

    Fscommand2 commands 239 quit fscommand2 command quit causes the flash lite player to stop playback and exit. This command is supported only when flash lite is running in stand-alone mode. It is not supported when the player is running in the context of another application (for example, as a plug-in ...

  • Page 240

    240 actionscript language elements setfocusrectcolor fscommand2 command setfocusrectcolor sets the color of the focus rectangle to any color. The acceptable range of values for red, green, and blue is 0-255. For flash, you cannot change the default color of the focus rectangle, which is yellow. Avai...

  • Page 241

    Fscommand2 commands 241 the following table shows what effect each mode has, and what modes are substituted: availability: actionscript 1.0; flash lite 1.1 example the following line of code sets the input text type of the field associated with the input1 variable to receive numeric data: status = f...

  • Page 242

    242 actionscript language elements for backward compatibility with flash lite 1.1, the soft1 soft key is always mapped to the left key on the handset, and the soft2 soft key is always mapped to the right key on the handset. For the soft3 soft key and higher, the locations are dependent on each hands...

  • Page 243

    Fscommand2 commands 243 startvibrate fscommand2 command startvibrate starts the phone's vibration feature. If a vibration is already occurring, flash lite stops that vibration before starting the new one. Vibrations also stop when playback of the flash application is stopped or paused, and when the ...

  • Page 244

    244 actionscript language elements.

  • Page 245

    245 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 246

    246 actionscript classes property summary properties inherited from class object 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 lite 2.0 see also calle...

  • Page 248

    248 actionscript classes the array class should not be used to create associative arrays, which are different data structures that contain named elements instead of numbered elements. You should use the object class to create associative arrays (also called hashes). Although actionscript permits you...

  • Page 249

    Array 249 property summary properties inherited from class object constructor summary modifiers property description static caseinsensitive : number represents case-insensitive sorting. Static descending : number represents a descending sort order. Length : number a non-negative integer specifying t...

  • Page 250

    250 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: string ]) : string converts the elements in an array to strings, in...

  • Page 251

    Array 251 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 elemen...

  • Page 252

    252 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 253

    Array 253 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 itself. The array my_array is left unchanged. Availability: actionscript...

  • Page 254

    254 actionscript classes descending (array.Descending property) public static descending : number represents a descending sort order. You can use this constant for the options parameter in the sort() or sorton() method. The value of this constant is 2. Availability: actionscript 1.0; flash lite 2.0 ...

  • Page 255

    Array 255 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 (+), but the elements within each nested array remain separated by...

  • Page 256

    256 actionscript classes my_array.Length = 5; trace(my_array.Length); // my_array.Length is updated to 5 trace(my_array); // outputs: a,b,undefined,undefined,undefined numeric (array.Numeric property) public static numeric : number represents numeric sorting instead of string-based sorting. String-b...

  • Page 257

    Array 257 push (array.Push method) public push(value: object ) : number adds one or more elements to the end of an array and returns the new length of the array. Availability: actionscript 1.0; flash lite 2.0 parameters value: object - one or more values to append to the array. Returns number - an i...

  • Page 258

    258 actionscript classes reverse (array.Reverse method) public reverse() : void reverses the array in place. Availability: actionscript 1.0; flash lite 2.0 example the following example uses this method to reverse the array numbers_array : var numbers_array:array = new array(1, 2, 3, 4, 5, 6); trace...

  • Page 259

    Array 259 if you don't pass any parameters, a duplicate of the original array is created. Availability: actionscript 1.0; flash lite 2.0 parameters startindex: number [optional] - a number specifying the index of the starting point for the slice. If start is a negative number, the starting point beg...

  • Page 260

    260 actionscript classes sort (array.Sort method) public sort([comparefunction: object ], [options: number ]) : array sorts the elements in an array. Flash sorts according to unicode values. (ascii is a subset of unicode.) by default, array . Sort() works as described in the following list: ■ sortin...

  • Page 261

    Array 261 note: array.Sort() is defined in ecma-262, but the array sorting options introduced in flash player 7 are flash-specific extensions to the ecma-262 specification. Returns array - the return value depends on whether you pass any parameters, as described in the following list: ■ if you speci...

  • Page 262

    262 actionscript classes } } trace("unsorted:"); //displays unsorted: trace(passwords_array); //displays mom:glam,ana:ring,jay:mag,anne:home,regina:silly. //writes mom:glam,ana:ring,jay:mag,anne:home,regina:silly passwords_array.Sort(order); trace("sorted:"); //displays sorted: trace(passwords_array...

  • Page 263

    Array 263 you can use the options parameter to override the default sort behavior. If you want to sort a simple array (for example, an array with only one field), or if you want to specify a sort order that the options parameter doesn't support, use array.Sort() . To pass multiple flags, separate th...

  • Page 264

    264 actionscript classes var rec_array:array = new array(); rec_array.Push({name: "john", city: "omaha", zip: 68144}); rec_array.Push({name: "john", city: "kansas city", zip: 72345}); rec_array.Push({name: "bob", city: "omaha", zip: 94010}); for(i=0; i trace(rec_array[i].Name + ", " + rec_array[i].C...

  • Page 266

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

  • Page 267

    Array 267 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 separated by commas. To...

  • Page 268

    268 actionscript classes 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 lite 2.0 parameters value: object - one or more numbers, elements, or ...

  • Page 269

    Boolean 269 property summary properties inherited from class object constructor summary 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...

  • Page 270

    270 actionscript classes example the following code creates a new empty boolean object called myboolean : var myboolean:boolean = new boolean(); tostring (boolean.Tostring method) public tostring() : string returns the string representation ( "true" or "false" ) of the boolean object. Availability: ...

  • Page 272

    272 actionscript classes property summary modifiers property description _alpha : number the alpha transparency value of the button specified by my_btn. Enabled : boolean a boolean value that specifies whether a button is enabled. _focusrect : boolean a boolean value that specifies whether a button ...

  • Page 273

    Button 273 properties inherited from class object event summary _visible : boolean a boolean value that indicates whether the button specified by my_btn is visible. _width : number the width of the button, in pixels. _x : number an integer that sets the x coordinate of a button relative to the local...

  • Page 274

    274 actionscript classes 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 but...

  • Page 275

    Button 275 example the following code sets the _alpha property of a button named mybtn_btn to 50% when the user clicks the button. First, add a button instance on the stage. Second, give it an instance name of mybtn_btn. Lastly, with frame 1 selected, place the following code into the actions panel:...

  • Page 276

    276 actionscript classes _focusrect (button._focusrect property) public _focusrect : boolean a boolean value that specifies whether a button has a yellow rectangle around it when it has input focus. This property can override the global _focusrect property. By default, the _focusrect property of a b...

  • Page 277

    Button 277 getdepth (button.Getdepth method) public getdepth() : number returns the depth of the button instance. Each movie clip, button, and text field has a unique depth associated with it that determines how the object appears in front of or in back of other objects. Objects with higher depths a...

  • Page 278

    278 actionscript classes _height (button._height property) public _height : number the height of the button, in pixels. Availability: actionscript 1.0; flash lite 2.0 example the following example sets the height and width of a button called my_btn to a specified width and height. My_btn._width = 50...

  • Page 279

    Button 279 instance name of the button specified by my_btn . Availability: actionscript 1.0; flash lite 2.0 example the following example traces all instance names of any button instances within the current timeline of a swf file. For (i in this) { if (this[i] instanceof button) { trace(this[i]._nam...

  • Page 280

    280 actionscript classes ondragover (button.Ondragover handler) ondragover = function() {} invoked when the user presses the mouse button outside of the button and then drags the pointer over the button. You must define a function that is executed when the event handler is invoked. Note: the ondrago...

  • Page 281

    Button 281 example in the following example, a function that sends text to the output panel is defined for the onkeydown handler. Create a button called my_btn on the stage, and enter the following actionscript in a frame on the timeline: my_btn.Onkeydown = function() { trace("onkeydown: "+this._nam...

  • Page 282

    282 actionscript classes example in the following example, a function that sends text to the output panel is defined for the onkeydown handler . Create a button called my_btn on the stage, and enter the following actionscript in a frame on the timeline: my_btn.Onkeydown = function() { trace("onkeydo...

  • Page 283

    Button 283 parameters newfocus: object - the object that is receiving the focus. Example the following example demonstrates how statements can be executed when a button loses focus. Create a button instance on the stage called my_btn and add the following actionscript to frame 1 of the timeline: thi...

  • Page 284

    284 actionscript classes example in the following example, a function that sends a trace() statement to the output panel is defined for the onrelease handler: my_btn.Onrelease = function () { trace ("onrelease called"); }; onreleaseoutside (button.Onreleaseoutside handler) onreleaseoutside = functio...

  • Page 285

    Button 285 example in the following example, a function that sends a trace() statement to the output panel is defined for the onrollout handler: my_btn.Onrollout = function () { trace ("onrollout called"); }; onrollover (button.Onrollover handler) onrollover = function() {} invoked when the button g...

  • Page 286

    286 actionscript classes 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_...

  • Page 287

    Button 287 _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 following values: ■ "...

  • Page 288

    288 actionscript classes 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 con...

  • Page 289

    Button 289 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 290

    290 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 291

    Button 291 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 292

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

  • Page 293

    Button 293 when you click each button, the file name of the swf containing the buttons displays in the output panel. _visible (button._visible property) public _visible : boolean a boolean value that indicates whether the button specified by my_btn is visible. Buttons that are not visible ( _visible...

  • Page 294

    294 actionscript classes see also _width (movieclip._width property) _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 ...

  • Page 295

    Button 295 example the following example displays the x coordinate of the mouse position for the stage and a button called my_btn that is placed on the stage. Enter the following actionscript in frame 1 of the timeline: this.Createtextfield("mouse_txt", 999, 5, 5, 150, 40); mouse_txt.Html = true; mo...

  • Page 296

    296 actionscript classes example the following example scales a button called my_btn. When you click and release the button, it grows 10% on the x and y axis. Enter the following actionscript in frame 1 of the timeline: my_btn.Onrelease = function(){ this._xscale ~= 1.1; this._yscale ~= 1.1; }; see ...

  • Page 297

    Button 297 _ymouse (button._ymouse property) public _ymouse : number [read-only] returns the y coordinate of the mouse position relative to the button. Note: the _ymouse property is supported for flash lite 2.0 only if system.Capabilities.Hasmouse is true or system.Capabilities.Hasstylus is true . A...

  • Page 298

    298 actionscript classes _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 percentage. The default registration point is (0,0). Availability: actionscript 1.0; flash lite 2.0 example the fol...

  • Page 299

    Capabilities (system.Capabilities) 299 the following example shows a string for a mobile device: ■ that indicates a normal screen orientation ■ that is running an undetermined language ■ that is running the symbian7.0sseries60v2 operating system ■ thatis configured so the user can't access hard disk...

  • Page 300

    300 actionscript classes property summary modifiers property description static audiomimetypes : array [read-only] returns an array of mime types for audio codecs supported by a mobile device. Static avhardwaredisable : boolean [read-only] a boolean value that specifies whether access to the user's ...

  • Page 301

    Capabilities (system.Capabilities) 301 static hasembeddedvideo : boolean [read-only] a boolean value that is true if the player is running on a mobile device that supports embedded video; false otherwise. Static hasmappablesoftkeys : boolean returns true if the mobile device allows you to reset or r...

  • Page 302

    302 actionscript classes static hasscreenplayback : boolean [read-only] a boolean value that is true if the player supports the playback of screen broadcast applications that are being run through flash media server; false otherwise. Static hassharedobjects : boolean [read-only] returns true if the ...

  • Page 303

    Capabilities (system.Capabilities) 303 properties inherited from class object static localfilereaddisable : boolean [read- only] a boolean value that indicates whether read access to the user's hard disk has been administratively prohibited (true) or allowed (false). Static mimetypes : array [read-o...

  • Page 304

    304 actionscript classes method summary methods inherited from class object audiomimetypes (capabilities.Audiomimetypes property) public static audiomimetypes : array [read-only] returns an array of mime types for audio codecs supported by a mobile device. Availability: actionscript 1.0; flash lite ...

  • Page 305

    Capabilities (system.Capabilities) 305 has4waykeyas (capabilities.Has4waykeyas property) public static has4waykeyas : boolean [read-only] a boolean value that is true if the flash lite player executes the actionscript code associated with key event handlers that are associated with the left, right, ...

  • Page 306

    306 actionscript classes example the following example traces the value of this read-only property: trace(system.Capabilities.Hasaudio); hasaudioencoder (capabilities.Hasaudioencoder property) public static hasaudioencoder : boolean [read-only] specifies if the flash player can encode an audio strea...

  • Page 307

    Capabilities (system.Capabilities) 307 example the following example traces the value of this read-only property: trace(system.Capabilities.Hascompoundsound); hasdataloading (capabilities.Hasdataloading property) public static hasdataloading : boolean [read-only] returns true if the flash lite playe...

  • Page 308

    308 actionscript classes availability: actionscript 1.0; flash lite 2.0 example the following example traces the value of this read-only property: trace(system.Capabilities.Hasemail); hasembeddedvideo (capabilities.Hasembeddedvideo property) public static hasembeddedvideo : boolean [read-only] a boo...

  • Page 309

    Capabilities (system.Capabilities) 309 example the following example traces the value of this read-only property: trace(system.Capabilities.Hasmfi); hasmidi (capabilities.Hasmidi property) public static hasmidi : boolean [read-only] returns true if the mobile device is capable of playing sound data ...

  • Page 310

    310 actionscript classes example the following example traces the value of this read-only property: trace(system.Capabilities.Hasmouse); hasmp3 (capabilities.Hasmp3 property) public static hasmp3 : boolean [read-only] specifies if the mobile device has a mp3 decoder. A boolean value that is true if ...

  • Page 311

    Capabilities (system.Capabilities) 311 example the following example traces the value of this read-only property: trace(system.Capabilities.Hasqwertykeyboard); hasscreenbroadcast (capabilities.Hasscreenbroadcast property) public static hasscreenbroadcast : boolean [read-only] a boolean value that is...

  • Page 312

    312 actionscript classes otherwise, this property returns false . Availability: actionscript 1.0; flash lite 2.0 example the following example traces the value of this read-only property: trace(system.Capabilities.Hassharedobjects); hassmaf (capabilities.Hassmaf property) public static hassmaf : boo...

  • Page 313

    Capabilities (system.Capabilities) 313 availability: actionscript 1.0; flash lite 2.0 example the following example traces the value of this read-only property: trace(system.Capabilities.Hasstreamingaudio); hasstreamingvideo (capabilities.Hasstreamingvideo property) public static hasstreamingvideo :...

  • Page 314

    314 actionscript classes specifies if the flash player can encode a video stream. A boolean value that is true if the player can encode a video stream, such as that coming from a web camera; false otherwise. The server string is ve . Note: for flash lite 2.0, the value returned is always false . Ava...

  • Page 315

    Capabilities (system.Capabilities) 315 language (capabilities.Language property) public static language : string [read-only] indicates the language of the system on which the player is running. This property is specified as a lowercase two-letter language code from iso 639-1. For chinese, an additio...

  • Page 316

    316 actionscript classes availability: actionscript 1.0; flash lite 2.0 example the following example traces the value of this read-only property: trace(system.Capabilities.Language); localfilereaddisable (capabilities.Localfilereaddisable property) public static localfilereaddisable : boolean [read...

  • Page 317

    Capabilities (system.Capabilities) 317 mimetypes (capabilities.Mimetypes property) public static mimetypes : array [read-only] returns an array that contains all mime types that the loadmovie function, sound and video objects support. Availability: actionscript 1.0; flash lite 2.0 example the follow...

  • Page 318

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

  • Page 319

    Color 319 version (capabilities.Version property) public static version : string [read-only] a string that contains the flash player platform and version information (for example, "win 7,1,0,0" ). The server string is v . Availability: actionscript 1.0; flash lite 2.0 example the following example t...

  • Page 320

    320 actionscript classes property summary properties inherited from class object constructor summary method summary methods inherited from class object color constructor public color(target: object ) creates a color object for the movie clip specified by the target_mc parameter. You can then use the...

  • Page 321

    Color 321 parameters target: object - the instance name of a movie clip. Example the following example creates a color object called my_color for the movie clip my_mc and sets its rgb value to orange: var my_color:color = new color(my_mc); my_color.Setrgb(0xff9933); getrgb (color.Getrgb method) publ...

  • Page 322

    322 actionscript classes returns object - an object whose properties contain the current offset and percentage values for the specified color. Example the following example gets the transform object, and then sets new percentages for colors and alpha of my_mc relative to their current values. To see...

  • Page 323

    Color 323 settransform (color.Settransform method) public settransform(transformobject: object ) : void sets color transform information for a color object. The colortransformobject parameter is a generic object that you create from the new object constructor. It has parameters specifying the percen...

  • Page 324

    324 actionscript classes example this example creates a new color object for a target swf file, creates a generic object called mycolortransform with the properties defined above, and uses the settransform() method to pass the colortransformobject to a color object. To use this code in a flash (fla)...

  • Page 325

    Date 325 ■ mac os x - the date object automatically adjusts its output for daylight saving time. The time zone information database in mac os x is used to determine whether any date or time in the present or past should have a daylight saving time bias applied. ■ mac os 9 - the operating system prov...

  • Page 326

    326 actionscript classes 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 speci...

  • Page 327

    Date 327 getseconds () : number returns the seconds (an integer from 0 to 59) of the specified date object, according to local time. Gettime () : number returns the number of milliseconds since midnight january 1, 1970, universal time, for the specified date object. Gettimezoneoffset () : number ret...

  • Page 328

    328 actionscript classes getyear () : number returns the year of the specified date object, according to local time. 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. Setfullyear (year: number ...

  • Page 329

    Date 329 methods inherited from class object setutchours (hour: number , [minute: number ], [second: number ], [millisecond: number ]) : number sets the hour for the specified date object in universal time and returns the new time in milliseconds. Setutcmilliseconds (millisecond: number ) : number s...

  • Page 330

    330 actionscript classes 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() constructor takes up to ...

  • Page 331

    Date 331 hour: number [optional] - an integer from 0 (midnight) to 23 (11 p.M.). Minute: number [optional] - an integer from 0 to 59. Second: number [optional] - an integer from 0 to 59. Millisecond: number [optional] - an integer from 0 to 999 of milliseconds. Example the following example retrieve...

  • Page 332

    332 actionscript classes example the following example creates a new date object and concatenates the returned values of date.Getmonth() , date.Getdate() , and date.Getfullyear(): var today_date:date = new date(); var date_str:string = (today_date.Getdate()+"/ "+(today_date.Getmonth()+1)+"/"+today_d...

  • Page 333

    Date 333 returns number - an integer representing the year. Example the following example uses the constructor to create a date object. The trace statement shows the value returned by the getfullyear() method. Var my_date:date = new date(); trace(my_date.Getyear()); // displays 104 trace(my_date.Get...

  • Page 334

    334 actionscript classes getlocalelongdate (date.Getlocalelongdate method) public getlocalelongdate() : string returns a string representing the current date, in long form, formatted according to the currently defined locale. Note: the format of the date depends on the mobile device and the locale. ...

  • Page 335

    Date 335 example the following example uses the constructor to create a date object based on the current time. It also uses the getlocaleshortdate() method to return the current date, in short form, formatted according to the currently defined locale, as follows: var my_date:date = new date(); trace...

  • Page 336

    336 actionscript classes returns number - an integer. Example the following example uses the constructor to create a date object based on the current time and uses the getmilliseconds() method to return the milliseconds value from that object: var my_date:date = new date(); trace(my_date.Getmillisec...

  • Page 337

    Date 337 example the following example uses the constructor to create a date object based on the current time and uses the getmonth() method to return the month value from that object: var my_date:date = new date(); trace(my_date.Getmonth()); the following example uses the constructor to create a da...

  • Page 338

    338 actionscript classes availability: actionscript 1.0; flash lite 2.0 returns number - an integer. Example the following example uses the constructor to create a date object based on the current time, and uses the gettime() method to return the number of milliseconds since midnight january 1, 1970...

  • Page 339

    Date 339 returns number - an integer. Example the following example creates a new date object and uses date.Getutcdate() and date.Getdate() . The value returned by date.Getutcdate() can differ from the value returned by date.Getdate(), depending on the relationship between your local time zone and u...

  • Page 340

    340 actionscript classes getutcfullyear (date.Getutcfullyear method) public getutcfullyear() : number returns the four-digit year of the specified date object, according to universal time. Availability: actionscript 1.0; flash lite 2.0 returns number - an integer. Example the following example creat...

  • Page 341

    Date 341 example the following example creates a new date object and uses date.Getutchours() and date.Gethours() . The value returned by date.Getutchours() may differ from the value returned by date.Gethours(), depending on the relationship between your local time zone and universal time. Var today_...

  • Page 342

    342 actionscript classes returns number - an integer. Example the following example creates a new date object and uses getutcminutes() to return the minutes value from the date object: var today_date:date = new date(); trace(today_date.Getutcminutes()); getutcmonth (date.Getutcmonth method) public g...

  • Page 343

    Date 343 returns number - an integer. Example the following example creates a new date object and uses getutcseconds() to return the seconds value from the date object: var today_date:date = new date(); trace(today_date.Getutcseconds()); getutcyear (date.Getutcyear method) public getutcyear() : numb...

  • Page 344

    344 actionscript classes returns number - an integer. Example the following example creates a date object with the month and year set to may 2004. The date.Getyear() method returns 104, and date.Getfullyear() returns 2004: var today_date:date = new date(2004,4); trace(today_date.Getyear()); // outpu...

  • Page 345

    Date 345 setfullyear (date.Setfullyear method) public setfullyear(year: number , [month: number ], [date: number ]) : number sets the year of the specified date object, according to local time and returns the new time in milliseconds. If the month and date parameters are specified, they are set to l...

  • Page 346

    346 actionscript classes sethours (date.Sethours method) public sethours(hour: number ) : number sets the hours 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. Availabil...

  • Page 347

    Date 347 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 then uses date.Setmilliseconds() to change the milliseconds value to 575: var my_date:date = new date(2004,4,15,8,30,0,250); trace(my_...

  • Page 348

    348 actionscript classes parameters month: number - an integer from 0 (january) to 11 (december). Date: number [optional] - an integer 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 exampl...

  • Page 349

    Date 349 settime (date.Settime method) public settime(millisecond: number ) : number sets the date for the specified date object in milliseconds since midnight on january 1, 1970, and returns the new time in milliseconds. Availability: actionscript 1.0; flash lite 2.0 parameters millisecond: number ...

  • Page 350

    350 actionscript classes returns number - an integer. Example the following example initially creates a new date object with today's date, uses date.Setutcdate() to change the date value to 10, and changes it again to 25: var my_date:date = new date(); my_date.Setutcdate(10); trace(my_date.Getutcdat...

  • Page 351

    Date 351 example the following example initially creates a new date object with today's date, uses date.Setutcfullyear() to change the year value to 2001, and changes the date to may 25, 1995: var my_date:date = new date(); my_date.Setutcfullyear(2001); trace(my_date.Getutcfullyear()); // output: 20...

  • Page 352

    352 actionscript classes example the following example initially creates a new date object with today's date, uses date.Setutchours() to change the time to 8:30 a.M., and changes the time again to 5:30:47 p.M.: var my_date:date = new date(); my_date.Setutchours(8,30); trace(my_date.Getutchours()); /...

  • Page 353

    Date 353 setutcminutes (date.Setutcminutes method) public setutcminutes(minute: number , [second: number ], [millisecond: number ]) : number sets the minute for the specified date object in universal time and returns the new time in milliseconds. Availability: actionscript 1.0; flash lite 2.0 parame...

  • Page 354

    354 actionscript classes parameters month: number - an integer from 0 (january) to 11 (december). Date: number [optional] - an integer 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 exampl...

  • Page 355

    Date 355 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:30:45 a.M.: var my_date:date = new date(2004,4,15,8,0,0); trace(my_date.Getutcseconds()); // output: 0 my_date.Set...

  • Page 356

    356 actionscript classes 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 lite 2.0 returns string - a string. Example the following example returns the information in the dateof...

  • Page 357

    Error 357 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 is in local time and varies accordingly. For pacific da...

  • Page 358

    358 actionscript classes property summary properties inherited from class object constructor summary method summary methods inherited from class object modifiers property description message : string contains the message associated with the error object. Name : string contains the name of the error ...

  • Page 359

    Error 359 error constructor public error([message: string ]) creates a new error object. If message is specified, its value is assigned to the objects error.Message property. Availability: actionscript 1.0; flash lite 2.0 parameters message: string [optional] - a string associated with the error obj...

  • Page 360

    360 actionscript classes example in the following example, a function throws a specified message depending on the parameters entered into thenum . If two numbers can be divided, success and the number are shown. Specific errors are shown if you try to divide by 0 or enter only 1 parameter: function ...

  • Page 361

    Error 361 var thenum:number = dividenumber(1, 0); trace("success! "+thenum); // output: dividebyzeroerror -> unable to divide by zero. } catch (e_err:dividebyzeroerror) { // divide by zero error occurred trace(e_err.Name+" -> "+e_err.Tostring()); } catch (e_err:error) { // generic error occurred tra...

  • Page 363

    Extendedkey 363 see also getcode (key.Getcode method) property summary properties inherited from class object method summary methods inherited from class object modifiers property description static soft1 : string the key code value for the soft1 soft key. Static soft10 : string the key code value f...

  • Page 364

    364 actionscript classes soft1 (extendedkey.Soft1 property) public static soft1 : string the key code value for the soft1 soft key. The soft1 key code always corresponds to the left soft key; the soft2 always corresponds to the right soft key. Availability: actionscript 2.0; flash lite 2.0 example t...

  • Page 365

    Extendedkey 365 soft2 (extendedkey.Soft2 property) public static soft2 : string the key code value for the soft2 soft key. The soft2 key code always corresponds to the right soft key; the soft1 key code always corresponds to the left soft key. Availability: actionscript 2.0; flash lite 2.0 see also ...

  • Page 366

    366 actionscript classes availability: actionscript 2.0; flash lite 2.0 soft8 (extendedkey.Soft8 property) public static soft8 : string the key code value for the soft8 soft key. Availability: actionscript 2.0; flash lite 2.0 soft9 (extendedkey.Soft9 property) public static soft9 : string the key co...

  • Page 367

    Function 367 method summary methods inherited from class object apply (function.Apply method) public apply(thisobject: object , [argarray: array ]) specifies the value of thisobject to be used within any function that actionscript calls. This method also specifies the parameters to be passed to any ...

  • Page 368

    368 actionscript classes example the following function invocations are equivalent: math.Atan2(1, 0) math.Atan2.Apply(null, [1, 0]) the following simple example shows how apply() passes an array of parameters: function thefunction() { trace(arguments); } // create a new array to pass as a parameter ...

  • Page 369

    Function 369 see also call (function.Call method) call (function.Call method) public call(thisobject: object , [parameter1: object ]) invokes the function represented by a function object. Every function in actionscript is represented by a function object, so all functions support this method. In al...

  • Page 370

    370 actionscript classes 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 = new myobject();...

  • Page 371

    Key 371 property summary properties inherited from class object event summary 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 372

    372 actionscript classes method summary methods inherited from class object 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, al...

  • Page 373

    Key 373 example the following example creates a new listener object and defines a function for onkeydown and onkeyup . The last line uses addlistener() to register the listener with the key object so that it can receive notification from the key down and key up events. Var mylistener:object = new ob...

  • Page 374

    374 actionscript classes capslock (key.Capslock property) public static capslock : number the key code value for the caps lock key (20). Availability: actionscript 1.0; flash lite 2.0 control (key.Control property) public static control : number the key code value for the control key (17). Availabil...

  • Page 375

    key.Isdown(key.Backspace)) { canvas_mc.Clear(); } }; key.Addlistener(keylistener); when using this example, make sure that you select control > disable keyboard shortcuts in the test environment. Down (key.Down property) p...

  • Page 376

    376 actionscript classes end (key.End property) public static end : number the key code value for the end key (35). Availability: actionscript 1.0; flash lite 2.0 enter (key.Enter property) public static enter : number the key code value for the enter key (13).. Availability: actionscript 1.0; flash...

  • Page 377

    Key 377 when using this example, make sure that you select control > disable keyboard shortcuts in the test environment. Escape (key.Escape property) public static escape : number the key code value for the escape key (27). Availability: actionscript 1.0; flash lite 2.0 example the following example...

  • Page 378

    378 actionscript classes 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 t...

  • Page 379

    Key 379 example the following example calls the getcode() 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.Getcode() . The keylistener object is then registered to the key object, whic...

  • Page 380

    380 actionscript classes home (key.Home property) public static home : number the key code value for the home key (36). Availability: actionscript 1.0; flash lite 2.0 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 hom...

  • Page 381

    Key 381 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 panel. Var keylis...

  • Page 382

    382 actionscript classes left (key.Left property) public static left : number the key code value for the left arrow key (37). Availability: actionscript 1.0; flash lite 2.0 example the following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. A sound ...

  • Page 383

    Key 383 _listeners (key._listeners property) public static _listeners : array [read-only] a list of references to all listener objects registered with the key object. This property is intended for internal use, but may be useful if you want to ascertain the number of listeners currently registered w...

  • Page 384

    384 actionscript classes 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 fo...

  • Page 385

    Key 385 pgup (key.Pgup property) public static pgup : number the key code value for the page up key (33). Availability: actionscript 1.0; flash lite 2.0 example the following example rotates a movie clip called car_mc when you press the page down and page up keys. Var keylistener:object = new object...

  • Page 386

    386 actionscript classes example the following example moves a movie clip called car_mc using the left and right arrow keys. The listener is removed when you press escape, and car_mc no longer moves. Var keylistener:object = new object(); keylistener.Onkeydown = function() { switch (key.Getcode()) {...

  • Page 387

    Key 387 break; case key.Right : car_mc._x += distance; break; case key.Down : car_mc._y += distance; break; } }; key.Addlistener(keylistener_obj); shift (key.Shift property) public static shift : number the key code value for the shift key (16). Availability: actionscript 1.0; flash lite 2.0 example...

  • Page 388

    388 actionscript classes example the following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. A sound plays when you press the spacebar. Give a sound in the library a linkage identifier of horn_id for this example. Var distance:number = 10; var horn_...

  • Page 389

    Key 389 date_txt.Text = today_date.Tostring(); } }; key.Addlistener(keylistener); when using this example, make sure that you select control > disable keyboard shortcuts in the test environment. Up (key.Up property) public static up : number the key code value for the up arrow key (38). Availability...

  • Page 391

    Loadvars 391 property summary properties inherited from class object event summary constructor summary modifiers property description contenttype : string the mime type that is sent to the server when you call loadvars.Send() or loadvars.Sendandload() . Loaded : boolean a boolean value that indicate...

  • Page 392

    392 actionscript classes method summary methods inherited from class object addrequestheader (loadvars.Addrequestheader method) public addrequestheader(header: object , headervalue: string ) : void modifiers signature description addrequestheader (header: object , headervalue: string ) : void adds o...

  • Page 393

    Loadvars 393 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 headervalue . In the second usage, you pass an array of strings, alternating header names and header values. If multiple ...

  • Page 394

    394 actionscript classes 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. Availability: actionscript 1.0; flash lite 2.0 example...

  • Page 395

    Loadvars 395 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.Sendandload() . This method returns undefined if no load oper...

  • Page 396

    396 actionscript classes trace("an error occurred while loading variables."); } }; my_lv.Load("[place a valid url pointing to a text file here]"); see also load (loadvars.Load method) , sendandload (loadvars.Sendandload method) getbytestotal (loadvars.Getbytestotal method) public getbytestotal() : n...

  • Page 397

    Loadvars 397 my_lv.Onload = function(success:boolean) { 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...

  • Page 398

    398 actionscript classes parameters url: string - a string; the url from which to download the 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; for details, see the description section. Returns boolean - false if no parameter (...

  • Page 399

    Loadvars 399 loaded (loadvars.Loaded property) public loaded : boolean a boolean value that indicates whether a load or sendandload operation has completed, undefined by default. When a loadvars.Load() or loadvars.Sendandload() operation is started, the loaded property is set to false ; when the ope...

  • Page 400

    400 actionscript classes ondata (loadvars.Ondata handler) ondata = function(src: string ) {} invoked when data has completely downloaded from the server or when an error occurs while data is downloading from a server. This handler is invoked before the data is parsed and can be used to call a custom...

  • Page 401

    Loadvars 401 onload (loadvars.Onload handler) onload = function(success: boolean ) {} invoked when a loadvars.Load() or loadvars.Sendandload() operation has ended. If the operation was successful, my_lv is populated with variables downloaded by the operation, and these variables are available when t...

  • Page 402

    402 actionscript classes to view a more robust example, see the login.Fla file in the actionscript samples folder. Typical paths to the actionscript samples folder are: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applica...

  • Page 403

    Loadvars 403 the flash test environment always uses the get method. To test using the post method, be sure you are attempting to use it from within a browser. Availability: actionscript 1.0; flash lite 2.0 parameters url: string - a string; the url to which to upload variables. Target: string - a st...

  • Page 404

    404 actionscript classes 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 downloaded, parsed as variable data, and the resulting variables are plac...

  • Page 405

    Loadvars 405 example for the following example, add a textinput instance called name_ti , a textarea instance called result_ta , and a button instance called submit_button to the stage. When the user clicks the login button instance in the following example, two loadvars objects are created: send_lv...

  • Page 406

    406 actionscript classes returns string - a string. Example the following example instantiates a new loadvars() object, creates two properties, and uses tostring() to return a string containing both properties in url encoded format: var my_lv:loadvars = new loadvars(); my_lv.Name = "gary"; my_lv.Age...

  • Page 407

    Locale (mx.Lang.Locale) 407 property summary properties inherited from class object method summary methods inherited from class object constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) mod...

  • Page 408

    408 actionscript classes adddelayedinstance (locale.Adddelayedinstance method) public static adddelayedinstance(instance: object , stringid: string ) add the {instance, string id} pair into the internal array for later use. This is primarily used by flash when the strings replacement method is "auto...

  • Page 409

    Locale (mx.Lang.Locale) 409 initialize (locale.Initialize method) public static initialize() : void determine the language to use and begin xml loading. This is primarily used by flash when the strings replacement method is "automatically at runtime". Availability: actionscript 2.0; flash lite 2.0 l...

  • Page 410

    410 actionscript classes parameters langcode: string - a string representing a language code. Setloadcallback (locale.Setloadcallback method) public static setloadcallback(loadcallback: function ) set the callback function that will be called after the xml file is loaded. Availability: actionscript ...

  • Page 411

    Math 411 availability: actionscript 1.0; flash lite 2.0 - in flash player 4, the methods and properties of the math class are emulated using approximations and might not be as accurate as the non- emulated math functions that flash player 5 supports. Property summary properties inherited from class ...

  • Page 412

    412 actionscript classes method summary modifiers signature description static abs (x: number ) : number computes and returns an absolute value for the number specified by the parameter x. Static acos (x: number ) : number computes and returns the arc cosine of the number specified in the parameter ...

  • Page 413

    Math 413 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 lite 2.0 - in flash player 4, the methods and properties of the math cl...

  • Page 414

    414 actionscript classes 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 lite 2.0 - in flash player 4, the methods and properties of the math class are e...

  • Page 415

    Math 415 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.5707963267949 see also acos (math.Acos method) , atan (math.Atan method) , atan2 (math.Atan2 method) ...

  • Page 416

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

  • Page 417

    Math 417 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 com...

  • Page 418

    418 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 419

    Math 419 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) fl...

  • Page 420

    420 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 lite 2.0 - in flash player 4, the methods and properties ...

  • Page 421

    Math 421 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 422

    422 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 lite 2.0 - in flash player 4, the methods and properties of the math class are emulated using approximations and mig...

  • Page 423

    Math 423 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 424

    424 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 lite 2.0 - in flash player 4, the methods and properties of the math...

  • Page 425

    Math 425 random (math.Random method) public static random() : number returns a pseudo-random number n, where 0 random number because it is not generated by a truly random natural phenomenon such as radioactive decay. Availability: actionscript 1.0; flash lite 2.0 - in flash player 4, the methods and...

  • Page 426

    426 actionscript classes 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; } for (var i = 0; i trace(randrange(4, 11))...

  • Page 427

    Math 427 example the following example draws a circle using the mathematical constant pi, the sine of an angle, and the drawing api. Drawcircle(this, 100, 100, 50); // function drawcircle(mc:movieclip, x:number, y:number, r:number):void { mc.Linestyle(2, 0xff0000, 100); mc.Moveto(x+r, y); mc.Curveto...

  • Page 428

    428 actionscript classes example the following example uses math.Pow and math.Sqrt to calculate the length of a line. This.Createemptymovieclip("canvas_mc", this.Getnexthighestdepth()); var mouselistener:object = new object(); mouselistener.Onmousedown = function() { this.Origx = _xmouse; this.Origy...

  • Page 429

    Math 429 sqrt2 (math.Sqrt2 property) public static sqrt2 : number a mathematical constant for the square root of 2, with an approximate value of 1.4142135623730951. Availability: actionscript 1.0; flash lite 2.0 - in flash player 4, the methods and properties of the math class are emulated using app...

  • Page 430

    430 actionscript classes example the following example draws a circle using the mathematical constant pi, the tangent of an angle, and the drawing api. Drawcircle(this, 100, 100, 50); // function drawcircle(mc:movieclip, x:number, y:number, r:number):void { mc.Linestyle(2, 0xff0000, 100); mc.Moveto(...

  • Page 431

    Mouse 431 property summary properties inherited from class object event summary method summary methods inherited from class object constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) event d...

  • Page 432

    432 actionscript classes addlistener (mouse.Addlistener method) public static addlistener(listener: object ) : void registers an object to receive notifications of the onmousedown , onmousemove , and onmouseup listeners. The listener parameter should contain an object that has a defined method for a...

  • Page 433

    Mouse 433 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\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/a...

  • Page 434

    434 actionscript classes example the following example uses the drawing api to draw a rectangle when the user presses the mouse button, moves the mouse, and then releases the mouse button at runtime. This.Createemptymovieclip("canvas_mc", this.Getnexthighestdepth()); var mouselistener:object = new o...

  • Page 435

    Mouse 435 onmousemove (mouse.Onmousemove event listener) onmousemove = function() {} notified when the mouse moves. To use the onmousemove listener, you must create a listener object. You can then define a function for onmousemove and use addlistener() to register the listener with the mouse object,...

  • Page 436

    436 actionscript classes the following example sets the x and y positions of the pointer_mc movie clip instance to the x and y pointer positions. The device must support a stylus or mouse for this example to work. To use the example, you create a movie clip and set its linkage identifier to pointer_...

  • Page 437

    Mouse 437 example the following example uses the mouse pointer as a tool to draw lines using onmousemove and the drawing api. The user draws a line by moving the pointer and stops drawing the line by releasing the mouse button. This.Createemptymovieclip("canvas_mc", this.Getnexthighestdepth()); var ...

  • Page 438

    438 actionscript classes example the following example attaches three buttons to the stage, and lets the user draw lines in the swf file at runtime, using the mouse pointer. One button clears all of the lines from the swf file. The second button removes the mouse listener so the user cannot draw lin...

  • Page 440

    440 actionscript classes property summary modifiers property description _alpha : number the alpha transparency value of the movie clip. _currentframe : number [read-only] returns the number of the frame in which the playhead is located in the movie clip's timeline. _droptarget : string [read-only] ...

  • Page 441

    Movieclip 441 _rotation : number specifies the rotation of the movie clip, in degrees, from its original orientation. _soundbuftime : number specifies the number of seconds a sound prebuffers before it starts to stream. Tabchildren : boolean determines whether the children of a movie clip are includ...

  • Page 442

    442 actionscript classes properties inherited from class object event summary _ymouse : number [read-only] indicates the y coordinate of the mouse position. _yscale : number sets the vertical scale (percentage) of the movie clip as applied from the registration point of the movie clip. Constructor (...

  • Page 443

    Movieclip 443 onreleaseoutside = function() {} invoked when the mouse button is pressed inside the movie clip area and then released outside the movie clip area. Onrollout = function() {} invoked when the pointer moves outside a movie clip area. Onrollover = function() {} invoked when the pointer mo...

  • Page 444

    444 actionscript classes method summary modifiers signature description attachmovie (id: string , name: string , depth: number , [initobject: object ]) : movieclip takes a symbol from the library and attaches it to the movie clip. Beginfill (rgb: number , [alpha: number ]) : void indicates the begin...

  • Page 445

    Movieclip 445 getbytesloaded () : number returns the number of bytes that have already loaded (streamed) for the movie clip. Getbytestotal () : number returns the size, in bytes, of the movie clip. Getdepth () : number returns the depth of the movie clip instance. Getinstanceatdepth (depth: number )...

  • Page 446

    446 actionscript classes linestyle (thickness: number , rgb: number , alpha: number , pixelhinting: boolean , noscale: string , capsstyle: string , jointstyle: string , miterlimit: number ) : void specifies a line style that flash uses for subsequent calls to lineto() and curveto() until you call li...

  • Page 447

    Movieclip 447 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 are active,...

  • Page 448

    448 actionscript classes example the following code sets the _alpha property of a dynamically created movie clip named triangle to 50% when the mouse rolls over the movie clip. Add the following actionscript to your fla or as file: this.Createemptymovieclip("triangle", this.Getnexthighestdepth()); t...

  • Page 449

    Movieclip 449 initobject: object [optional] - (supported for flash player 6 and later) an object containing properties with which to populate the newly attached movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If initobject is not an object, it is ignored...

  • Page 450

    450 actionscript classes 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,...

  • Page 451

    Movieclip 451 parameters filltype: string - either the string " linear " or the string " radial ". Colors: array - an array of rgb hex color values to be used in the gradient (for example, red is 0xff0000, blue is 0x0000ff, and so on). Alphas: array - an array of alpha values for the corresponding c...

  • Page 452

    452 actionscript classes this code draws the following image on the screen: ■ 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 g...

  • Page 453

    Movieclip 453 this code draws the following image on the screen: see also beginfill (movieclip.Beginfill method) , endfill (movieclip.Endfill method) , linestyle (movieclip.Linestyle method) , lineto (movieclip.Lineto method) , moveto (movieclip.Moveto method) clear (movieclip.Clear method) public c...

  • Page 454

    454 actionscript classes an example is also in the drawingapi.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/m...

  • Page 455

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

  • Page 456

    456 actionscript classes 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 lite 2.0 parameters instanc...

  • Page 457

    Movieclip 457 an example is also in the animations.Fla file in the actionscript samples folder. The following list gives typical paths to this folder: ■ windows: windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/applications/mac...

  • Page 458

    458 actionscript classes parameters controlx: number - an integer that specifies the horizontal position of the control point relative to the registration point of the parent movie clip. Controly: number - an integer that specifies the vertical position of the control point relative to the registrat...

  • Page 459

    Movieclip 459 the following script uses the curveto() method and the math class to create a circle: this.Createemptymovieclip("circle2_mc", 2); circle2_mc.Linestyle(0, 0x000000); drawcircle(circle2_mc, 100, 100, 100); function drawcircle(mc:movieclip, x:number, y:number, r:number):void { mc.Moveto(x...

  • Page 460

    460 actionscript classes _droptarget (movieclip._droptarget property) public _droptarget : string [read-only] returns the absolute path in slash-syntax notation of the movie clip instance on which this movie clip was dropped. The _droptarget property always returns a path that starts with a slash ( ...

  • Page 461

    Movieclip 461 duplicatemovieclip (movieclip.Duplicatemovieclip method) public duplicatemovieclip(name: string , depth: number , [initobject: object ]) : movieclip creates an instance of the specified movie clip while the swf file is playing. Duplicated movie clips always start playing at frame 1, no...

  • Page 462

    462 actionscript classes example the following example duplicates a newly created movieclip a number of times and traces the target for each duplicate. Var container:movieclip = setupcontainer(); var ln:number = 10; var spacer:number = 1; var duplicate:movieclip; for(var i:number = 1; i var newy:num...

  • Page 463

    Movieclip 463 the enabled property only governs the button-like properties of a movie clip. You can change the enabled property at any time; the modified movie clip is immediately enabled or disabled. The enabled property can be read out of a prototype object. If enabled is set to false , the object...

  • Page 464

    464 actionscript classes see also beginfill (movieclip.Beginfill method) , begingradientfill (movieclip.Begingradientfill method) , moveto (movieclip.Moveto method) focusenabled (movieclip.Focusenabled property) public focusenabled : boolean if the value is undefined or false , a movie clip cannot r...

  • Page 465

    Movieclip 465 example this example demonstrates how to hide the yellow rectangle around a specified movie clip instance in a swf file when the instance has focus in a browser window. Create three movie clips called mc1_mc , mc2_mc , and mc3_mc , and add the following actionscript to frame 1 of the t...

  • Page 466

    466 actionscript classes example the following example uses the _framesloaded property to start a swf file when all the frames are loaded. If all the frames aren't loaded, the _xscale property of the bar_mc movie clip instance is increased proportionally to create a progress bar. Enter the following...

  • Page 467

    Movieclip 467 example the following example creates a movie clip called square_mc . The code draws a square for that movie clip and uses movieclip.Getbounds() to display the coordinate values of the instance in the output panel. This.Createemptymovieclip("square_mc", 1); square_mc._x = 10; square_mc...

  • Page 468

    468 actionscript classes example the following example uses the _framesloaded property to start a swf file when all the frames are loaded. If all the frames aren't loaded, the _xscale property of the loader movie clip instance is increased proportionally to create a progress bar. Enter the following...

  • Page 469

    Movieclip 469 enter the following actionscript in frame 1 of the timeline: var pctloaded:number = math.Round(this.Getbytesloaded()/ this.Getbytestotal()*100); bar_mc._xscale = pctloaded; add the following code to frame 2: if (this._framesloaded this.Gotoandplay(1); } else { this.Gotoandstop(3); } pl...

  • Page 470

    470 actionscript classes see also getinstanceatdepth (movieclip.Getinstanceatdepth method) , getnexthighestdepth (movieclip.Getnexthighestdepth method) , swapdepths (movieclip.Swapdepths method) , getdepth (textfield.Getdepth method) , getdepth (button.Getdepth method) getinstanceatdepth (movieclip....

  • Page 471

    Movieclip 471 see also attachmovie (movieclip.Attachmovie method) , duplicatemovieclip (movieclip.Duplicatemovieclip method) , createemptymovieclip (movieclip.Createemptymovieclip method) , getdepth (movieclip.Getdepth method) , getnexthighestdepth (movieclip.Getnexthighestdepth method) , swapdepths...

  • Page 472

    472 actionscript classes example the following example draws thre movie clip instances, using the getnexthighestdepth() method as the depth parameter of the createemptymovieclip() method, and labels each movie clip them with its depth: for (i = 0; i drawclip(i); } function drawclip(n:number):void { ...

  • Page 473

    Movieclip 473 returns number - an integer that specifies the flash player version that was targeted when the swf file loaded into the movie clip was published. Example the following example creates a new container and outputs the value of getswfversion() . It then uses moviecliploader to load an ext...

  • Page 474

    474 actionscript classes parameters url: string - the url from which to obtain the document. Window: string [optional] - a parameter specifying the name, frame, or expression that specifies the window or html frame that the document is loaded into. You can also use one of the following reserved targ...

  • Page 475

    Movieclip 475 you must first create a generic object that has two properties, x and y. These x and y values (and they must be called x and y) are called the global coordinates because they relate to the top-left corner of the stage. The x property represents the horizontal offset from the top-left c...

  • Page 476

    476 actionscript classes you can extend the methods and event handlers of the movieclip class by creating a subclass. Availability: actionscript 1.0; flash lite 2.0 parameters pt: object - the name or identifier of an object created with the generic object class. The object specifies the x and y coo...

  • Page 477

    Movieclip 477 gotoandplay (movieclip.Gotoandplay method) public gotoandplay(frame: object ) : void starts playing the swf file at the specified frame. To specify a scene as well as a frame, use gotoandplay() . You can extend the methods and event handlers of the movieclip class by creating a subclas...

  • Page 478

    478 actionscript classes 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 gotoandstop() . You can extend the methods and event handlers ...

  • Page 479

    Movieclip 479 example the following code example displays the height and width of a movie clip in the output panel: this.Createemptymovieclip("image_mc", this.Getnexthighestdepth()); var image_mcl:moviecliploader = new moviecliploader(); var mcllistener:object = new object(); mcllistener.Onloadinit ...

  • Page 480

    480 actionscript classes hitarea (movieclip.Hitarea property) public hitarea : object designates another movie clip to serve as the hit area for a movie clip. If the hitarea property does not exist or is null or undefined , the movie clip itself is used as the hit area. The value of the hitarea prop...

  • Page 481

    Movieclip 481 usage 2: evaluates the bounding boxes of the target and specified instance, and returns true if they overlap or intersect at any point. Parameters x: number the x coordinate of the hit area on the stage. Y: number the y coordinate of the hit area on the stage. The x and y coordinates a...

  • Page 482

    482 actionscript classes linestyle (movieclip.Linestyle method) public linestyle(thickness: number , rgb: number , alpha: number , pixelhinting: boolean , noscale: string , capsstyle: string , jointstyle: string , miterlimit: number ) : void specifies a line style that flash uses for subsequent call...

  • Page 483

    Movieclip 483 see also beginfill (movieclip.Beginfill method) , begingradientfill (movieclip.Begingradientfill method) , clear (movieclip.Clear method) , curveto (movieclip.Curveto method) , lineto (movieclip.Lineto method) , moveto (movieclip.Moveto method) lineto (movieclip.Lineto method) public l...

  • Page 484

    484 actionscript classes 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 loadm...

  • Page 485

    Movieclip 485 parameters url: string - the absolute or relative url of the swf or jpeg file to be loaded. A relative path must be relative to the swf file at level 0. Absolute urls must include the protocol reference, such as http:// or file:/// . Method: string [optional] - specifies an http method...

  • Page 486

    486 actionscript classes the loadvariables method can also be used to update variables in the active movie clip with new values. The loadvariables method requires that the text of the url be in the standard mime format: application/x-www-form-urlencoded (cgi script format). In swf files running in a...

  • Page 487

    Movieclip 487 example the following example loads information from a text file called params.Txtinto the target_mc movie clip that is created by using createemptymovieclip() . The setinterval() function is used to check the loading progress. The script checks for a variable in the params.Txt file na...

  • Page 488

    488 actionscript classes you must first create a generic object that has two properties, x and y. These x and y values (and they must be called x and y) are called the local coordinates because they relate to the top-left corner of the movie clip. The x property represents the horizontal offset from...

  • Page 489

    Movieclip 489 parameters pt: object - the name or identifier of an object created with the object class, specifying the x and y coordinates as properties. Example the following example converts x and y coordinates of the my_mc object, from the movie clip's (local) coordinates to the stage (global) c...

  • Page 490

    490 actionscript classes if you don't have access to chess.Fla (for example, if you are loading chess.Swf from someone else's site into chess_mc ), you can set the chess.Swf _lockroot property when you load it. Place the following actionscript on the main timeline of games.Fla: chess_mc._lockroot = ...

  • Page 491

    Movieclip 491 the lockroot.Swf file has _ lockroot applied to it, and nolockroot.Swf does not. After the files are loaded, each file dumps variables from their _root scopes. Place the following actionscript on the main timeline of a fla document: this.Createemptymovieclip("lockroot_mc", this.Getnext...

  • Page 492

    492 actionscript classes which then traces the following: 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 myothervar -> 2 myvar -> 1 from lockroot.Swf myothervar -> 2 myvar -> 1 s...

  • Page 493

    Movieclip 493 example the following example draws a triangle with a 5-pixel, solid magenta line and a partially transparent blue fill: this.Createemptymovieclip("triangle_mc", 1); triangle_mc.Beginfill(0x0000ff, 30); triangle_mc.Linestyle(5, 0xff00ff, 100); triangle_mc.Moveto(200, 200); triangle_mc....

  • Page 494

    494 actionscript classes example the following example uses _framesloaded and nextframe() to load content into a swf file. Do not add any code to frame 1, but add the following actionscript to frame 2 of the timeline: if (this._framesloaded >= 3) { this.Nextframe(); } else { this.Gotoandplay(1); } t...

  • Page 495

    Movieclip 495 the last function uses onclipevent(data). The onclipevent() event handler is invoked for any movie clip that receives data, whether the movie clip is in the library or not. Therefore, the last function in this example is invoked when symbol_mc is instantiated and also when replacement....

  • Page 496

    496 actionscript classes example the following example defines a function for the ondragout method that sends a trace() action to the output panel: my_mc.Ondragout = function () { trace ("ondragout called"); } see also ondragover (movieclip.Ondragover handler) ondragover (movieclip.Ondragover handle...

  • Page 497

    Movieclip 497 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 extends the movieclip class or that is linked to a symbol in the library. Availability: actionscript 1.0; flash lite 2.0 example the following...

  • Page 498

    498 actionscript classes the movie clip must have focus for the onkeydown event handler to work. Add the following actionscript to set input focus: my_mc.Tabenabled = true; my_mc.Focusenabled = true; selection.Setfocus(my_mc); when you tab to the movie clip and press a key, key was pressed is displa...

  • Page 499

    Movieclip 499 the following example sets input focus: my_mc.Focusenabled = true; selection.Setfocus(my_mc); see also getascii (key.Getascii method) , getcode (key.Getcode method) , focusenabled (movieclip.Focusenabled property) , setfocus (selection.Setfocus method) , onkeydown (key.Onkeydown event ...

  • Page 500

    500 actionscript classes onload (movieclip.Onload handler) onload = function() {} invoked when the movie clip is instantiated and appears in the timeline. 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 e...

  • Page 501

    Movieclip 501 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 define the function on the timeline or in a class file that extends the movieclip class ...

  • Page 502

    502 actionscript classes onmouseup (movieclip.Onmouseup handler) onmouseup = function() {} invoked when the mouse button is released. 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 extends the movieclip ...

  • Page 503

    Movieclip 503 example the following example defines a function for the onrelease method that sends a trace() action to the output panel: my_mc.Onrelease = function () { trace ("onrelease called"); } onreleaseoutside (movieclip.Onreleaseoutside handler) onreleaseoutside = function() {} invoked when t...

  • Page 504

    504 actionscript classes example the following example defines a function for the onrollout method that sends a trace() action to the output panel: my_mc.Onrollout = function () { trace ("onrollout called"); } onrollover (movieclip.Onrollover handler) onrollover = function() {} invoked when the poin...

  • Page 505

    Movieclip 505 example the following example displays information about the movie clip that receives input 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 = void;...

  • Page 506

    506 actionscript classes you can use _parent to move up multiple levels in the display list as in the following: this._parent._parent._alpha = 20; availability: actionscript 1.0; flash lite 2.0 example the following example traces the reference to a movie clip and its relationship to the main timeli...

  • Page 507

    Movieclip 507 use the following actionscript to play the timeline of a movie clip in a swf file. This actionscript is for a button called my_btn on the main timeline that plays a movie clip called animation_mc : animation_mc.Stop(); my_btn.Onrelease = function(){ animation_mc.Play(); }; see also pla...

  • Page 508

    508 actionscript classes see also prevframe function _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. The _quality property can be set to...

  • Page 509

    Movieclip 509 removemovieclip (movieclip.Removemovieclip method) public removemovieclip() : void removes a movie clip instance created with duplicatemovieclip() , movieclip.Duplicatemovieclip() , movieclip.Createemptymovieclip() , or movieclip.Attachmovie() . This method does not remove a movie clip...

  • Page 510

    510 actionscript classes example each time you click a button in the following example, you attach a movie clip instance to the stage in a random position. When you click a movie clip instance, you remove that instance from the swf file. Function randrange(min:number, max:number):number { var randnu...

  • Page 511

    Movieclip 511 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 512

    512 actionscript classes 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._sound...

  • Page 513

    Movieclip 513 left: number [optional] - value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. Top: number [optional] - value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. R...

  • Page 514

    514 actionscript classes 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 ...

  • Page 515

    Movieclip 515 see also _droptarget (movieclip._droptarget property) , startdrag (movieclip.Startdrag method) , stopdrag function 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 spe...

  • Page 516

    516 actionscript classes 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...

  • Page 517

    Movieclip 517 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 defines at le...

  • Page 518

    518 actionscript classes 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 rela...

  • Page 519

    Movieclip 519 _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 lite 2.0 example in the following example, two movie clip bu...

  • Page 520

    520 actionscript classes you can change the trackasmenu property at any time; the modified movie clip immediately takes on the new behavior. Note: this property is supported in flash lite only if system.Capabilities.Hasmouse is true or system.Capabilities.Hasstylus is true . Availability: actionscri...

  • Page 521

    Movieclip 521 example the following example unloads a movie clip instance called box when a user clicks the box movie clip: this.Createemptymovieclip("box", 1); with (box) { linestyle(1, 0xcccccc); beginfill(0x4827cf); moveto(0, 0); lineto(80, 0); lineto(80, 60); lineto(0, 60); lineto(0, 0); endfill...

  • Page 522

    522 actionscript classes example the following example displays the url of the image that is loaded into the image_mc instance in the output panel. This.Createemptymovieclip("image_mc", 1); var mcllistener:object = new object(); mcllistener.Onloadinit = function(target_mc:movieclip) { trace("_url: "...

  • Page 523

    Movieclip 523 _width (movieclip._width property) public _width : number the width of the movie clip, in pixels. Availability: actionscript 1.0; flash lite 2.0 - as a read-only property. Example the following code example displays the height and width of a movie clip in the output panel: this.Createe...

  • Page 524

    524 actionscript classes _xmouse (movieclip._xmouse property) public _xmouse : number [read-only] returns the x coordinate of the mouse position. Note: this property is supported in flash lite only if system.Capabilities.Hasmouse is true or system.Capabilities.Hasstylus is true . Availability: actio...

  • Page 525

    Movieclip 525 example the following example creates a movie clip called box_mc at runtime. The drawing api is used to draw a box in this instance, and when the mouse rolls over the box, horizontal and vertical scaling is applied to the movie clip. When the mouse rolls off the instance, it returns to...

  • Page 526

    526 actionscript classes _y (movieclip._y property) public _y : number sets the y 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 movie ...

  • Page 527

    Movieclip 527 see also mouse , _xmouse (movieclip._xmouse property) _yscale (movieclip._yscale property) public _yscale : number sets the vertical scale ( percentage ) of the movie clip as applied from the registration point of the movie clip. The default registration point is (0,0). Scaling the loc...

  • Page 529

    Moviecliploader 529 property summary properties inherited from class object event summary constructor summary constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype (object.Prototype property) , __resolve (object.__resolve property) event description onloadcomp...

  • Page 530

    530 actionscript classes 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: actionscript 1.0; fl...

  • Page 531

    Moviecliploader 531 parameters listener: object - an object that listens for a callback notification from the moviecliploader event handlers. Returns boolean - a boolean value. The return value is true if the listener was established successfully; otherwise the return value is false . Example the fo...

  • Page 532

    532 actionscript classes getprogress (moviecliploader.Getprogress method) public getprogress(target: object ) : object returns the number of bytes loaded and total number of bytes for a file that is being loaded by using moviecliploader.Loadclip() ; for compressed movies, the getprogress method refl...

  • Page 533

    Moviecliploader 533 trace(">> checking progress now with : " + interval.Id); var progress:object = mcloader.Getprogress(image); trace("bytesloaded: " + progress.Bytesloaded + " bytestotal: " + progress.Bytestotal); if(progress.Bytesloaded == progress.Bytestotal) { clearinterval(interval.Id); } } see...

  • Page 534

    534 actionscript classes you can use the loadclip() method to load one or more files into a single movie clip or level; moviecliploader listener objects are passed to the loading target movie clip instance as a parameter. Alternatively, you can create a different moviecliploader object for each file...

  • Page 535

    Moviecliploader 535 create an empty movieclip and use the moviecliploader to load an image into it. Var container:movieclip = createemptymovieclip("container", getnexthighestdepth()); var mcloader:moviecliploader = new moviecliploader(); mcloader.Addlistener(this); mcloader.Loadclip("yourimage.Jpg",...

  • Page 536

    536 actionscript classes when you use the onloadcomplete and onloadinit events with the moviecliploader class, it's important to understand how this differs from the way they work with your swf file. The onloadcomplete event is called after the swf or jpeg file is loaded, but before the application ...

  • Page 537

    Moviecliploader 537 onloaderror (moviecliploader.Onloaderror event listener) onloaderror = function(target_mc, errorcode) {} invoked when a file loaded with moviecliploader.Loadclip() has failed to load. This listener can be invoked for various reasons, including if the server is down, if the file i...

  • Page 538

    538 actionscript classes var image_mcl:moviecliploader = new moviecliploader(); image_mcl.Addlistener(mcllistener); image_mcl.Loadclip("http://www.Fakedomain.Com/images/bad_hair_day.Jpg", image_mc); see also addlistener (moviecliploader.Addlistener method) , loadclip (moviecliploader.Loadclip method...

  • Page 539

    Moviecliploader 539 var timerms:number = target_mc.Completetimer-target_mc.Starttimer; target_mc.Createtextfield("timer_txt", target_mc.Getnexthighestdepth(), 0, target_mc._height, target_mc._width, 22); target_mc.Timer_txt.Text = "loaded in "+timerms+" ms."; }; var image_mcl:moviecliploader = new m...

  • Page 540

    540 actionscript classes parameters target_mc: movieclip [optional] a movie clip loaded by a moviecliploader.Loadclip() method. Loadedbytes: number the number of bytes that had been loaded when the listener was invoked. Totalbytes: number the total number of bytes in the file being loaded. Availabil...

  • Page 541

    Moviecliploader 541 onloadstart (moviecliploader.Onloadstart event listener) onloadstart = function([target_mc]) {} invoked when a call to moviecliploader.Loadclip() has successfully begun to download a file. Call this listener on a listener object that you add using moviecliploader.Addlistener() . ...

  • Page 542

    542 actionscript classes see also addlistener (moviecliploader.Addlistener method) , loadclip (moviecliploader.Loadclip method) , onloaderror (moviecliploader.Onloaderror event listener) , onloadinit (moviecliploader.Onloadinit event listener) , onloadcomplete (moviecliploader.Onloadcomplete event l...

  • Page 543

    Moviecliploader 543 var image_mcl:moviecliploader = new moviecliploader(); // start_button.Clickhandler = function() { trace("starting..."); start_button.Enabled = false; stop_button.Enabled = true; // image_mcl.Addlistener(mcllistener); image_mcl.Loadclip("http://www.Helpexamples.Com/flash/images/ ...

  • Page 544

    544 actionscript classes example the following example loads an image into a movie clip called image_mc . If you click the movie clip, the movie clip is removed and information is displayed in the output panel. This.Createemptymovieclip("image_mc", this.Getnexthighestdepth()); var mcllistener:object...

  • Page 545

    Number 545 the following example assigns the value of the min_value property to a variable declared without the use of the constructor: var smallest:number = number.Min_value; availability: actionscript 1.0; flash lite 2.0 - (became a native object in flash player 6, which improved performance signi...

  • Page 546

    546 actionscript classes 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.79e+308. Availability: actionscript 1.0; flash lite 2.0 exam...

  • Page 547

    Number 547 example the following actionscript displays the largest and smallest representable numbers to the output panel to the log file. Trace("number.Min_value = "+number.Min_value); trace("number.Max_value = "+number.Max_value); this code displays the following values: number.Min_value = 4.94065...

  • Page 548

    548 actionscript classes number constructor public number(num: object ) creates a new number object. The new number constructor is primarily used as a placeholder. A number object is not the same as the number() function that converts a parameter to a primitive value. Availability: actionscript 1.0;...

  • Page 549

    Number 549 tostring (number.Tostring method) public tostring(radix: number ) : string returns the string representation of the specified number object ( mynumber ). Availability: actionscript 1.0; flash lite 2.0 parameters radix: number - specifies the numeric base (from 2 to 36) to use for the numb...

  • Page 550

    550 actionscript classes object object public class object the object class is at the root of the actionscript class hierarchy. This class contains a small subset of the features provided by the javascript object class. Availability: actionscript 1.0; flash lite 2.0 - (became a native object in flas...

  • Page 551

    Object 551 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 name . W...

  • Page 552

    552 actionscript classes if invoked incorrectly, object.Addproperty() can fail with an error. The following table describes errors that can occur: availability: actionscript 1.0; flash lite 2.0 - in actionscript 2.0 classes, you can use get or set instead of this method. Parameters name: string - a ...

  • Page 553

    Object 553 function book() { this.Setquantity = function(numbooks:number):void { this.Books = numbooks; }; this.Getquantity = function():number { return this.Books; }; this.Gettitle = function():string { return "catcher in the rye"; }; this.Addproperty("bookcount", this.Getquantity, this.Setquantity...

  • Page 554

    554 actionscript classes the following example shows how to use the implicit getter and setter functions available in actionscript 2.0. Rather than defining the book function and editing book.Prototype , you define the book class in an external file named book.As. The following code must be in a sep...

  • Page 555

    Object 555 if you use the instanceof operator, you can also determine if an object belongs to a specified class: var my_str:string = new string("sven"); trace(my_str instanceof string); //output: true however, in the following example the object.Constructor property converts primitive data types (su...

  • Page 556

    556 actionscript classes properties that you create are enumerable, but built-in properties are generally not enumerable. Availability: actionscript 1.0; flash lite 2.0 parameters name: string - returns boolean - a boolean value: true if the property specified by the name parameter is enumerable. Ex...

  • Page 557

    Object 557 returns boolean - a boolean value: true if the object is in the prototype chain of the object specified by the theclass parameter; false otherwise. Object constructor public object() creates an object object and stores a reference to the object's constructor method in the object's constru...

  • Page 558

    558 actionscript classes the following trace statements show that the __proto_ property of both instances refers to the prototype property of the circle class. Trace(circle.Prototype == onecircle.__proto__); // output: true trace(circle.Prototype == twocircle.__proto__); // output: true see also pro...

  • Page 559

    Object 559 the following trace statement shows how you can use the prototype property and the __proto__ property together to move two levels up the inheritance hierarchy (or prototype chain). The circle.Prototype.__proto__ property contains a reference to the superclass of the shape class. Trace(cir...

  • Page 560

    560 actionscript classes parameters name: string - string; the linkage identifier of the movie clip symbol or the string identifier for the actionscript class. Theclass: function - a reference to the constructor function of the actionscript class or null to unregister the symbol. Returns boolean - a...

  • Page 561

    Object 561 usage 1: the following example uses __resolve to build an object where every undefined property returns the value "hello, world!" . // instantiate a new object var myobject:object = new object(); // define the __resolve function myobject.__resolve = function (name) { return "hello, world!...

  • Page 562

    562 actionscript classes this.Myfunction(name); }; // create a new object method and assign it the reference this[name] = f; // return the reference return f; }; // test __resolve using undefined method names // __resolve will only be called once for each method name myobject.Somemethod(); // calls ...

  • Page 563

    Object 563 // define a generic function for __resolve to call myobject.Myfunction = function (name) { arguments.Shift(); trace("method " + name + " was called with arguments: " + arguments.Join(',')); }; // define the __resolve function myobject.__resolve = function (name) { // reserve the name "ons...

  • Page 564

    564 actionscript classes example this example shows the return value for tostring() on a generic object: var myobject:object = new object(); trace(myobject.Tostring()); // output: [object object] this method can be overridden to return a more meaningful value. The following examples show that this m...

  • Page 565

    Object 565 // output: a vehicle that is red and has 2 doors // for comparison purposes, this is a call to valueof() // there is no primitive value of myvehicle, so the object is returned // giving the same output as tostring(). Trace(myvehicle.Valueof()); // output: a vehicle that is red and has 2 d...

  • Page 566

    566 actionscript classes example the following example shows the return value of valueof() for a generic object (which does not have a primitive value) and compares it to the return value of tostring(). First, create a generic object. Second, create a new date object set to february 1, 2004, 8:15 am...

  • Page 567

    Object 567 you can use the return statement in your callback method definition to affect the value of the property you are watching. The value returned by your callback method is assigned to the watched object property. The value you choose to return depends on whether you wish to monitor, modify or...

  • Page 568

    568 actionscript classes userdata: object [optional] - an arbitrary piece of actionscript data that is passed to the callback method. If the userdata parameter is omitted, undefined is passed to the callback method. Returns boolean - a boolean value: true if the watchpoint is created successfully, f...

  • Page 570

    570 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 calling swf file or in any other swf fi...

  • Page 571

    Security (system.Security) 571 also, for files running in flash player 7 or later, you can't use this method to let swf files hosted using a secure protocol (https) allow access from swf files hosted in nonsecure protocols; you must use system.Security.Allowinsecuredomain() instead. Occasionally, yo...

  • Page 572

    572 actionscript classes see also onloadcomplete (moviecliploader.Onloadcomplete event listener) , _parent (movieclip._parent property) , _url (movieclip._url property) , allowinsecuredomain (security.Allowinsecuredomain method) allowinsecuredomain (security.Allowinsecuredomain method) public static...

  • Page 573

    Security (system.Security) 573 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 t...

  • Page 574

    574 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 575

    Selection 575 a policy file obtained from the old default location--/crossdomain.Xml on an http server on port 80—implicitly authorizes access to all ports 1024 and above. There is no way to retrieve a policy file to authorize xmlsocket operations from any other location on an http server; any custo...

  • Page 576

    576 actionscript classes method summary 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.Setfo...

  • Page 577

    Selection 577 example in the following example, you create two input text fields at runtime, setting the borders for each text field to true . This code creates a new (generic) actionscript object named focuslistener . This object defines for itself an onsetfocus property, to which it assigns a func...

  • Page 578

    578 actionscript classes returns string - a string or null . Example the following example displays the currently focused selections 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 instan...

  • Page 579

    Selection 579 parameters oldfocus: [optional] - the object losing focus. Newfocus: [optional] - the object receiving focus. 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 actionsc...

  • Page 580

    580 actionscript classes removelistener (selection.Removelistener method) public static removelistener(listener: object ) : boolean removes an object previously registered with selection.Addlistener() . Availability: actionscript 1.0; flash lite 2.0 parameters listener: object - the object that will...

  • Page 581

    Selection 581 setfocus (selection.Setfocus method) public static setfocus(newfocus: object ) : boolean gives focus to the selectable (editable) text field, button, or movie clip, specified by the newfocus parameter. You can use dot or slash notation to specify the path. You can also use a relative o...

  • Page 582

    582 actionscript classes function checkform():boolean { if (username_txt.Text.Length == 0) { status_txt.Text = "fill in username"; selection.Setfocus("username_txt"); return false; } if (password_txt.Text.Length == 0) { status_txt.Text = "fill in password"; selection.Setfocus("password_txt"); return...

  • Page 583

    Sharedobject 583 the following examples describe the potential of using shared objects: ■ a flash application can be used as a user interface for a service that enables the user to search used car listings. The application connects to a server that provides listings of cars based on the search terms...

  • Page 584

    584 actionscript classes example in the following example, a swf file creates a listener function named prefs and then creates a shared object. The player calls the loadcompleteprefs function when the data is available. Function loadcompleteprefs (sharedobject:myso) { if (0 == myso.Getsize() ) { // ...

  • Page 585

    Sharedobject 585 property summary properties inherited from class object event summary modifiers property description data : object the collection of attributes assigned to the data property of the object. Constructor (object.Constructor property) , __proto__ (object.__proto__ property) , prototype ...

  • Page 586

    586 actionscript classes method summary methods inherited from class object addlistener (sharedobject.Addlistener method) public static addlistener(objectname: string , notifyfunction: function ) : void creates an event listener that the flash lite player invokes when the player has loaded the share...

  • Page 587

    Sharedobject 587 availability: actionscript 2.0; flash lite 2.0 parameters objectname: string - a string that represents the name of the shared object. Notifyfunction: function - the name of a function the player calls to notify the application that the getlocal() method has executed and the data is...

  • Page 588

    588 actionscript classes note: for flash lite, if the shared object listener has not been invoked, the data property could contain undefined values. For details, see the description of the addlistener() method. Var items_array:array = new array(101, 346, 483); var currentuserisadmin:boolean = true; ...

  • Page 589

    Sharedobject 589 the shared object contains the following data: favoritesong: my world is blue favoritenightclub: the bluenote tavern favoritecolor: blue data: [object object] availability: actionscript 1.0; flash lite 2.0 example the following example saves text to a shared object named my_so (for ...

  • Page 590

    590 actionscript classes returns object - a boolean value, true or false ; or a string value of "pending" . The flush() method returns pending for most requests, with the following exceptions: ■ if there is no need to write data (that is, the data has already been written), flush() returns true . ■ ...

  • Page 591

    Sharedobject 591 getlocal (sharedobject.Getlocal method) public static getlocal(name: string ) : sharedobject returns a reference to a locally persistent shared object that is available only to the current client. If the shared object does not already exist, getlocal() creates one. This method is a ...

  • Page 592

    592 actionscript classes the following code block is placed on each swf file frame: // on each frame, call the rememberme function to save the frame number. Function rememberme() { my_so.Data.Frame=this._currentframe; my_so.Data.User="john"; } getmaxsize (sharedobject.Getmaxsize method) public stati...

  • Page 593

    Sharedobject 593 if the shared object listener has not yet been called, getsize() returns 0. For details about using the listener, see the addlistener() method. Availability: actionscript 1.0; flash lite 2.0 returns number - a numeric value specifying the size of the shared object, in bytes. Example...

  • Page 594

    594 actionscript classes the following events notify you when certain sharedobject activities occur: availability: actionscript 1.0; flash lite 2.0 parameters infoobject: object - a parameter defined according to the status message. Example the following example displays different messages based on ...

  • Page 595

    Sound 595 var flushresult = my_so.Flush(1000001); switch (flushresult) { case 'pending' : message_txt.Text = "flush is pending, waiting on user interaction."; break; case true : message_txt.Text = "flush was successful. Requested storage space approved."; break; case false : message_txt.Text = "flus...

  • Page 596

    596 actionscript classes availability: actionscript 1.0; flash lite 2.0 property summary properties inherited from class object event summary constructor summary modifiers property description duration : number [read-only] the duration of a sound, in milliseconds. Id3 : object [read-only] provides a...

  • Page 597

    Sound 597 method summary modifiers signature description attachsound (id: string ) : void attaches the sound specified in the id parameter to the specified sound object. Getbytesloaded () : number returns the number of bytes loaded (streamed) for the specified sound object. Getbytestotal () : number...

  • Page 598

    598 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 599

    Sound 599 example the following example loads a sound and displays the duration of the sound file in the output panel. Add the following actionscript to your fla or as file. Var my_sound:sound = new sound(); my_sound.Onload = function(success:boolean) { var totalseconds:number = this.Duration/1000; ...

  • Page 600

    600 actionscript classes with (pb.Stroke_mc) { linestyle(3, 0x000000); moveto(0, 0); lineto(pb_width, 0); lineto(pb_width, pb_height); lineto(0, pb_height); lineto(0, 0); } var my_interval:number; var my_sound:sound = new sound(); my_sound.Onload = function(success:boolean) { if (success) { trace("s...

  • Page 601

    Sound 601 example the following example dynamically creates two text fields that display the bytes that are loaded and the total number of bytes for a sound file that loads into the swf file. A text field also displays a message when the file finishes loading. Add the following actionscript to your ...

  • Page 602

    602 actionscript classes getbytestotal (sound.Getbytestotal method) public getbytestotal() : number returns the size, in bytes, of the specified sound object. Availability: actionscript 1.0; flash lite 2.0 returns number - an integer indicating the total size, in bytes, of the specified sound object...

  • Page 603

    Sound 603 you can use the following example to start the device sound. Because flash lite does not support streaming sound, it is a good practice to load the sound before playing it. Var my_sound:sound = new sound(); my_sound.Onload = function(success) { if (success) { my_sound.Start(); } else { out...

  • Page 604

    604 actionscript classes transform_mc.Transform_txt.Html = true; var knob_ll:movieclip = transform_mc.Attachmovie("knob_id", "ll_mc", transform_mc.Getnexthighestdepth(), {_x:0, _y:30}); var knob_lr:movieclip = transform_mc.Attachmovie("knob_id", "lr_mc", transform_mc.Getnexthighestdepth(), {_x:30, _...

  • Page 605

    Sound 605 function pressknob() { this.Startdrag(false, this.Left, this.Top, this.Right, this.Bottom); } function releaseknob() { 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 = ...

  • Page 606

    606 actionscript classes example the following example creates a slider using the drawing api and a movie clip that is created at runtime. A dynamically created text field displays the current volume level of the sound playing in the swf file. Add the following actionscript to your actionscript or f...

  • Page 607

    Sound 607 see also setvolume (sound.Setvolume method) 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.Attachsou...

  • Page 608

    608 actionscript classes 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 tha...

  • Page 609

    Sound 609 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 also attachsoun...

  • Page 610

    610 actionscript classes the following example loads a streaming sound: var my_sound:sound = new sound(); my_sound.Loadsound("song1.Mp3", true); see also onload (sound.Onload handler) onid3 (sound.Onid3 handler) onid3 = function() {} invoked each time new id3 data is available for an mp3 file that y...

  • Page 611

    Sound 611 see also attachsound (sound.Attachsound method) , id3 (sound.Id3 property) , loadsound (sound.Loadsound method) onload (sound.Onload handler) onload = function(success: boolean ) {} invoked automatically when a sound loads. You must create a function that executes when the this handler is ...

  • Page 612

    612 actionscript classes onsoundcomplete (sound.Onsoundcomplete handler) onsoundcomplete = function() {} invoked automatically when a sound finishes playing. You can use this handler to trigger events in a swf file when a sound finishes playing. You must create a function that executes when this han...

  • Page 613

    Sound 613 example for a sample usage of this property, see sound.Duration . See also duration (sound.Duration property) setpan (sound.Setpan method) public setpan(value: number ) : void determines how the sound is played in the left and right channels (speakers). For mono sounds, pan determines whic...

  • Page 614

    614 actionscript classes sounds use a considerable amount of disk space and memory. Because stereo sounds use twice as much data as mono sounds, it is generally best to use 22-khz 6-bit mono sounds. You can use settransform() to play mono sounds as stereo, play stereo sounds as mono, and to add inte...

  • Page 615

    Sound 615 example the following example illustrates a setting that can be achieved by using settransform() , but cannot be achieved by using setvolume() or setpan() , even if they are combined. The following code creates a new soundtransformobject object and sets its properties so that sound from bo...

  • Page 616

    616 actionscript classes parameters value: number - a number from 0 to 100 representing a volume level. 100 is full volume and 0 is no volume. The default setting is 100. Example for a sample usage of this method, see sound.Getvolume() . See also setpan (sound.Setpan method) , settransform (sound.Se...

  • Page 617

    Sound 617 parameters secondoffset: number [optional] - a parameter that lets you start playing the sound at a specific point. For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the secondoffset parameter. The sound is not delayed 15 seconds, ...

  • Page 618

    618 actionscript classes parameters linkageid: string [optional] - a parameter specifying a specific sound to stop playing. The idname parameter must be enclosed in quotation marks (" "). Example the following example uses two buttons, stop_btn and play_btn , to control the playback of a sound that ...

  • Page 619

    Stage 619 property summary properties inherited from class object event summary method summary methods inherited from class object modifiers property description static align : string indicates the current alignment of the swf file in the player or browser. Static height : number property (read-only...

  • Page 620

    620 actionscript classes 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 scaling setting ( showall ) or other sc...

  • Page 621

    Stage 621 the following table lists the values for the align property. Any value not listed here centers the swf file in flash player or browser area, which is the default setting. Availability: actionscript 1.0; flash lite 2.0 example the following example demonstrates different alignments of the s...

  • Page 622

    622 actionscript classes example this example creates a new listener object called stagelistener . It then uses mylistener to call onresize and define a function that will be called when onresize is triggered. Finally, the code adds the mylistener object to the callback list of the stage object. Lis...

  • Page 623

    Stage 623 removelistener (stage.Removelistener method) public static removelistener(listener: object ) : boolean removes a listener object created with addlistener(). Availability: actionscript 1.0; flash lite 2.0 parameters listener: object - an object added to an object's callback list with addlis...

  • Page 624

    624 actionscript classes scalemode (stage.Scalemode property) public static scalemode : string indicates the current scaling of the swf file within flash player. The scalemode property forces the swf file into a specific scaling mode. By default, the swf file uses the html parameters set in the publ...

  • Page 625

    Stage 625 to view another example, see the stagesize.Fla file in the actionscript samples folder. The following list provides typical paths to the actionscript samples folder: ■ windows: boot drive\program files\macromedia\flash 8\samples and tutorials\samples\actionscript ■ macintosh: macintosh hd/...

  • Page 627

    String 627 constructor summary method summary signature description string (value: string ) creates a new string object. Modifiers signature description charat (index: number ) : string returns the character in the position specified by the parameter index. Charcodeat (index: number ) : number retur...

  • Page 628

    628 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 629

    String 629 parameters index: number - an integer specifying the position of a character in the string. The first character is indicated by 0 , and the last character is indicated by my_str.Length-1 . Returns string - the character at the specified index. Or an empty string if the specified index is ...

  • Page 630

    630 actionscript classes see also charat (string.Charat method) 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 ...

  • Page 631

    String 631 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 i...

  • Page 632

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

  • Page 633

    String 633 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 lite 2....

  • Page 634

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

  • Page 635

    String 635 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)); // sli...

  • Page 636

    636 actionscript classes example the following example returns an array with five elements: var my_str:string = "p,a,t,s,y"; var my_array:array = my_str.Split(","); for (var i = 0; i trace(my_array[i]); } // output: p a t s y the following example returns an array with two elements, "p" and "a" : va...

  • Page 637

    String 637 string constructor public string(value: string ) creates a new string object. Note: because string literals use less overhead than string objects and are generally easier to use, you should use string literals instead of the constructor for the string class unless you have a good reason t...

  • Page 638

    638 actionscript classes example the following example creates a new string, my_str and uses substr() to return the second word in the string; first, using a positive start parameter, and then using a negative start parameter: var my_str:string = new string("hello world"); var mysubstring:string = n...

  • Page 639

    String 639 example the following example shows how to use substring() : var my_str:string = "hello world"; var mysubstring:string = my_str.Substring(6,11); trace(mysubstring); // output: world the following example shows what happens if a negative start parameter is used: var my_str:string = "hello ...

  • Page 640

    640 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/macr...

  • Page 641

    String 641 touppercase (string.Touppercase method) public touppercase() : string returns a copy of the string object, with all lowercase characters converted to uppercase. The original value is unchanged. Availability: actionscript 1.0; flash lite 2.0 returns string - a string. Example the following...

  • Page 642

    642 actionscript classes example the following example creates a new instance of the string object and then shows that the valueof method returns a reference to the primitive value, rather than an instance of the object. Var str:string = new string("hello world"); var value:string = str.Valueof(); t...

  • Page 643

    System 643 event summary method summary methods inherited from class object onstatus (system.Onstatus handler) onstatus = function(infoobject: object ) {} event handler: provides a super event handler for certain objects. The sharedobject class provides an onstatus() event handler that uses an infor...

  • Page 644

    644 actionscript classes example the following example shows how to create a system.Onstatus() function to process information objects when a class-specific onstatus() function does not exist: // create generic function system.Onstatus = function(genericerror:object){ // your script would do somethi...

  • Page 645

    Textfield 645 if you set system.Usecodepage to true, remember that the traditional code page of the operating system running the player must include the characters used in your external text file in order for the text to display. For example, if you load an external text file that contains chinese c...

  • Page 646

    646 actionscript classes see also object , createtextfield (movieclip.Createtextfield method) property summary modifiers property description _alpha : number sets or retrieves the alpha transparency value of the text field. Autosize : object controls automatic sizing and alignment of text fields. Ba...

  • Page 647

    Textfield 647 maxchars : number indicates the maximum number of characters that the text field can contain. Maxhscroll : number [read-only] indicates the maximum value of textfield.Hscroll . Maxscroll : number [read-only] indicates the maximum value of textfield.Scroll . Multiline : boolean indicate...

  • Page 648

    648 actionscript classes properties inherited from class object _url : string [read-only] retrieves the url of the swf file that created the text field. Variable : string the name of the variable that the text field is associated with. _visible : boolean a boolean value that indicates whether the te...

  • Page 649

    Textfield 649 event summary method summary event description onchanged = function(changedfield: textfield ) {} event handler/listener; invoked when the content of a text field changes. Onkillfocus = function(newfocus: object ) {} invoked when a text field loses keyboard focus. Onscroller = function(...

  • Page 650

    650 actionscript classes 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 even...

  • Page 651

    Textfield 651 returns boolean - example the following example defines an onchanged handler for the input text field my_txt . It then defines a new listener object, txtlistener , and defines an onchanged handler for that object. This handler will be invoked when the text field my_txt is changed. The ...

  • Page 652

    652 actionscript classes example the following code sets the _alpha property of a text field named my_txt to 20%. Create a new font symbol in the library by selecting new font from the library options menu. Then set the linkage of the font to my font .Set the linkage for a font symbol to my font . A...

  • Page 653

    Textfield 653 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 side will a...

  • Page 654

    654 actionscript classes 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 t...

  • Page 655

    Textfield 655 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 lite 2.0 example the following example creates a text field called ...

  • Page 656

    656 actionscript classes all the text between lines textfield.Scroll and textfield.Bottomscroll is currently visible in the text field. Availability: actionscript 1.0; flash lite 2.0 example the following example creates a text field and fills it with text. You must insert a button (with the instanc...

  • Page 657

    Textfield 657 example the following example creates two text fields, called first_txt and second_txt . The white space is removed from the second text field. Add the following actionscript to your fla or actionscript file: var my_str:string = "hello\tworldhow are you?\t\t\tend"; this.Createtextfie...

  • Page 658

    658 actionscript classes example in this example, you need to create a dynamic text field called my_txt , and then use the following actionscript to embed fonts and rotate the text field. The string my font refers to a font symbol in the library, with the linkage identifier name my font . The exampl...

  • Page 659

    Textfield 659 getnewtextformat (textfield.Getnewtextformat method) public getnewtextformat() : textformat returns a textformat object containing a copy of the text field's text format object. The text format object is the format that newly inserted text, such as text entered by a user, receives. Whe...

  • Page 660

    660 actionscript classes ■ usage 3: my_textfield.Gettextformat(beginindex:number,endindex:number) returns a textformat object containing formatting information for the span of text from beginindex to endindex . Only properties that are common to all of the text in the specified range is set in the r...

  • Page 661

    Textfield 661 _height (textfield._height property) public _height : number the height of the text field in pixels. Availability: actionscript 1.0; flash lite 2.0 example the following code example sets the height and width of a text field: my_txt._width = 200; my_txt._height = 200; _highquality (tex...

  • Page 662

    662 actionscript classes availability: actionscript 1.0; flash lite 2.0 example the following example scrolls the my_txt text field horizontally using two buttons called scrollleft_btn and scrollright_btn . The amount of scroll appears in a text field called scroll_txt . Add the following actionscri...

  • Page 663

    Textfield 663 example the following example creates a text field that sets the html property to true . Html- formatted text appears in the text field. This.Createtextfield("my_txt", this.Getnexthighestdepth(), 10, 10, 160, 22); my_txt.Html = true; my_txt.Htmltext = " this is bold text "; see also ht...

  • Page 664

    664 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 = t...

  • Page 665

    Textfield 665 maxscroll (textfield.Maxscroll property) public maxscroll : number [read-only] indicates the maximum value of textfield.Scroll . Availability: actionscript 1.0; flash lite 2.0 example the following example sets the maximum value for the scrolling text field my_txt . Create two buttons,...

  • Page 666

    666 actionscript classes example the following example creates a multiline text field called mytext . This.Createtextfield("mytext", this.Getnexthighestdepth(), 10, 30, 110, 100); mytext.Text = "flash is an authoring tool that designers and developers use to create presentations, applications, and o...

  • Page 667

    Textfield 667 a reference to the text field instance is passed as a parameter to the onchanged handler. You can capture this data by putting a parameter in the event handler method. For example, the following code uses textfield_txt as the parameter that is passed to the onchanged event handler. The...

  • Page 668

    668 actionscript classes example the following example creates two text fields called first_txt and second_txt . When you give focus to a text field, information about the text field with current focus and the text field that lost focus is displayed in the output panel. This.Createtextfield("first_t...

  • Page 669

    Textfield 669 onscroller is called whether the scroll position changed because of a users interaction with the text field, or programmatic changes. The onchanged handler fires only if a user interaction causes the change. These two options are necessary because often one piece of code changes the sc...

  • Page 670

    670 actionscript classes see also hscroll (textfield.Hscroll property) , maxhscroll (textfield.Maxhscroll property) , maxscroll (textfield.Maxscroll property) , scroll (textfield.Scroll property) onsetfocus (textfield.Onsetfocus handler) onsetfocus = function(oldfocus: object ) {} invoked when a tex...

  • Page 671

    Textfield 671 example the following actionscript creates two text fields and outputs information about the _parent of each object. The first text field, first_txt , is created on the main timeline. The second text field, second_txt , is created inside the movie clip called holder_mc . This.Createtex...

  • Page 672

    672 actionscript classes example the following example creates two text fields: username_txt and password_txt . Text is entered into both text fields; however, password_txt has the password property set to true . Therefore, the characters display as asterisks instead of as characters in the password...

  • Page 673

    Textfield 673 example the following example sets the rendering quality to low : my_txt._quality = "low"; see also _quality property removelistener (textfield.Removelistener method) public removelistener(listener: object ) : boolean removes a listener object previously registered to a text field inst...

  • Page 674

    674 actionscript classes }; my_txt.Addlistener(txtlistener); removelistener_btn.Onrelease = function() { trace("removing listener..."); if (!My_txt.Removelistener(txtlistener)) { trace("error! Unable to remove listener"); } }; removetextfield (textfield.Removetextfield method) public removetextfield...

  • Page 675

    Textfield 675 parameters beginindex: number - the start index value for the replacement range. Endindex: number - the end index value for the replacement range. Newtext: string - the text to use to replace the specified range of characters. Example the following example creates a text field called m...

  • Page 676

    676 actionscript classes example in this example, you need to create a dynamic text field called my_txt , and then use the following actionscript to embed fonts and rotate the text field. The string my font refers to a font symbol in the library, with a linkage identifier of my font . Var my_fmt:tex...

  • Page 677

    Textfield 677 example the following example sets the maximum value for the scrolling text field my_txt . Create two buttons, scrollup_btn and scrolldown_btn , to scroll the text field. Add the following actionscript to your fla or actionscript file. This.Createtextfield("scroll_txt", this.Getnexthig...

  • Page 678

    678 actionscript classes note: this property is not supported for arabic, hebrew, and thai. Availability: actionscript 1.0; flash lite 2.0 example the following example creates a selectable text field that constantly updates with the current date and time. This.Createtextfield("date_txt", this.Getne...

  • Page 679

    Textfield 679 my_txt.Type = "input"; my_txt.Setnewtextformat(my_fmt); my_txt.Text = "oranges are a good source of vitamin c"; see also getnewtextformat (textfield.Getnewtextformat method) , gettextformat (textfield.Gettextformat method) , settextformat (textfield.Settextformat method) settextformat ...

  • Page 680

    680 actionscript classes availability: actionscript 1.0; flash lite 2.0 parameters beginindex: number [optional] - an integer that specifies the first character of the desired text span. If you do not specify beginindex and endindex , the textformat is applied to the entire textfield. Endindex: numb...

  • Page 681

    Textfield 681 _soundbuftime (textfield._soundbuftime property) public _soundbuftime : number specifies the number of seconds a sound prebuffers before it starts to stream. Note: although you can specify this property for a textfield object, it is actually a global property that applies to all sounds...

  • Page 682

    682 actionscript classes example the following example creates a new text field at runtime, called news_txt . Three buttons on the stage, css1_btn , css2_btn and clearcss_btn , are used to change the style sheet that is applied to news_txt , or clear the style sheet from the text field. Add the foll...

  • Page 683

    Textfield 683 the following styles are applied to the text field. Save the following two css files in the same directory as the fla or actionscript file you created previously: // in styles.Css .Important { color: #ff0000; } .Bold { font-weight: bold; } .Headline { color: #000000; font-family: arial...

  • Page 684

    684 actionscript classes example the following example creates several text fields, called one_txt , two_txt , three_txt and four_txt . The three_txt text field has the tabenabled property set to false , so it is excluded from the automatic tab ordering. This.Createtextfield("one_txt", this.Getnexth...

  • Page 685

    Textfield 685 the custom tab ordering defined by the tabindex property is flat. This means that no attention is paid to the hierarchical relationships of objects in the swf file. All objects in the swf file with tabindex properties are placed in the tab order, and the tab order is determined by the ...

  • Page 686

    686 actionscript classes example the following actionscript creates a text field called my_txt and outputs the target path of the new field, in both slash and dot notation. This.Createtextfield("my_txt", this.Getnexthighestdepth(), 10, 10, 100, 22); trace(my_txt._target); // output: /my_txt trace(ev...

  • Page 687

    Textfield 687 textcolor (textfield.Textcolor property) public textcolor : number indicates the color of the text in a text field. The hexadecimal color system uses six digits to represent color values. Each digit has sixteen possible values or characters. The characters range from 0 to 9 and then a ...

  • Page 688

    688 actionscript classes see also textwidth (textfield.Textwidth property) textwidth (textfield.Textwidth property) public textwidth : number indicates the width of the text. Availability: actionscript 1.0; flash lite 2.0 example see the example for textfield.Textheight . See also textheight (textfi...

  • Page 689

    Textfield 689 _url (textfield._url property) public _url : string [read-only] retrieves the url of the swf file that created the text field. Availability: actionscript 1.0; flash lite 2.0 example the following example retrieves the url of the swf file that created the text field, and a swf file that...

  • Page 690

    690 actionscript classes _visible (textfield._visible property) public _visible : boolean a boolean value that indicates whether the text field my_txt is visible. Text fields that are not visible ( _visible property set to false ) are disabled. Availability: actionscript 1.0; flash lite 2.0 example ...

  • Page 691

    Textfield 691 this.Createtextfield("width_txt", this.Getnexthighestdepth(), 10, 10, 30, 20); width_txt.Border = true; width_txt.Maxchars = 3; width_txt.Type = "input"; width_txt.Text = my_txt._width; width_txt.Onchanged = function() { my_txt._width = this.Text; } this.Createtextfield("height_txt", t...

  • Page 692

    692 actionscript classes _x (textfield._x property) public _x : number an integer that sets the x coordinate of a text field relative to the local coordinates of the parent movie clip. If a text field is on the main timeline, then its coordinate system refers to the upper left corner of the stage as...

  • Page 693

    Textfield 693 example the following example creates three text fields on the stage. The mouse_txt instance displays the current position of the mouse in relation to the stage. The textfield_txt instance displays the current position of the mouse pointer in relation to the my_txt instance. Add the fo...

  • Page 694

    694 actionscript classes my_txt.Text = "sample text goes here."; scaleup_btn.Onrelease = function() { my_txt._xscale = 2; my_txt._yscale = 2; } scaledown_btn.Onrelease = function() { my_txt._xscale /= 2; my_txt._yscale /= 2; } see also _x (textfield._x property) , _y (textfield._y property) , _yscal...

  • Page 695

    Textformat 695 availability: actionscript 1.0; flash lite 2.0 example see the example for textfield._xmouse . See also _xmouse (textfield._xmouse property) _yscale (textfield._yscale property) public _yscale : number the vertical scale of the text field as applied from the registration point of the ...

  • Page 696

    696 actionscript classes property summary modifiers property description align : string a string that indicates the alignment of the paragraph. Blockindent : number a number that indicates the block indentation in points. Bold : boolean a boolean value that specifies whether the text is boldface. Bu...

  • Page 697

    Textformat 697 properties inherited from class object constructor summary method summary 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 fol...

  • Page 698

    698 actionscript classes the default value is null , which indicates that the property is undefined. Availability: actionscript 1.0; flash lite 2.0 example the following example creates a text field with a border and uses textformat.Align to center the text. Var my_fmt:textformat = new textformat();...

  • Page 699

    Textformat 699 bold (textformat.Bold property) public bold : boolean a boolean value that specifies whether the text is boldface. The default value is null , which indicates that the property is undefined. If the value is true , the text is boldface. Note: for arabic, hebrew, and thai, this property...

  • Page 700

    700 actionscript classes example the following example creates a new text field at runtime, and puts a string with a line break into the field. The textformat class is used to format the characters by adding bullets to each line in the text field. This is demonstrated in the following actionscript: ...

  • Page 701

    Textformat 701 font (textformat.Font property) public font : string a string that specifies the name of the font for text. The default value is null , which indicates that the property is undefined. Note: for flash lite, this property works for embedded fonts only. This property is not supported for...

  • Page 702

    702 actionscript classes if you are creating a text field based on the text metrics, use textfieldheight rather than height and textfieldwidth rather than width . The following figure illustrates these measurements. When setting up your textformat object, set all the attributes exactly as they will ...

  • Page 703

    Textformat 703 // create a textformat object, // and apply its properties. Var my_fmt:textformat = new textformat(); with (my_fmt) { font = "arial"; bold = true; } // obtain metrics information for the text string // with the specified formatting. Var metrics:object = my_fmt.Gettextextent(my_str); /...

  • Page 704

    704 actionscript classes indent (textformat.Indent property) public indent : number an integer that indicates the indentation from the left margin to the first character in the paragraph. The default value is null , which indicates that the property is undefined. Availability: actionscript 1.0; flas...

  • Page 705

    Textformat 705 leading (textformat.Leading property) public leading : number an integer that represents the amount of vertical space in pixels (called leading) between lines. The default value is null , which indicates that the property is undefined. Availability: actionscript 1.0; flash lite 2.0 ex...

  • Page 706

    706 actionscript classes rightmargin (textformat.Rightmargin property) public rightmargin : number the right margin of the paragraph, in points. The default value is null , which indicates that the property is undefined. Availability: actionscript 1.0; flash lite 2.0 example the following example cr...

  • Page 707

    Textformat 707 tabstops (textformat.Tabstops property) public tabstops : array specifies custom tab stops as an array of non-negative integers. Each tab stop is specified in pixels. If custom tab stops are not specified ( null ), the default tab stop is 4 (average character width). Note: for flash l...

  • Page 708

    708 actionscript classes 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(); myformat.Url = "http://www.Macromedia.Com"...

  • Page 709

    Textformat 709 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 target window where the hyperlink is displayed. If the target window is an empty string, the text is displa...

  • Page 710

    710 actionscript classes 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 underl...

  • Page 712

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

  • Page 713

    Video 713 close (video.Close method) public close() : void stops playback of the video, frees the memory associated with this video object, and clears the video area onscreen. Availability: actionscript 2.0; flash lite 2.0 example the following example closes the video that is playing in a video obj...

  • Page 714

    714 actionscript classes pause (video.Pause method) public pause() : void stops playback of the video and continues to render the current frame onscreen. A subsequent call to video.Resume() resumes playback from the current position. Availability: actionscript 2.0; flash lite 2.0 example the followi...

  • Page 715

    Video 715 resume (video.Resume method) public resume() : void calling this method resumes playback of the video. If video.Pause() was previously called, playback begins from the current position. If video.Stop() was previously called, playback begins from the first frame. Availability: actionscript ...

  • Page 717

    Xml 717 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) , insertbefore (xmlnode.Ins...

  • Page 718

    718 actionscript classes 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 description ondata ...

  • Page 719

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

  • Page 720

    720 actionscript classes if multiple calls are made to set the same header name, each successive value replaces the value set in the previous call. You cannot add or change the following standard http headers using this method: accept- ranges , age , allow , allowed , connection , content-length , c...

  • Page 721

    Xml 721 example the following example creates a new xml document and checks its default content type: // create a new xml document var doc:xml = new xml(); // trace the default content type trace(doc.Contenttype); // output: application/x-www-form-urlencoded the following example defines an xml pack...

  • Page 722

    722 actionscript classes example the following example creates three xml nodes using the createelement() method: // create an xml document var doc:xml = new xml(); // create three xml nodes using createelement() var element1:xmlnode = doc.Createelement("element1"); var element2:xmlnode = doc.Createe...

  • Page 723

    Xml 723 example the following example creates two xml text nodes using the createtextnode() method, and places them into existing xml nodes: // create an xml document var doc:xml = new xml(); // create three xml nodes using createelement() var element1:xmlnode = doc.Createelement("element1"); var el...

  • Page 724

    724 actionscript classes if no doctype declaration was encountered during a parse operation, the xml.Doctypedecl property is set to undefined . The xml.Tostring() method outputs the contents of xml.Doctypedecl immediately after the xml declaration stored in xml.Xmldecl , and before any other text in...

  • Page 725

    Xml 725 var percentloaded:number = math.Floor((bytesloaded / bytestotal ) 100); trace ("milliseconds elapsed: " + gettimer()); trace ("bytesloaded: " + bytesloaded); trace ("bytestotal: " + bytestotal); trace ("percent loaded: " + percentloaded); trace ("---------------------------------"); } doc.On...

  • Page 726

    726 actionscript classes usage 1: you can set the ignorewhite property for individual xml objects, as the following code shows: my_xml.Ignorewhite = true; usage 2: you can set the default ignorewhite property for xml objects, as the following code shows: xml.Prototype.Ignorewhite = true; availabilit...

  • Page 727

    Xml 727 // set the ignorewhite property to false (default value) flooring.Ignorewhite = false; ... // output (line breaks added for clarity): ceramic tile linoleum the xml_blogtracker.Fla and xml_languagepicker.Fla files in the actionscript samples folder also contain a code example. The following a...

  • Page 728

    728 actionscript classes you can define a custom function that executes when the onload event handler of the xml object is invoked. Availability: actionscript 1.0; flash lite 2.0 - behavior changed in flash player 7. Parameters url: string - a string that represents the url where the xml document to...

  • Page 729

    Xml 729 loaded (xml.Loaded property) public loaded : boolean indicates if the xml document has successfully loaded. If there is no custom onload() event handler defined for the xml object, then this property is set to true when the document- loading process initiated by the xml.Load() call has compl...

  • Page 730

    730 actionscript classes availability: actionscript 1.0; flash lite 2.0 parameters src: string - a string or undefined ; the raw data, usually in xml format, that is sent by the server. Example the following example shows what the xml.Ondata event handler looks like by default: xml.Prototype.Ondata ...

  • Page 731

    Xml 731 example the following example includes actionscript for a simple e-commerce storefront application. The sendandload() method transmits an xml element that contains the user's name and password, and uses an xml.Onload handler to process the reply from the server. Var login_str:string = " pass...

  • Page 732

    732 actionscript classes example the following example creates and parses an xml packet: var xml_str:string = " san francisco" // defining the xml source within the xml constructor: var my1_xml:xml = new xml(xml_str); trace(my1_xml.Firstchild.Attributes.Name); // output: california // defining the x...

  • Page 733

    Xml 733 example the following example defines an xml packet and sets the content type for the xml object. The data is then sent to a server and shows a result in a browser window. Var my_xml:xml = new xml("ernie 13045"); my_xml.Contenttype = "text/xml"; my_xml.Send("http://www.Flash-mx.Com/mm/highsc...

  • Page 734

    734 actionscript classes 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 ...

  • Page 735

    Xml 735 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 completed successfully....

  • Page 736

    736 actionscript classes 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...

  • Page 737

    Xml 737 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: var other_xml:xml...

  • Page 738

    738 actionscript classes 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+new...

  • Page 739

    Xmlnode 739 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 : xmlnode [read-...

  • Page 740

    740 actionscript classes method summary methods inherited from class object 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 paramete...

  • Page 741

    Xmlnode 741 parameters newchild: xmlnode - an xmlnode that represents the node to be moved from its current location to the child list of the my_xml object. Example this example does the following things in the order shown: ■ creates two empty xml documents, doc1 and doc2 . ■ creates a new node usin...

  • Page 742

    742 actionscript classes attributes (xmlnode.Attributes property) public attributes : object an object containing all of the attributes of the specified xml instance. The xml.Attributes object contains one variable for each attribute of the xml instance. Because these variables are defined as part o...

  • Page 743

    Xmlnode 743 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("rootnode"); // create three child nodes var oldest:xmlnode =...

  • Page 744

    744 actionscript classes clonenode (xmlnode.Clonenode method) public clonenode(deep: boolean ) : xmlnode constructs and returns a new xml node of the same type, name, value, and attributes as the specified xml object. If deep is set to true , all child nodes are recursively cloned, resulting in an e...

  • Page 745

    Xmlnode 745 // insert the clone node into rootnode between the middle and youngest nodes rootnode.Insertbefore(middle2, youngest); trace(rootnode); // output (with line breaks added): // // // // // // // create a copy of rootnode using clonenode() to demonstrate a deep copy var rootclone:xmlnode = ...

  • Page 746

    746 actionscript classes example the following example shows how to use xml.Firstchild to loop through a node's child nodes: // create a new xml document var doc:xml = new xml(); // create a root node var rootnode:xmlnode = doc.Createelement("rootnode"); // create three child nodes var oldest:xmlnod...

  • Page 747

    Xmlnode 747 see also appendchild (xmlnode.Appendchild method) , insertbefore (xmlnode.Insertbefore method) , removenode (xmlnode.Removenode method) haschildnodes (xmlnode.Haschildnodes method) public haschildnodes() : boolean specifies whether or not the xml object has child nodes. Availability: act...

  • Page 748

    748 actionscript classes parameters newchild: xmlnode - the xmlnode object to be inserted. Insertpoint: xmlnode - the xmlnode object that will follow the newchild node after the method is invoked. Example the following inserts a new xml node between two existing nodes: var my_xml:xml = new xml("13...

  • Page 749

    Xmlnode 749 doc.Appendchild(rootnode); // add each of the child nodes as children of rootnode rootnode.Appendchild(oldest); rootnode.Appendchild(middle); rootnode.Appendchild(youngest); // use lastchild to iterate through the child nodes of rootnode for (var anode:xmlnode = rootnode.Lastchild; anode...

  • Page 750

    750 actionscript classes nextsibling (xmlnode.Nextsibling property) public nextsibling : xmlnode [read-only] an xmlnode value that references the next sibling in the parent node's child list. This property is null if the node does not have a next sibling node. This property cannot be used to manipul...

  • Page 751

    Xmlnode 751 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 t...

  • Page 752

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

  • Page 753

    Xmlnode 753 var mytextnode:xmlnode = doc.Createtextnode("textnode"); // place the new node into the xml tree mynode.Appendchild(mytextnode); trace(mynode.Nodetype); trace(mytextnode.Nodetype); // output: // 1 // 3 see also nodevalue (xmlnode.Nodevalue property) nodevalue (xmlnode.Nodevalue property)...

  • Page 754

    754 actionscript classes // null // mytextnode the following example creates and parses an xml packet. The code loops through each child node, and displays the node value using the firstchild property and firstchild.Nodevalue . When you use firstchild to display contents of the node, it maintains th...

  • Page 755

    Xmlnode 755 example the following example creates an xml packet and displays the parent node of the username node in the output panel: var my_xml:xml = new xml("mortongood&evil"); // first child is the node var rootnode:xmlnode = my_xml.Firstchild; // first child of the root is the node var targetno...

  • Page 756

    756 actionscript classes see also lastchild (xmlnode.Lastchild property) , appendchild (xmlnode.Appendchild method) , insertbefore (xmlnode.Insertbefore method) , removenode (xmlnode.Removenode method) , xml removenode (xmlnode.Removenode method) public removenode() : void removes the specified xml ...

  • Page 757

    Xmlui 757 for top-level xml objects (those created with the constructor), the xml.Tostring() method outputs the document's xml declaration (stored in the xml.Xmldecl property), followed by the document's doctype declaration (stored in the xml.Doctypedecl property), followed by the text representatio...

  • Page 758

    758 actionscript classes macromedia flash mx 2004 and macromedia flash mx professional 2004 come 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 ...

  • Page 759

    Xmlui 759 accept (xmlui.Accept method) public static accept() makes the current xmlui dialog exit with an "accept" state. Identical to the user clicking the ok button. Availability: actionscript 1.0; flash lite 2.0 cancel (xmlui.Cancel method) public static cancel() makes the current xmlui dialog ex...

  • Page 760

    760 actionscript classes.

  • Page 761

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

  • Page 762

    762 deprecated actionscript mbchr (number: number ) deprecated since flash player 5. This function was deprecated in favor of the string.Fromcharcode() method. Mblength (string: string ) number deprecated since flash player 5. This function was deprecated in favor of the methods and properties of th...

  • Page 763

    Deprecated operator summary 763 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. _highquality deprecated since flash player 7. This p...

  • Page 764

    764 deprecated actionscript eq ( equality (strings) ) deprecated since flash player 5. This operator was deprecated in favor of the == (equality) operator. Ge ( greater than or equal to (strings) ) deprecated since flash player 5. This operator was deprecated in favor of the >= (greater than or equa...

  • Page 765

    765 4 chapter 4 unsupported actionscript flash lite 2.0 does not support the following elements: unsupported classes unsupported methods unsupported properties accessibility, camera, contextmenu, contextmenuitem, customactions, localconnection, microphone, netconnection, netstream, printjob, textfie...

  • Page 766

    766 unsupported actionscript unsupported global functions unsupported event handlers unsupported fscommands asfunction, mmexecute, print, printasbitmap, printasbitmapnum, printnum, updateafterevent onupdate, mouse.Onmousewheel allowscale, exec, fullscreen, quit, showmenu, trapallkeys.

  • Page 767

    767 index symbols 126, 128, 155, 156 ! Logical not operator 160 != inequality operator 152 !== strict inequality operator 173 " string delimiter operator 174 #endinitclip directive 23 #include directive 24 #initclip directive 25 $version property 95 % modulo operator 164 %= modulo assignment operato...

  • Page 768

    768 index _rotation property 287, 510, 675 _soundbuftime property 109, 288, 512, 681 _target property 290, 518, 685 _totalframes property 519 _url property 292, 521, 689 _visible property 293, 522, 690 _width property 293, 523, 690 _x property 294, 523, 692 _xmouse property 294, 524, 692 _xscale pro...

  • Page 769

    Index 769 _alpha property 274 _focusrect property 276 _height property 278 _highquality property 278 _name property 278 _parent property 286 _quality property 287 _rotation property 287 _soundbuftime property 288 _target property 290 _url property 292 _visible property 293 _width property 293 _x pro...

  • Page 770

    770 index dispatched by loadvars 400, 401 dispatched by mouse 433, 435, 436 dispatched by movieclip 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505 dispatched by moviecliploader 535, 537, 538, 539, 541 dispatched by selection 578 dispatched by sharedobject 593 dispatched by sound 610, 611...

  • Page 771

    Index 771 down property 375 duplicatemovieclip function 42 duplicatemovieclip() method 461 duration property 598 dynamic statement 190 e e property 418 else if statement 192 else statement 192 embedfonts property 657 enabled property 275, 462 end property 376 endfill() method 463 enter property 376 ...

  • Page 772

    772 index getnetworkconnectionname command 231 getnetworkconnectstatus command 232 getnetworkgeneration command 233 getnetworkname command 233 getnetworkrequeststatus command 234 getnetworkstatus command 235 getnewtextformat() method 659 getnexthighestdepth() method 471 getpan() method 602 getplatfo...

  • Page 773

    Index 773 initialize() method 409 insert property 380 insertbefore() method 747 instanceof operator 154 int function 54 interface statement 204 intrinsic statement 206 isdebugger property 314 isdown() method 381 isfinite function 54 isnan function 55 ispropertyenumerable() method 555 isprototypeof()...

  • Page 774

    774 index loadstring() method 409 setdefaultlang() method 409 setloadcallback() method 410 locale class 406 localfilereaddisable property 316 localtoglobal() method 487 log() method 420 log10e property 421 log2e property 421 lt less than (strings) operator 156 m math abs() method 413 acos() method 4...

  • Page 775

    Index 775 getbytesloaded() method 467 getbytestotal() method 468 getdepth() method 469 getinstanceatdepth() method 470 getnexthighestdepth() method 471 getswfversion() method 472 geturl() method 473 globaltolocal() method 474 gotoandplay() method 477 gotoandstop() method 478 hitarea property 480 hit...

  • Page 776

    776 index o object __proto__ property 557 __resolve property 560 addproperty() method 551 constructor property 554 hasownproperty() method 555 ispropertyenumerable() method 555 isprototypeof() method 556 object() constructor 557 prototype property 558 registerclass() method 559 tostring() method 563...

  • Page 777

    Index 777 resume() method 715 return statement 209 returnindexedarray property 257 reverse() method 258 right property 386 rightmargin property 706 round() method 425 s scalemode property 624 screenorientation property 317 screenresolutionx property 318 screenresolutiony property 318 scroll property...

  • Page 778

    778 index getbytestotal() method 602 getpan() method 602 gettransform() method 603 getvolume() method 605 id3 property 607 loadsound() method 609 position property 612 setpan() method 613 settransform() method 613 setvolume() method 615 sound() constructor 616 start() method 616 stop() method 617 so...

  • Page 779

    Index 779 _soundbuftime property 681 _target property 685 _url property 689 _visible property 690 _width property 690 _x property 692 _xmouse property 692 _xscale property 693 _y property 694 _ymouse property 694 _yscale property 695 addlistener() method 650 autosize property 652 background property...

  • Page 780

    780 index unloadmovie() method 520 unloadmovienum function 91 unshift() method 268 unwatch() method 565 up property 389 url property 710 usecodepage property 644 utc() method 356 v valueof() method 270, 357, 549, 565, 641 var statement 221 variable property 689 version property 319 video close() met...