MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Summary of FLASH MX 2004-ACTIONSCRIPT LANGUAGE

  • Page 1

    Actionscript language reference.

  • Page 2

    Trademarks add life to the web, afterburner, aftershock, andromedia, allaire, animation powerpack, aria, attain, authorware, authorware star, backstage, bright tiger, clustercats, coldfusion, contribute, design in motion, director, dream templates, dreamweaver, drumbeat 2000, edje, ejipt, extreme 3d...

  • Page 3: Contents

    3 contents chapter 1: introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 sample entry for most actionscript elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 sample entry for classes . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 4

    4 contents + (addition) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 += (addition assignment) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 = (assignment) . . . . . . . . . . . . . . . . . ...

  • Page 5

    Contents 5 button._height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 button.Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 button._name . . . . . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents camera.Setquality() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 camera.Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 case . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 7

    Contents 7 date.Setfullyear() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 date.Sethours(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 date.Setmilliseconds() . . . . . . . . . . . . . . ...

  • Page 8

    8 contents implements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 #include . . . . . . . . . . . . . . . . . ...

  • Page 9

    Contents 9 loadvars.Ondata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 loadvars.Onload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 loadvars.Send(). . . . . . . . . . . . . . . . . . . . ....

  • Page 10

    10 contents microphone.Rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 microphone.Setgain() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 microphone.Setrate() . . . . . . . . . . . . . . . . . ...

  • Page 11

    Contents 11 movieclip.Hittest() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 movieclip.Linestyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536 movieclip.Lineto() . . . . . . . . . . . . . . . . . ....

  • Page 12

    12 contents movieclip._visible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 movieclip._width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593 movieclip._x . . . . . . . . . . . . . . . . . . . . ....

  • Page 13

    Contents 13 object() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659 object class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 object.Addproperty() . . . . . . . . . . ....

  • Page 14

    14 contents sharedobject.Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738 sharedobject.Flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740 sharedobject.Getlocal() . . . . . . . . . . . . . . ....

  • Page 15

    Contents 15 string.Substr() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806 string.Substring(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807 string.Tolowercase(). . . . . . . . . . . . . ...

  • Page 16

    16 contents textfield.Stylesheet.Parsecss() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866 textfield.Stylesheet.Setstyle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867 textfield.Stylesheet.Transform() . . . . . . . . . . . . . . . ....

  • Page 17

    Contents 17 textfield._target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925 textfield.Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926 textfield.Textcolor . . . . . . . . . . . . . ....

  • Page 18

    18 contents undefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 989 unescape() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991 unloadmovie(). . . . . . . . . . . . . . . ...

  • Page 19

    Contents 19 xmlnode class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058 xmlsocket class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1059 xmlsocket.Close() . . . . . . . . . . . . . . . . . . ....

  • Page 20

    20 contents.

  • Page 21: Chapter 1

    21 chapter 1 introduction this manual describes the syntax and use of actionscript elements in macromedia flash mx 2004 and macromedia flash mx professional 2004. To use examples in a script, copy the code example from this book and paste it into the script pane or into an external script file. The ...

  • Page 22

    22 chapter 1: introduction availability unless otherwise noted, the availability section tells which versions of flash player support the element. The supported flash player version is not the same as the version of flash used to author the content. For example, if you use macromedia flash mx 2004 o...

  • Page 23

    Examples folder 23 method and property summary tables each class entry contains a table listing all of the associated methods. If the class has properties (often constants), event handlers, or event listeners, these elements are summarized in additional tables. All the elements listed in these table...

  • Page 24

    24 chapter 1: introduction.

  • Page 25: Chapter 2

    25 chapter 2 actionscript language reference –– (decrement) availability flash player 4. Usage ––expression expression–– parameters expression a number or a variable that evaluates to a number. Returns a number. Description operator (arithmetic); a pre-decrement and post-decrement unary operator tha...

  • Page 26

    26 chapter 2: actionscript language reference the following example loops from 10 to 1, and each iteration of the loop decreases the counter variable i by 1. For (var i = 10; i>0; i--) { trace(i); }.

  • Page 27

    ++ (increment) 27 ++ (increment) availability flash player 4. Usage ++expression expression++ parameters expression a number or a variable that evaluates to a number. Returns a number. Description operator (arithmetic); a pre-increment and post-increment unary operator that adds 1 to expression . Th...

  • Page 28

    28 chapter 2: actionscript language reference this is execution 5 */ the following example uses ++ as a pre-increment operator: var a:array = []; // var a:array = new array(); var i:number = 0; while (i a.Push(++i); } trace(a.Tostring());//traces: 1,2,3,4,5,6,7,8,9,10 this example also uses ++ as a ...

  • Page 29

    ! (logical not) 29 ! (logical not) availability flash player 4. Usage !Expression parameters expression an expression or a variable that evaluates to a boolean value. Returns a boolean value. Description operator (logical); inverts the boolean value of a variable or expression. If expression is a va...

  • Page 30

    30 chapter 2: actionscript language reference != (inequality) availability flash player 5. Usage expression1 != expression2 parameters none. Returns a boolean value. Description operator (inequality); tests for the exact opposite of the equality ( == ) operator. If expression1 is equal to expression...

  • Page 31

    != (inequality) 31 trace("foo"); }; var b:function = function() { trace("foo"); }; a(); // foo b(); // foo trace(a!=b); // true a = b; a(); // foo b(); // foo trace(a!=b); // false // trace statement output: foo foo true foo foo false the following example illustrates comparison by reference with tw...

  • Page 32

    32 chapter 2: actionscript language reference !== (strict inequality) availability flash player 6. Usage expression1 !== expression2 parameters none. Returns a boolean value. Description operator; tests for the exact opposite of the strict equality ( === ) operator. The strict inequality operator pe...

  • Page 33

    (logical or) , == (equality) , === (strict equality).

  • Page 34

    34 chapter 2: actionscript language reference % (modulo) availability flash player 4. 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. Usage expression1 % expression2 parameters none. Returns a n...

  • Page 35

    %= (modulo assignment) 35 %= (modulo assignment) availability flash player 4. Usage expression1 %= expression2 parameters none. Returns a number. Description operator (arithmetic compound assignment); assigns expression1 the value of expression1 % expression2 . The following two expressions are equi...

  • Page 36

    36 chapter 2: actionscript language reference & (bitwise and) availability flash player 5. In flash 4, the and (&) operator was used for concatenating strings. In flash 5 and later, the and (&) operator is a bitwise and, and you must use the addition ( +) operator to concatenate strings. Flash 4 fil...

  • Page 38

    38 chapter 2: actionscript language reference && (logical and) availability flash player 4. Usage expression1 && expression2 parameters none. Returns a boolean value. Description operator (logical); performs a boolean operation on the values of one or both of the expressions. Evaluates expression1 (...

  • Page 39

    (logical or) , == (equality) , === (strict equality).

  • Page 40

    40 chapter 2: actionscript language reference &= (bitwise and assignment) availability flash player 5. Usage expression1 &= expression2 parameters none. Returns a 32-bit integer; the value of expression1 & expression2 . Description operator; assigns expression1 the value of expression1 & expression2...

  • Page 41

    () (parentheses) 41 () (parentheses) availability flash player 4. Usage (expression1 [, expression2]) (expression1, expression2) function(parameter1,..., parametern) parameters expression1, expression2 numbers, strings, variables, or text. Function the function to be performed on the contents of the...

  • Page 42

    42 chapter 2: actionscript language reference function foo() { a += b; } function bar() { b *= 10; } trace((foo(), bar(), a+b)); // outputs 23 usage 3: the following example shows the use of parentheses with functions: var today:date = new date(); trace(today.Getfullyear()); // traces current year f...

  • Page 43

    – (minus) 43 – (minus) availability flash player 4. Usage (negation) - expression (subtraction) expression1 - expression2 parameters none. Returns an integer or floating-point number. Description operator (arithmetic); used for negating or subtracting. Usage 1: when used for negating, it reverses th...

  • Page 44

    44 chapter 2: actionscript language reference * (multiplication) availability flash player 4. Usage expression1 * expression2 parameters none. Returns an integer or floating-point number. Description operator (arithmetic); multiplies two numerical expressions. If both expressions are integers, the p...

  • Page 45

    *= (multiplication assignment) 45 *= (multiplication assignment) availability flash player 4. Usage expression1 *= expression2 parameters none. Returns the value of expression1 * expression2 . If an expression cannot be converted to a numeric value, it returns nan (not a number). Description operato...

  • Page 46

    46 chapter 2: actionscript language reference , (comma) availability flash player 4. Usage (expression1, expression2 [, expressionn...]) parameters none. Returns the value of expression1 , expression2 , and so on. Description operator; evaluates expression1 , then expression2 , and so on. This opera...

  • Page 47

    , (comma) 47 v = v + 4 , z++, v + 6; trace(v); // output: 4 trace(z); // output: 1 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 ret...

  • Page 48

    48 chapter 2: actionscript language reference . (dot) availability flash player 4. Usage object.Property_or_method instancename.Variable instancename.Childinstance instancename.Childinstance.Variable parameters object an instance of a class. The object can be an instance of any of the built-in actio...

  • Page 49

    . (dot) 49 this.Createemptymovieclip("container_mc", this.Getnexthighestdepth()); this.Container_mc.Createtextfield("date_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); this.Container_mc.Date_txt.Autosize = true; this.Container_mc.Date_txt.Text = new date(); the dot (.) operator is used when targ...

  • Page 50

    50 chapter 2: actionscript language reference : (type) availability flash player 6. Usage [modifiers] var variablename:type function functionname():type { ... } function functionname(parameter1:type, ... , parametern:type) [ :type ]{ ... } note: to use this operator, you must specify actionscript 2....

  • Page 51

    : (type) 51 usage 2: the following example shows how to specify a function’s parameter type by defining a function named randomint() that takes a parameter named integer of type number: function randomint(integer:number):number { return math.Round(math.Random()*integer); } trace(randomint(8)); usage...

  • Page 52

    52 chapter 2: actionscript language reference ?: (conditional) availability flash player 4. Usage expression1 ? Expression2 : expression3 parameters expression1 an expression that evaluates to a boolean value; usually a comparison expression, such as x . Expression2 , expression3 values of any type....

  • Page 53

    / (division) 53 / (division) availability flash player 4. Usage expression1 / expression2 parameters expression a number or a variable that evaluates to a number. Returns a floating-point number. Description operator (arithmetic); divides expression1 by expression2 . The result of the division opera...

  • Page 54

    54 chapter 2: actionscript language reference // (comment delimiter) availability flash 1. Usage // comment parameters comment any characters. Returns nothing. Description comment; indicates the beginning of a script comment. Any characters that appear between the comment delimiter ( //) and the end...

  • Page 55

    /* (comment delimiter) 55 /* (comment delimiter) availability flash player 5. Usage /* comment */ /* comment comment */ parameters comment any characters. Returns nothing. Description comment; indicates one or more lines of script comments. Any characters that appear between the opening comment tag ...

  • Page 56

    56 chapter 2: actionscript language reference /= (division assignment) availability flash player 4. Usage expression1 /= expression2 parameters expression1,expression2 a number or a variable that evaluates to a number. Returns a number. Description operator (arithmetic compound assignment); assigns ...

  • Page 57

    [] (array access) 57 [] (array access) availability flash player 4. Usage myarray = [a0, a1,...An] myarray[i] = value myobject[propertyname] parameters myarray the name of an array. A0, a1,...An elements in an array; any native type or object instance, including nested arrays. I an integer index gre...

  • Page 58

    58 chapter 2: actionscript language reference usage 2: surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the followin...

  • Page 59

    [] (array access) 59 in the following example, the expression inside the brackets is evaluated, and the result is used as the name of the variable to be retrieved from movie clip name_mc : name_mc["a" + i]; if you are familiar with the flash 4 actionscript slash syntax, you can use the eval() functi...

  • Page 60

    60 chapter 2: actionscript language reference ^ (bitwise xor) availability flash player 5. Usage expression1 ^ expression2 parameters expression1,expression2 a number. Returns a 32-bit integer. Description operator (bitwise); converts expression1 and expression2 to 32-bit unsigned integers, and retu...

  • Page 61

    ^= (bitwise xor assignment) 61 ^= (bitwise xor assignment) availability flash player 5. Usage expression1 ^= expression2 parameters expression1,expression2 integers and variables. Returns a 32-bit integer. Specifically, the value of expression1 ^ expression2 . Description operator (bitwise compound ...

  • Page 62

    62 chapter 2: actionscript language reference {} (object initializer) availability flash player 5. Usage object = {name1: value1, name2: value2,...Namen: valuen} {expression1; [...Expressionn]} parameters object the object to create. Name1,2,...N the names of the properties. Value1,2,...N the corres...

  • Page 63

    {} (object initializer) 63 the following example shows how array and object initializers can be nested within each other: var person:object = {name:"gina vechio", children:["ruby", "chickie", "puppa"]}; the following example uses the information in the previous example and produces the same result u...

  • Page 65

    expression2 parameters expression1, expression2 a boolean value or an expression that converts to a boolean value. Returns a boolean value. Description operator (logical); evaluates expression1 (the expression on th...

  • Page 66

    fx2()) { trace("if statement entered"); } /* the following is sent to the output panel: fx1 called if statement entered */ see also ! (logical not) , != (inequality) , !== (stric...

  • Page 68

    68 chapter 2: actionscript language reference ~ (bitwise not) availability flash player 5. Usage ~ expression parameters expression a number. Returns a 32-bit integer. Description operator (bitwise); also known as the one’s complement operator or the bitwise complement operator. Converts the express...

  • Page 70

    70 chapter 2: actionscript language reference + (addition) availability flash player 4; flash player 5.In flash 5 and later, + is either a numeric operator or a string concatenator depending on the data type of the parameter. In flash 4, + is only a numeric operator. Flash 4 files that are brought i...

  • Page 71

    + (addition) 71 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 de...

  • Page 72

    72 chapter 2: actionscript language reference += (addition assignment) availability flash player 4. Usage expression1 += expression2 parameters expression1,expression2 a number or string. Returns a string or a number. Description operator (arithmetic compound assignment); assigns expression1 the val...

  • Page 73

    73 availability flash player 4; flash player 5. In flash 5 and later, the (less than) operator is a comparison operator capable of handling various data types. In flash 4, is an numeric operator. Flash 4 files that are brought into the flash 5 or later authoring environment undergo a conversion proc...

  • Page 74

    74 chapter 2: actionscript language reference availability flash player 5. Usage expression1 expression2 parameters expression1 a number or expression to be shifted left. Expression2 a number or expression that converts to an integer from 0 to 31. Returns a 32-bit integer. Description operator (bitw...

  • Page 75

    75 if you trace the following example, you see that the bits have been pushed two spaces to the left: // 2 binary == 0010 // 8 binary == 1000 trace(2 see also >>= (bitwise right shift and assignment) , >> (bitwise right shift) , assignment) , >>> (bitwise unsigned right shift) , >>>= (bitwise unsign...

  • Page 76

    76 chapter 2: actionscript language reference availability flash player 5. Usage expression1 expression2 parameters expression1 a number or expression to be shifted left. Expression2 a number or expression that converts to an integer from 0 to 31. Returns a 32-bit integer. Description operator (bitw...

  • Page 77

    77 availability flash player 4. In flash 5 or later, the less than or equal to ( ) operator is a comparison operator capable of handling various data types. In flash 4, is a numeric operator. Flash 4 files that are brought into the flash 5 or later authoring environment undergo a conversion process ...

  • Page 78

    78 chapter 2: actionscript language reference = (assignment) availability flash player 4. In flash 5 or later, = is an assignment operator, and the == operator is used to evaluate equality. In flash 4, = is a numeric equality operator. Flash 4 files that are brought into the flash 5 or later authori...

  • Page 79

    = (assignment) 79 the following example uses assignment by reference to create the moonsofjupiter variable, which contains a reference to a newly created array object. Assignment by value is then used to copy the value "callisto" to the first element of the array referenced by the variable moonsofju...

  • Page 80

    80 chapter 2: actionscript language reference -= (subtraction assignment) availability flash player 4. Usage expression1 -= expression2 parameters expression1,expression2 a number or expression that evaluates to a number. Returns a number. Description operator (arithmetic compound assignment); assig...

  • Page 81

    == (equality) 81 == (equality) availability flash player 5. Usage expression1 == expression2 parameters expression1,expression2 a number, string, boolean value, variable, object, array, or function. Returns a boolean value. Description operator (equality); tests two expressions for equality. The res...

  • Page 82

    82 chapter 2: actionscript language reference var y:string = "steve"; trace(x == y); // output: false the following examples show comparison by reference. The first example compares two arrays with identical length and elements. The equality operator will return false for these two arrays. Although ...

  • Page 83

    === (strict equality) 83 === (strict equality) availability flash player 6. Usage expression1 === expression2 returns a boolean value. Description operator; tests two expressions for equality; the strict equality ( === )operator performs in the same way as the equality ( == ) operator, except that d...

  • Page 84

    84 chapter 2: actionscript language reference // automatic data typing in this example converts false to “0” var string1:string = "0"; var bool2:boolean = false; trace(string1 == bool2); // true trace(string1 === bool2); // false the following examples show how strict equality treats variables that ...

  • Page 85

    > (greater than) 85 > (greater than) availability flash player 4. In flash 5 or later, the greater-than ( > ) operator is a comparison operator capable of handling various data types. In flash 4, > is a numeric operator. Flash 4 files that are brought into the flash 5 or later authoring environment ...

  • Page 86

    86 chapter 2: actionscript language reference >= (greater than or equal to) availability flash player 4. In flash 5 or later, the greater than or equal to ( >= ) operator is a comparison operator capable of handling various data types. In flash 4, >= is a numeric operator. Flash 4 files that are bro...

  • Page 87

    >> (bitwise right shift) 87 >> (bitwise right shift) availability flash player 5. Usage expression1 >> expression2 parameters expression1 a number or expression to be shifted right. Expression2 a number or expression that converts to an integer from 0 to 31. Returns a 32-bit integer. Description ope...

  • Page 88

    88 chapter 2: actionscript language reference 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 11...

  • Page 89

    >>= (bitwise right shift and assignment) 89 >>= (bitwise right shift and assignment) availability flash player 5. Usage expression1 >>= expression2 parameters expression1 a number or expression to be shifted right. Expression2 a number or expression that converts to an integer from 0 to 31. Returns ...

  • Page 90

    90 chapter 2: actionscript language reference >>> (bitwise unsigned right shift) availability flash player 5. Usage expression1 >>> expression2 parameters expression1 a number or expression to be shifted right. Expression2 a number or expression that converts to an integer between 0 and 31. Returns ...

  • Page 91

    >>>= (bitwise unsigned right shift and assignment) 91 >>>= (bitwise unsigned right shift and assignment) availability flash player 5. Usage expression1 >>>= expression2 parameters expression1 a number or expression to be shifted left. Expression2 a number or expression that converts to an integer fr...

  • Page 92: Chapter 2

    92 chapter 2: actionscript language reference accessibility class availability flash player 6. Description the accessibility class manages communication with screen readers. Screen readers are a type of assistive technology for visually impaired users that provides an audio version of screen content...

  • Page 93

    Accessibility.Isactive() 93 accessibility.Isactive() availability flash player 6. Usage accessibility.Isactive() : boolean parameters none. Returns a boolean value: true if the flash player is communicating with an accessibility aid (usually a screen reader); false otherwise. Description method; ind...

  • Page 94

    94 chapter 2: actionscript language reference accessibility.Updateproperties() availability flash player 6 (6.0.65). Usage accessibility.Updateproperties() : void parameters none. Returns nothing. Description method; causes all changes to _accprops (accessibility properties) objects to take effect. ...

  • Page 95: Chapter 2

    _accprops 95 _accprops availability flash player 6.65. Usage _accprops.Propertyname instancename._accprops.Propertyname parameters propertyname an accessibility property name (see the following description for valid names). Instancename the instance name assigned to an instance of a movie clip, butt...

  • Page 96

    96 chapter 2: actionscript language reference to specify settings that correspond to the tab index setting in the accessibility panel, use the button.Tabindex , movieclip.Tabindex , or textfield.Tabindex property. There is no way to specify an auto label setting at runtime. To refer to the _accprops...

  • Page 97

    _accprops 97 if you don’t specify an accessibility property for a document or an object, any values set in the accessibility panel are implemented. After you specify an accessibility property, you can’t revert its value to a value set in the accessibility panel. However, you can set the property to ...

  • Page 98: Chapter 2

    98 chapter 2: actionscript language reference arguments object availability flash player 5; property added in flash player 6. Description the arguments object is an array that contains the values that were passed as parameters to any function. Each time a function is called in actionscript, an argum...

  • Page 99

    Arguments.Callee 99 arguments.Callee availability flash player 5. Usage arguments.Callee:function description property; refers to the function that is currently being called. Example you can use the arguments.Callee property to make an anonymous function that is recursive, as shown in the following ...

  • Page 100

    100 chapter 2: actionscript language reference arguments.Caller availability flash player 6. Usage arguments.Caller:function description property; refers to the calling function. The value of this property is null if the current function was not called by another function. Example the following exam...

  • Page 101

    Arguments.Length 101 arguments.Length availability flash player 5. Usage arguments.Length:number description property; the number of parameters actually passed to a function. Example the following actionscript includes a function called getarglength , which returns the number of arguments that are p...

  • Page 102: Chapter 2

    102 chapter 2: actionscript language reference array() availability flash player 6. Usage array() : array array(numelements:number) : array array( [element0:object [, element1 , element2,...Elementn ] ]) : array parameters element one or more elements to place in the array. Returns an array. Descrip...

  • Page 103: Chapter 2

    Array class 103 array class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the array class lets you access and manipulate arrays. An array is an object whose properties are identified by a number representing their positi...

  • Page 104

    104 chapter 2: actionscript language reference constructor for the array class availability flash player 5. Usage new array() : array new array(length:number) : array new array(element0, element1, element2,...Elementn) : array parameters length an integer that specifies the number of elements in the...

  • Page 105

    Array class 105 usage 3: the following example creates the new array object go_gos_array with an initial length of 5: var go_gos_array:array = new array("belinda", "gina", "kathy", "charlotte", "jane"); trace(go_gos_array.Length); // returns 5 trace(go_gos_array.Join(", ")); // displays elements the...

  • Page 106

    106 chapter 2: actionscript language reference array.Concat() availability flash player 5. Usage my_array.Concat( [ value0:object, value1,...Valuen ]) : array parameters value0,...Valuen numbers, elements, or strings to be concatenated in a new array. If you don’t pass any values, a duplicate of my_...

  • Page 107

    Array.Join() 107 array.Join() availability flash player 5. Usage my_array.Join([separator:string]) : string parameters separator a character or string that separates array elements in the returned string. If you omit this parameter, a comma (,) is used as the default separator. Returns a string. Des...

  • Page 108

    108 chapter 2: actionscript language reference array.Length availability flash player 5. Usage my_array.Length:number description property; a non-negative integer specifying the number of elements in the array. This property is automatically updated when new elements are added to the array. When you...

  • Page 109

    Array.Pop() 109 array.Pop() availability flash player 5. Usage my_array.Pop() : object parameters none. Returns the value of the last element in the specified array. Description method; removes the last element from an array and returns the value of that element. Example the following code creates t...

  • Page 110

    110 chapter 2: actionscript language reference array.Push() availability flash player 5. Usage my_array.Push(value,...) : number parameters value one or more values to append to the array. Returns an integer representing the length of the new array. Description method; adds one or more elements to t...

  • Page 111

    Array.Reverse() 111 array.Reverse() availability flash player 5. Usage my_array.Reverse() : void parameters none. Returns nothing. Description method; reverses the array in place. Example the following example uses this method to reverse the array numbers_array : var numbers_array:array = new array(...

  • Page 112

    112 chapter 2: actionscript language reference array.Shift() availability flash player 5. Usage my_array.Shift() : object parameters none. Returns the first element in an array. Description method; removes the first element from an array and returns that element. Example the following code creates t...

  • Page 113

    Array.Slice() 113 array.Slice() availability flash player 5. Usage my_array.Slice( [ start:number [ , end:number ] ] ) : array parameters start a number specifying the index of the starting point for the slice. If start is a negative number, the starting point begins at the end of the array, where -...

  • Page 115

    Array.Sort() 115 by default, array . Sort() works as described in the following list: • sorting is case-sensitive (z precedes a). • sorting is ascending (a precedes b). • the array is modified to reflect the sort order; multiple elements that have identical sort fields are placed consecutively in th...

  • Page 118

    118 chapter 2: actionscript language reference by default, array . Sorton() works as described in the following list: • sorting is case-sensitive (z precedes a). • sorting is ascending (a precedes b). • the array is modified to reflect the sort order; multiple elements that have identical sort field...

  • Page 119

    Array.Sorton() 119 // barb // abcd performing a default sort on the age field produces the following results: my_array.Sorton("age"); // 29 // 3 // 35 // 4 performing a numeric sort on the age field produces the following results: my_array.Sorton("age", 16); // 3 // 4 // 29 // 35 performing a descen...

  • Page 120

    120 chapter 2: actionscript language reference // my_array[2].Age = 35; // my_array[3].Age = 4; example the following example creates a new array and sorts it according to the fields name and city : the first sort uses name as the first sort value and city as the second. The second sort uses city as...

  • Page 121

    Array.Splice() 121 array.Splice() availability flash player 5. Usage my_array.Splice(start:number, deletecount:number [, value0:object, value1...Valuen]) : array parameters start an integer that specifies the index of the element in the array where the insertion or deletion begins. Deletecount an in...

  • Page 122

    122 chapter 2: actionscript language reference the following example creates an array and splices it using element index 1 for the start parameter, the number 0 for the deletecount parameter, and the string chair for the value parameter. This does not remove anything from the original array, and add...

  • Page 123

    Array.Tostring() 123 array.Tostring() availability flash player 5. Usage my_array.Tostring() : string parameters none. Returns a string. Description method; returns a string value representing the elements in the specified array object. Every element in the array, starting with index 0 and ending wi...

  • Page 124

    124 chapter 2: actionscript language reference array.Unshift() availability flash player 5. Usage my_array.Unshift(value1:object,value2,...Valuen) : number parameters value1,...Valuen one or more numbers, elements, or variables to be inserted at the beginning of the array. Returns an integer represe...

  • Page 125: Chapter 2

    Asfunction 125 asfunction availability flash player 5. Usage asfunction:function:function,"parameter":string parameters function an identifier for a function. Parameter a string that is passed to the function named in the function parameter. Returns nothing. Description protocol; a special protocol ...

  • Page 126: Chapter 2

    126 chapter 2: actionscript language reference boolean() availability flash player 5; behavior changed in flash player 7. Usage boolean(expression) : boolean parameters expression an expression to convert to a boolean value. Returns a boolean value. Description function; converts the parameter expre...

  • Page 127

    Boolean() 127 if files are published for flash player 6 or earlier, the results will differ for three of the preceding examples: trace(boolean("true")); // output: false trace(boolean("false")); // output: false trace(boolean("craiggers")); // output: false this example shows a string that will eval...

  • Page 128: Chapter 2

    128 chapter 2: actionscript language reference boolean class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the boolean class is a wrapper object with the same functionality as the standard javascript boolean object. Use ...

  • Page 129

    Boolean.Tostring() 129 boolean.Tostring() availability flash player 5. Usage myboolean.Tostring() : string parameters none. Returns a string; "true" or "false" . Description method; returns the string representation ( "true" or "false" ) of the boolean object. Example this example creates a variable...

  • Page 130

    130 chapter 2: actionscript language reference boolean.Valueof() availability flash player 5. Usage myboolean.Valueof() : boolean parameters none. Returns a boolean value. Description method: returns true if the primitive value type of the specified boolean object is true; false otherwise. Example t...

  • Page 131: Chapter 2

    Break 131 break availability flash player 4. Usage break parameters none. Returns nothing. Description statement; 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 st...

  • Page 132

    132 chapter 2: actionscript language reference see also for , for..In , do while , while , switch , case , continue , throw , try..Catch..Finally.

  • Page 133: Chapter 2

    Button class 133 button class availability flash player 6. Description all button symbols in a swf file are instances of the button object. You can give a button an instance name in the property inspector, and use the methods and properties of the button class to manipulate buttons with actionscript...

  • Page 134

    134 chapter 2: actionscript language reference event handler summary for the button class button.Usehandcursor a boolean value that indicates whether the pointing hand is displayed when the mouse passes over a button. Button._visible a boolean value that indicates whether a button instance is hidden...

  • Page 135

    Button._alpha 135 button._alpha availability flash player 6. Usage my_btn._alpha:number description property; the alpha transparency value of the button specified by my_btn . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a button with _alpha set t...

  • Page 136

    136 chapter 2: actionscript language reference button.Enabled availability flash player 6. Usage my_btn.Enabled:boolean description property; a boolean value that specifies whether a button is enabled. When a button is disabled (the enabled property is set to false ), the button is visible but canno...

  • Page 137

    Button._focusrect 137 button._focusrect availability flash player 6. Usage my_btn._focusrect:boolean description property; a boolean value that specifies whether a button has a yellow rectangle around it when it has keyboard focus. This property can override the global _focusrect property. By defaul...

  • Page 138

    138 chapter 2: actionscript language reference button.Getdepth() availability flash player 6. Usage my_btn.Getdepth() : number returns an integer. Description method; returns the depth of a button instance. Example if you create mybtn1_btn and mybtn2_btn on the stage, you can trace their depth using...

  • Page 139

    Button._height 139 button._height availability flash player 6. Usage my_btn._height:number description property; the height of the button, in pixels. Example the following example sets the height and width of a button called my_btn to a specified width and height. My_btn._width = 500; my_btn._height...

  • Page 140

    140 chapter 2: actionscript language reference button.Menu availability flash player 7. Usage my_btn.Menu = contextmenu parameters contextmenu a contextmenu object. Description property; associates the contextmenu object contextmenu with the button object my_button . The contextmenu class lets you m...

  • Page 141

    Button._name 141 button._name availability flash player 6. Usage my_btn . _name:string description property; instance name of the button specified by my_btn . Example the following example traces all instance names of any button instances within the current timeline of a swf file. For (i in this) { ...

  • Page 142

    142 chapter 2: actionscript language reference button.Ondragout availability flash player 6. Usage my_btn.Ondragout = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is clicked over the button and the pointer th...

  • Page 143

    Button.Ondragover 143 button.Ondragover availability flash player 6. Usage my_btn.Ondragover = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the user presses and drags the mouse button outside and then over the button. You mus...

  • Page 144

    144 chapter 2: actionscript language reference button.Onkeydown availability flash player 6. Usage my_btn.Onkeydown = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a button has keyboard focus and a key is pressed. The onkeydow...

  • Page 145

    Button.Onkeydown 145 see also button.Onkeyup.

  • Page 146

    146 chapter 2: actionscript language reference button.Onkeyup availability flash player 6. Usage my_btn.Onkeyup = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a button has input focus and a key is released. The onkeyup event ...

  • Page 147

    Button.Onkeyup 147 press control+enter to test the swf file. Make sure you select control > disable keyboard shortcuts in the test environment. Then press the tab key until the button has focus (a yellow rectangle appears around the my_btn instance) and start pressing keys on your keyboard. When you...

  • Page 148

    148 chapter 2: actionscript language reference button.Onkillfocus availability flash player 6. Usage my_btn.Onkillfocus = function (newfocus:object) : void { // your statements here } parameters newfocus the object that is receiving the focus. Returns nothing. Description event handler; invoked when...

  • Page 149

    Button.Onpress 149 button.Onpress availability flash player 6. Usage my_btn.Onpress = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a button is pressed. You must define a function that executes when the event handler is invoke...

  • Page 150

    150 chapter 2: actionscript language reference button.Onrelease availability flash player 6. Usage my_btn.Onrelease = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a button is released. You must define a function that executes...

  • Page 151

    Button.Onreleaseoutside 151 button.Onreleaseoutside availability flash player 6. Usage my_btn.Onreleaseoutside = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse is released while the pointer is outside the button after...

  • Page 152

    152 chapter 2: actionscript language reference button.Onrollout availability flash player 6. Usage my_btn.Onrollout = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer moves outside a button area. You must define a fun...

  • Page 153

    Button.Onrollover 153 button.Onrollover availability flash player 6. Usage my_btn.Onrollover = function() : void { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer moves over a button area. You must define a function that executes when t...

  • Page 154

    154 chapter 2: actionscript language reference button.Onsetfocus availability flash player 6. Usage my_btn.Onsetfocus = function(oldfocus:object) : void { // your statements here } parameters oldfocus the object to lose keyboard focus. Returns nothing. Description event handler; invoked when a butto...

  • Page 155

    Button._parent 155 button._parent availability flash player 6. Usage my_btn._parent:movieclip.Property _parent:movieclip.Property description property; a reference to the movie clip or object that contains the current movie clip or object. The current object is the one containing the actionscript co...

  • Page 156

    156 chapter 2: actionscript language reference button._quality availability flash player 6. Usage my_btn._quality:string description 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. ...

  • Page 157

    Button._rotation 157 button._rotation availability flash player 6. Usage my_btn._rotation:number description property; the rotation of the button, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. ...

  • Page 158

    158 chapter 2: actionscript language reference button._soundbuftime availability flash player 6. Usage my_btn._soundbuftime:number description property (global); an integer that specifies the number of seconds a sound prebuffers before it starts to stream. Note: although you can specify this propert...

  • Page 159

    Button.Tabenabled 159 button.Tabenabled availability flash player 6. Usage my_btn.Tabenabled:boolean description property; 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...

  • Page 160

    160 chapter 2: actionscript language reference button.Tabindex availability flash player 6. Usage my_btn.Tabindex:number description property; lets you customize the tab ordering of objects in a swf file. You can set the tabindex property on a button, movie clip, or text field instance; it is undefi...

  • Page 161

    Button._target 161 button._target availability flash player 6. Usage my_btn._target:string description read-only property; returns the target path of the button instance specified by my_btn . Example add a button instance to the stage with an instance name my_btn and add the following code to frame ...

  • Page 162

    162 chapter 2: actionscript language reference button.Trackasmenu availability flash player 6. Usage my_btn.Trackasmenu:boolean description property; a boolean value that indicates whether other buttons or movie clips can receive mouse release events. If you drag a button and then release on a secon...

  • Page 163

    Button._url 163 button._url availability flash player 6. Usage my_btn . _url:string description read-only property; retrieves the url of the swf file that created the button. Example create two button instances on the stage called one_btn and two_btn . Enter the following actionscript in frame 1 of ...

  • Page 164

    164 chapter 2: actionscript language reference button.Usehandcursor availability flash player 6. Usage my_btn.Usehandcursor:boolean description property; a boolean value that, when set to true (the default), indicates whether a pointing hand (hand cursor) displays when the mouse rolls over a button....

  • Page 165

    Button._visible 165 button._visible availability flash player 6. Usage my_btn._visible:boolean description property; a boolean value that indicates whether the button specified by my_btn is visible. Buttons that are not visible ( _visible property set to false ) are disabled. Example create two butt...

  • Page 166

    166 chapter 2: actionscript language reference button._width availability flash player 6. Usage my_btn._width:number description property; the width of the button, in pixels. Example the following example increases the width property of a button called my_btn , and displays the width in the output p...

  • Page 167

    Button._x 167 button._x availability flash player 6. Usage my_btn._x:number description property; an integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip. If a button is on the main timeline, then its coordinate system refers to the upper left cor...

  • Page 168

    168 chapter 2: actionscript language reference button._xmouse availability flash player 6. Usage my_btn._xmouse:number description read-only property; returns the x coordinate of the mouse position relative to the button. Example the following example displays the xmouse position for the stage and a...

  • Page 169

    Button._xscale 169 button._xscale availability flash player 6. Usage my_btn._xscale:number description property; the horizontal scale of the button as applied from the registration point of the button, expressed as a percentage. The default registration point is (0,0). Scaling the local coordinate s...

  • Page 170

    170 chapter 2: actionscript language reference button._y availability flash player 6. Usage my_btn._y:number description property; the y coordinate of the button relative to the local coordinates of the parent movie clip. If a button is in the main timeline, its coordinate system refers to the upper...

  • Page 171

    Button._ymouse 171 button._ymouse availability flash player 6. Usage my_btn._ymouse:number description read-only property; indicates the y coordinate of the mouse position relative to the button. Example the following example displays the xmouse position for the stage and a button called my_btn that...

  • Page 172

    172 chapter 2: actionscript language reference button._yscale availability flash player 6. Usage my_btn._yscale:number description property; 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). Exam...

  • Page 173: Chapter 2

    Camera class 173 camera class availability flash player 6. Description the camera class is primarily for use with macromedia flash communication server, but can be used in a limited way without the server. The camera class lets you capture video from a video camera attached to the computer that is r...

  • Page 174

    174 chapter 2: actionscript language reference event handler summary for the camera class constructor for the camera class see camera.Get() . Camera.Motionlevel the amount of motion required to invoke camera.Onactivity(true) . Camera.Motiontimeout the number of milliseconds between the time when the...

  • Page 175

    Camera.Activitylevel 175 camera.Activitylevel availability flash player 6. Usage active_cam.Activitylevel:number description read-only property; a numeric value that specifies the amount of motion the camera is detecting. Values range from 0 (no motion is being detected) to 100 (a large amount of mo...

  • Page 176

    176 chapter 2: actionscript language reference camera.Bandwidth availability flash player 6. Usage active_cam.Bandwidth:number description read-only property; an integer that specifies the maximum amount of bandwidth the current outgoing video feed can use, in bytes. A value of 0 means that flash vi...

  • Page 177

    Camera.Currentfps 177 camera.Currentfps availability flash player 6. Usage active_cam.Currentfps:number description read-only property; the rate at which the camera is capturing data, in frames per second. This property cannot be set; however, you can use the camera.Setmode() method to set a related...

  • Page 178

    178 chapter 2: actionscript language reference camera.Fps availability flash player 6. Usage active_cam.Fps:number description read-only property; the maximum rate at which you want the camera to capture data, in frames per second. The maximum rate possible depends on the capabilities of the camera;...

  • Page 179

    Camera.Get() 179 camera.Get() availability flash player 6. Usage camera.Get([index:number]) : camera note: the correct syntax is camera.Get() . To assign the camera object to a variable, use syntax like active_cam = camera.Get() . Parameters index an optional zero-based integer that specifies which ...

  • Page 180

    180 chapter 2: actionscript language reference the user can also specify permanent privacy settings for a particular domain by right-clicking (windows) or control-clicking (macintosh) while a swf file is playing, selecting settings, opening the privacy panel, and selecting remember. You can’t use ac...

  • Page 181

    Camera.Height 181 camera.Height availability flash player 6. Usage active_cam.Height:number description read-only property; the current capture height, in pixels. To set a value for this property, use camera.Setmode() . Example the following code displays the current width, height and fps of a video...

  • Page 182

    182 chapter 2: actionscript language reference camera.Index availability flash player 6. Usage active_cam.Index:number description read-only property; a zero-based integer that specifies the index of the camera, as reflected in the array returned by camera.Names . Example the following example displ...

  • Page 183

    Camera.Motionlevel 183 camera.Motionlevel availability flash player 6. Usage active_cam.Motionlevel:number description read-only property; a numeric value that specifies the amount of motion required to invoke camera.Onactivity(true) . Acceptable values range from 0 to 100. The default value is 50. ...

  • Page 184

    184 chapter 2: actionscript language reference /* when the level of activity changes goes above or below the number defined in camera.Motionlevel, trigger the onactivity event handler. If the activitylevel is above the value defined in the motionlevel property isactive will be set to true. Otherwise...

  • Page 185

    Camera.Motiontimeout 185 camera.Motiontimeout availability flash player 6. Usage active_cam.Motiontimeout:number description read-only property; the number of milliseconds between the time the camera stops detecting motion and the time camera.Onactivity (false) is invoked. The default value is 2000 ...

  • Page 186

    186 chapter 2: actionscript language reference see also camera.Onactivity , camera.Setmotionlevel().

  • Page 187

    Camera.Muted 187 camera.Muted availability flash player 6. Usage active_cam.Muted:boolean description read-only property; a boolean value that specifies whether the user has denied access to the camera ( true ) or allowed access ( false ) in the flash player privacy settings panel. When this value c...

  • Page 188

    188 chapter 2: actionscript language reference camera.Name availability flash player 6. Usage active_cam.Name:string description read-only property; a string that specifies the name of the current camera, as returned by the camera hardware. Example the following example displays the name of the defa...

  • Page 189

    Camera.Names 189 camera.Names availability flash player 6. Usage camera.Names:array note: the correct syntax is camera.Names . To assign the return value to a variable, use syntax like cam_array = camera.Names . To determine the name of the current camera, use active_cam.Name . Description read-only...

  • Page 190

    190 chapter 2: actionscript language reference camera.Onactivity availability flash player 6. Usage active_cam.Onactivity = function(activity:boolean) : void { // your statements here } parameters activity a boolean value set to true when the camera starts detecting motion, false when it stops. Retu...

  • Page 191

    Camera.Onstatus 191 camera.Onstatus availability flash player 6. Usage active_cam.Onstatus = function(infoobject:object) : void { // your statements here } parameters infoobject a parameter defined according to the status message. Returns nothing. Description event handler; invoked when the user all...

  • Page 192

    192 chapter 2: actionscript language reference trace("camera access granted"); break; } }; see also camera.Get() , camera.Muted , system.Showsettings() ; system.Onstatus.

  • Page 193

    Camera.Quality 193 camera.Quality availability flash player 6. Usage active_cam.Quality:number description read-only property; an integer specifying the required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable quality values range fr...

  • Page 194

    194 chapter 2: actionscript language reference camera.Setmode() availability flash player 6. Usage active_cam.Setmode(width:number, height:number, fps:number [,favorsize:boolean]) : void parameters width the requested capture width, in pixels. The default value is 160. Height the requested capture h...

  • Page 195

    Camera.Setmode() 195 example the following example sets the camera capture mode. You can type a frame rate into a textinput instance and press enter or return to apply the frame rate. Create a new video instance by selecting new video from the library options menu. Add an instance to the stage and g...

  • Page 196

    196 chapter 2: actionscript language reference camera.Setmotionlevel() availability flash player 6. Usage active_cam.Setmotionlevel(sensitivity:number [, timeout:number]) : void parameters sensitivity a numeric value that specifies the amount of motion required to invoke camera.Onactivity(true) . Ac...

  • Page 197

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

  • Page 198

    198 chapter 2: actionscript language reference camera.Setquality() availability flash player 6. Usage active_cam.Setquality(bandwidth:number, framequality:number) : void parameters bandwidth an integer that specifies the maximum amount of bandwidth that the current outgoing video feed can use, in by...

  • Page 199

    Camera.Setquality() 199 example the following examples illustrate how to use this method to control bandwidth use and picture quality. // ensure that no more than 8192 (8k/second) is used to send video active_cam.Setquality(8192,0); // ensure that no more than 8192 (8k/second) is used to send video ...

  • Page 200

    200 chapter 2: actionscript language reference camera.Width availability flash player 6. Usage active_cam.Width:number description read-only property; the current capture width, in pixels. To set a desired value for this property, use camera.Setmode() . Example the following code displays the curren...

  • Page 201: Chapter 2

    Case 201 case availability flash player 4. Usage case expression: statement(s) parameters expression any expression. Statement(s) any statement or sequence of statements. Returns nothing. Description statement; defines a condition for the switch statement. If the expression parameter equals the expr...

  • Page 202

    202 chapter 2: actionscript language reference see also break , default , === (strict equality) , switch.

  • Page 203: Chapter 2

    Class 203 class availability flash player 6. Usage [dynamic] class classname [ extends superclass ] [ implements interfacename [, interfacename... ] ] { // class definition 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 fi...

  • Page 204

    204 chapter 2: actionscript language reference to indicate that objects can add and access dynamic properties at runtime, precede the class statement with the dynamic keyword. To declare that a class implements an interface, use the implements keyword. To create subclasses of a class, use the extend...

  • Page 205

    Class 205 }; var jpeg_mcl:moviecliploader = new moviecliploader(); jpeg_mcl.Addlistener(listenerobject); jpeg_mcl.Loadclip(image, target_mc); } } in an external script file or in the actions panel, use the new operator to create a imageloader object. Var jakob_mc:movieclip = this.Createemptymoviecli...

  • Page 206: Chapter 2

    206 chapter 2: actionscript language reference clearinterval() availability flash player 6. Usage clearinterval( intervalid:number ) : void parameters intervalid a numeric (integer) identifier returned from a call to setinterval() . Returns nothing. Description function; cancels an interval created ...

  • Page 207: Chapter 2

    Color class 207 color class availability flash player 5. Description the color class lets you set the rgb color value and color transform of movie clips and retrieve those values once they have been set. You must use the constructor new color() to create a color object before calling its methods. Me...

  • Page 208

    208 chapter 2: actionscript language reference color.Getrgb() availability flash player 5. Usage my_color.Getrgb() : number parameters none. Returns a number that represents the rgb numeric value for the color specified. Description method; returns the numeric values set by the last setrgb() call. E...

  • Page 209

    Color.Gettransform() 209 color.Gettransform() availability flash player 5. Usage my_color.Gettransform() : object parameters none. Returns an object whose properties contain the current offset and percentage values for the specified color. Description method; returns the transform value set by the l...

  • Page 210

    210 chapter 2: actionscript language reference color.Setrgb() availability flash player 5. Usage my_color.Setrgb(0xrrggbb:number) : void parameters 0xrrggbb the hexadecimal or rgb color to be set. Rr , gg , and bb each consist of two hexadecimal digits that specify the offset of each color component...

  • Page 211

    Color.Settransform() 211 color.Settransform() availability flash player 5. Usage my_color.Settransform(colortransformobject:object) : void parameters colortransformobject an object created with the new object constructor. This instance of the object class must have the following properties that spec...

  • Page 212

    212 chapter 2: actionscript language reference 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...

  • Page 213: Chapter 2

    Contextmenu class 213 contextmenu class availability flash player 7. Description the contextmenu class provides runtime control over the items in the flash player context menu, which appears when a user right-clicks (windows) or control-clicks (macintosh) on flash player. You can use the methods and...

  • Page 214

    214 chapter 2: actionscript language reference property summary for the contextmenu class event handler summary for the contextmenu class constructor for the contextmenu class availability flash player 7. Usage new contextmenu ([callbackfunction]) parameters callbackfunction a reference to a functio...

  • Page 215

    Contextmenu class 215 var showitem = true; // change this to false to remove var my_cm:contextmenu = new contextmenu(menuhandler); my_cm.Customitems.Push(new contextmenuitem("hello", itemhandler)); function menuhandler(obj, menuobj) { if (showitem == false) { menuobj.Customitems[0].Enabled = false; ...

  • Page 216

    216 chapter 2: actionscript language reference contextmenu.Builtinitems availability flash player 7. Usage my_cm.Builtinitems:object description property; an object that has the following boolean properties: save , zoom , quality , play , loop , rewind , forward_back , and print . Setting these vari...

  • Page 217

    Contextmenu.Copy() 217 contextmenu.Copy() availability flash player 7. Usage my_cm.Copy() : contextmenu parameters none. Returns a contextmenu object. Description method; creates a copy of the specified contextmenu object. The copy inherits all the properties of the original menu object. Example thi...

  • Page 218

    218 chapter 2: actionscript language reference contextmenu.Customitems availability flash player 7. Usage my_cm.Customitems:array description property; an array of contextmenuitem objects. Each object in the array represents a context menu item that you have defined. Use this property to add, remove...

  • Page 219

    Contextmenu.Hidebuiltinitems() 219 contextmenu.Hidebuiltinitems() availability flash player 7. Usage my_cm.Hidebuiltinitems() : void parameters none. Returns nothing. Description method; hides all built-in menu items (except settings) in the specified contextmenu object. If the flash debug player is...

  • Page 220

    220 chapter 2: actionscript language reference contextmenu.Onselect availability flash player 7. Usage my_cm.Onselect = function (item:object, item_menu:contextmenu) : void{ // your code here } parameters item a reference to the object (movie clip, button, or selectable text field) that was under th...

  • Page 221: Chapter 2

    Contextmenuitem class 221 contextmenuitem class availability flash player 7. Description you use the contextmenuitem class to create custom menu items to display in the flash player context menu. Each contextmenuitem object has a caption (text) that is displayed in the context menu, and a callback h...

  • Page 222

    222 chapter 2: actionscript language reference constructor for the contextmenuitem class availability flash player 7. Usage new contextmenuitem(caption:string, callbackfunction:function, [ separatorbefore:boolean, [ enabled:boolean, [ visible:boolean] ] ] ) : contextmenuitem parameters caption a str...

  • Page 223

    Contextmenuitem.Caption 223 contextmenuitem.Caption availability flash player 7. Usage menuitem_cmi.Caption:string description property; a string that specifies the menu item caption (text) displayed in the context menu. Example the following example displays the caption for the selected menu item (...

  • Page 224

    224 chapter 2: actionscript language reference contextmenuitem.Copy() availability flash player 7. Usage menuitem_cmi.Copy() : contextmenuitem returns a contextmenuitem object. Description method; creates and returns a copy of the specified contextmenuitem object. The copy includes all properties of...

  • Page 225

    Contextmenuitem.Enabled 225 contextmenuitem.Enabled availability flash player 7. Usage menuitem_cmi.Enabled:boolean description property; a boolean value that indicates whether the specified menu item is enabled or disabled. By default, this property is true . Example the following example creates t...

  • Page 226

    226 chapter 2: actionscript language reference contextmenuitem.Onselect availability flash player 7. Usage menuitem_cmi.Onselect = function (obj:object, menuitem:contextmenuitem) : void { // your statements here } parameters obj a reference to the movie clip (or timeline), button, or selectable text...

  • Page 227

    Contextmenuitem.Separatorbefore 227 contextmenuitem.Separatorbefore availability flash player 7. Usage menuitem_cmi.Separatorbefore:boolean description property; a boolean value that indicates whether a separator bar should appear above the specified menu item. By default, this property is false . N...

  • Page 228

    228 chapter 2: actionscript language reference contextmenuitem.Visible availability flash player 7. Usage menuitem_cmi.Visible:boolean description property; a boolean value that indicates whether the specified menu item is visible when the flash player context menu is displayed. By default, this pro...

  • Page 229: Chapter 2

    Continue 229 continue availability flash player 4. Usage continue parameters none. Returns nothing. Description statement; 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 normally. It has no e...

  • Page 230

    230 chapter 2: actionscript language reference 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...

  • Page 231: Chapter 2

    Customactions class 231 customactions class availability flash player 6. Description the methods of the customactions class allow a swf file playing in the flash authoring tool to manage any custom actions that are registered with the authoring tool. A swf file can install and uninstall custom actio...

  • Page 232

    232 chapter 2: actionscript language reference customactions.Get() availability flash player 6. Usage customactions.Get(customname:string) : string parameters customname the name of the custom action definition to retrieve. Returns if the custom action xml definition is located, returns a string; ot...

  • Page 233

    Customactions.Install() 233 customactions.Install() availability flash player 6. Usage customactions.Install(customname:string, customxml:string) : boolean parameters customname the name of the custom action definition to install. Customxml the text of the xml definition to install. Returns a boolea...

  • Page 234

    234 chapter 2: actionscript language reference then open a new fla file in the same directory and select frame 1 of the timeline. Enter the following code into the actions panel: var my_xml:xml = new xml(); my_xml.Ignorewhite = true; my_xml.Onload = function(success:boolean) { trace(success); custom...

  • Page 235

    Customactions.List() 235 customactions.List() availability flash player 6. Usage customactions.List() : array parameters none. Returns an array. Description method; returns an array object containing the names of all the custom actions that are registered with the flash authoring tool. The elements ...

  • Page 236

    236 chapter 2: actionscript language reference customactions.Uninstall() availability flash player 6. Usage customactions.Uninstall(customname:string) : boolean parameters customname the name of the custom action definition to uninstall. Returns a boolean value of false if no custom actions are foun...

  • Page 237: Chapter 2

    Date class 237 date class availability flash player 5. Description the date class lets you retrieve date and time values relative to universal time (greenwich mean time, now called universal time or utc) or relative to the operating system on which flash player is running. The methods of the date cl...

  • Page 238

    238 chapter 2: actionscript language reference date.Getmilliseconds() returns the milliseconds according to local time. Date.Getminutes() returns the minutes according to local time. Date.Getmonth() returns the month according to local time. Date.Getseconds() returns the seconds according to local t...

  • Page 239

    Date class 239 constructor for the date class availability flash player 5. Usage new date() : date new date(timevalue:number) : date new date(year:number, month:number [, date:number [, hour:number [, minute:number [, second:number [, millisecond:number ]]]]]) : date parameters year a value of 0 to ...

  • Page 240

    240 chapter 2: actionscript language reference description constructor; constructs a new date object that holds the specified date or the current date and time. Example the following example retrieves the current date and time: var now_date:date = new date(); the following example creates a new date...

  • Page 241

    Date.Getdate() 241 date.Getdate() availability flash player 5. Usage my_date.Getdate() : number parameters none. Returns an integer. Description method; returns the day of the month (an integer from 1 to 31) of the specified date object according to local time. Local time is determined by the operat...

  • Page 242

    242 chapter 2: actionscript language reference date.Getday() availability flash player 5. Usage my_date.Getday() : number parameters none. Returns an integer representing the day of the week. Description method; returns the day of the week (0 for sunday, 1 for monday, and so on) of the specified dat...

  • Page 243

    Date.Getfullyear() 243 date.Getfullyear() availability flash player 5. Usage my_date.Getfullyear() : number parameters none. Returns an integer representing the year. Description method; returns the full year (a four-digit number, such as 2000) of the specified date object, according to local time. ...

  • Page 244

    244 chapter 2: actionscript language reference date.Gethours() availability flash player 5. Usage my_date.Gethours() : number parameters none. Returns an integer. Description method; returns the hour (an integer from 0 to 23) of the specified date object, according to local time. Local time is deter...

  • Page 245

    Date.Getmilliseconds() 245 date.Getmilliseconds() availability flash player 5. Usage my_date.Getmilliseconds() : number parameters none. Returns an integer. Description method; returns the milliseconds (an integer from 0 to 999) of the specified date object, according to local time. Local time is de...

  • Page 246

    246 chapter 2: actionscript language reference date.Getminutes() availability flash player 5. Usage my_date.Getminutes() : number parameters none. Returns an integer. Description method; returns the minutes (an integer from 0 to 59) of the specified date object, according to local time. Local time i...

  • Page 247

    Date.Getmonth() 247 date.Getmonth() availability flash player 5. Usage my_date.Getmonth() : number parameters none. Returns an integer. Description method; returns the month (0 for january, 1 for february, and so on) of the specified date object, according to local time. Local time is determined by ...

  • Page 248

    248 chapter 2: actionscript language reference date.Getseconds() availability flash player 5. Usage my_date.Getseconds() : number parameters none. Returns an integer. Description method; returns the seconds (an integer from 0 to 59) of the specified date object, according to local time. Local time i...

  • Page 249

    Date.Gettime() 249 date.Gettime() availability flash player 5. Usage my_date.Gettime() : number parameters none. Returns an integer. Description method; returns the number of milliseconds since midnight january 1, 1970, universal time, for the specified date object. Use this method to represent a sp...

  • Page 250

    250 chapter 2: actionscript language reference date.Gettimezoneoffset() availability flash player 5. Usage my_date.Gettimezoneoffset() : number parameters none. Returns an integer. Description method; returns the difference, in minutes, between the computer’s local time and universal time. Example t...

  • Page 251

    Date.Getutcdate() 251 date.Getutcdate() availability flash player 5. Usage my_date.Getutcdate() : number parameters none. Returns an integer. Description method; returns the day of the month (an integer from 1 to 31) in the specified date object, according to universal time. Example the following ex...

  • Page 252

    252 chapter 2: actionscript language reference date.Getutcday() availability flash player 5. Usage my_date.Getutcday() : number parameters none. Returns an integer. Description method; returns the day of the week (0 for sunday, 1 for monday, and so on) of the specified date object, according to univ...

  • Page 253

    Date.Getutcfullyear() 253 date.Getutcfullyear() availability flash player 5. Usage my_date.Getutcfullyear() : number parameters none. Returns an integer. Description method; returns the four-digit year of the specified date object, according to universal time. Example the following example creates a...

  • Page 254

    254 chapter 2: actionscript language reference date.Getutchours() availability flash player 5. Usage my_date.Getutchours() : number parameters none. Returns an integer. Description method; returns the hour (an integer from 0 to 23) of the specified date object, according to universal time. Example t...

  • Page 255

    Date.Getutcmilliseconds() 255 date.Getutcmilliseconds() availability flash player 5. Usage my_date.Getutcmilliseconds() : number parameters none. Returns an integer. Description method; returns the milliseconds (an integer from 0 to 999) of the specified date object, according to universal time. Exa...

  • Page 256

    256 chapter 2: actionscript language reference date.Getutcminutes() availability flash player 5. Usage my_date.Getutcminutes() : number parameters none. Returns an integer. Description method; returns the minutes (an integer from 0 to 59) of the specified date object, according to universal time. Ex...

  • Page 257

    Date.Getutcmonth() 257 date.Getutcmonth() availability flash player 5. Usage my_date.Getutcmonth() : number parameters none. Returns an integer. Description method; returns the month (0 [january] to 11 [december]) of the specified date object, according to universal time. Example the following examp...

  • Page 258

    258 chapter 2: actionscript language reference date.Getutcseconds() availability flash player 5. Usage my_date.Getutcseconds() : number parameters none. Returns an integer. Description method; returns the seconds (an integer from 0 to 59) of the specified date object, according to universal time. Ex...

  • Page 259

    Date.Getyear() 259 date.Getyear() availability flash player 5. Usage my_date.Getyear() : number parameters none. Returns an integer. Description method; returns the year of the specified date object, according to local time. Local time is determined by the operating system on which flash player is r...

  • Page 260

    260 chapter 2: actionscript language reference date.Setdate() availability flash player 5. Usage my_date.Setdate(date) : number parameters date an integer from 1 to 31. Returns an integer. Description method; sets the day of the month for the specified date object, according to local time, and retur...

  • Page 261

    Date.Setfullyear() 261 date.Setfullyear() availability flash player 5. Usage my_date.Setfullyear(year:number [, month:number [, date:number]]) : number parameters year a four-digit number specifying a year. Two-digit numbers do not represent four-digit years; for example, 99 is not the year 1999, bu...

  • Page 262

    262 chapter 2: actionscript language reference date.Sethours() availability flash player 5. Usage my_date.Sethours(hour) : number parameters hour an integer from 0 (midnight) to 23 (11 p.M.). Returns an integer. Description method; sets the hours for the specified date object according to local time...

  • Page 263

    Date.Setmilliseconds() 263 date.Setmilliseconds() availability flash player 5. Usage my_date.Setmilliseconds(millisecond:number) : number parameters millisecond an integer from 0 to 999. Returns an integer. Description method; sets the milliseconds for the specified date object according to local ti...

  • Page 264

    264 chapter 2: actionscript language reference date.Setminutes() availability flash player 5. Usage my_date.Setminutes(minute:number) : number parameters minute an integer from 0 to 59. Returns an integer. Description method; sets the minutes for a specified date object according to local time and r...

  • Page 265

    Date.Setmonth() 265 date.Setmonth() availability flash player 5. Usage my_date.Setmonth(month:number [, date:number ]) : number parameters month an integer from 0 (january) to 11 (december). Date an integer from 1 to 31. This parameter is optional. Returns an integer. Description method; sets the mo...

  • Page 266

    266 chapter 2: actionscript language reference date.Setseconds() availability flash player 5. Usage my_date.Setseconds(second:number) : number parameters second an integer from 0 to 59. Returns an integer. Description method; sets the seconds for the specified date object in local time and returns t...

  • Page 267

    Date.Settime() 267 date.Settime() availability flash player 5. Usage my_date.Settime(milliseconds:number) : number parameters milliseconds a number; an integer value where 0 is midnight on january 1, universal time. Returns an integer. Description method; sets the date for the specified date object ...

  • Page 268

    268 chapter 2: actionscript language reference date.Setutcdate() availability flash player 5. Usage my_date.Setutcdate(date:number) : number parameters date a number; an integer from 1 to 31. Returns an integer. Description method; sets the date for the specified date object in universal time and re...

  • Page 269

    Date.Setutcfullyear() 269 date.Setutcfullyear() availability flash player 5. Usage my_date.Setutcfullyear(year:number [, month:number [, date:number]]) : number parameters year an integer that represents the year specified as a full four-digit year, such as 2000. Month an integer from 0 (january) to...

  • Page 270

    270 chapter 2: actionscript language reference date.Setutchours() availability flash player 5. Usage my_date.Setutchours(hour:number [, minute:number [, second:number [, millisecond:number]]]) : number parameters hour a number; an integer from 0 (midnight) to 23 (11 p.M.). Minute a number; an intege...

  • Page 271

    Date.Setutcmilliseconds() 271 date.Setutcmilliseconds() availability flash player 5. Usage my_date.Setutcmilliseconds(millisecond:number) : number parameters millisecond an integer from 0 to 999. Returns an integer. Description method; sets the milliseconds for the specified date object in universal...

  • Page 272

    272 chapter 2: actionscript language reference date.Setutcminutes() availability flash player 5. Usage my_date.Setutcminutes(minute:number [, second:number [, millisecond:number]]) : number parameters minute an integer from 0 to 59. Second an integer from 0 to 59. This parameter is optional. Millise...

  • Page 273

    Date.Setutcmonth() 273 date.Setutcmonth() availability flash player 5. Usage my_date.Setutcmonth(month:number [, date:number]) : number parameters month an integer from 0 (january) to 11 (december). Date an integer from 1 to 31. This parameter is optional. Returns an integer. Description method; set...

  • Page 274

    274 chapter 2: actionscript language reference date.Setutcseconds() availability flash player 5. Usage my_date.Setutcseconds(second:number [, millisecond:number]) : number parameters second an integer from 0 to 59. Millisecond an integer from 0 to 999. This parameter is optional. Returns an integer....

  • Page 275

    Date.Setyear() 275 date.Setyear() availability flash player 5. Usage my_date.Setyear(year:number) : number parameters year a number that represents the year. If year is an integer between 0–99, setyear sets the year at 1900 + year ; otherwise, the year is the value of the year parameter. Returns an ...

  • Page 276

    276 chapter 2: actionscript language reference date.Tostring() availability flash player 5. Usage my_date.Tostring() : string parameters none. Returns a string. Description method; returns a string value for the specified date object in a readable format. Example the following example returns the in...

  • Page 277

    Date.Utc() 277 date.Utc() availability flash player 5. Usage date.Utc(year:number, month:number [, date:number [, hour:number [, minute:number [, second:number [, millisecond:number ]]]]]) : number parameters year a four-digit integer that represents the year (for example, 2000). Month an integer fr...

  • Page 278: Chapter 2

    278 chapter 2: actionscript language reference default availability flash player 6. Usage default: statements parameters statements any statements. Returns nothing. Description statement; defines the default case for a switch statement. The statements execute if the expression parameter of the switc...

  • Page 279: Chapter 2

    Delete 279 delete availability flash player 5. Usage delete reference parameters reference the name of the variable or object to eliminate. Returns a boolean value. Description operator; destroys the object reference specified by the reference parameter, and returns true if the reference is successf...

  • Page 280

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

  • Page 281: Chapter 2

    Do while 281 do while availability flash player 4. Usage do { statement(s) } while (condition) parameters condition the condition to evaluate. Statement(s) the statement(s) to execute as long as the condition parameter evaluates to true . Returns nothing. Description statement; similar to a while lo...

  • Page 282

    282 chapter 2: actionscript language reference see also break , continue , while.

  • Page 283: Chapter 2

    Duplicatemovieclip() 283 duplicatemovieclip() availability flash player 4. Usage duplicatemovieclip(target:string, newname:string, depth:number) : void parameters target the target path of the movie clip to duplicate. Newname a unique identifier for the duplicated movie clip. Depth a unique depth le...

  • Page 284: Chapter 2

    284 chapter 2: actionscript language reference dynamic availability flash player 6. Usage dynamic class classname [ extends superclass ] [ implements interfacename [, interfacename... ] ] { // class definition here } note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or ...

  • Page 285

    Dynamic 285 /* output: craig.Age = 32 craig.Name = craiggers */ if you add an undeclared function, dance , an error is generated, as shown in the following example: trace(""); craig.Dance = true; for (i in craig) { trace("craig."+i +" = "+ craig[i]); } /* output: **error** scene=scene 1, layer=layer...

  • Page 286: Chapter 2

    286 chapter 2: actionscript language reference else availability flash player 4. Usage if (condition){ statement(s); } else { statement(s); } parameters condition an expression that evaluates to true or false . Statement(s) an alternative series of statements to run if the condition specified in the...

  • Page 287: Chapter 2

    Else if 287 else if availability flash player 4. Usage if (condition){ statement(s); } else if (condition){ statement(s); } parameters condition an expression that evaluates to true or false . Statement(s) an alternative series of statements to run if the condition specified in the if statement is f...

  • Page 288: Chapter 2

    288 chapter 2: actionscript language reference #endinitclip availability flash player 6. Usage #endinitclip parameters none. Returns nothing. Description compiler directive; indicates the end of a block of initialization actions. Example #initclip ...Initialization actions go here... #endinitclip se...

  • Page 289: Chapter 2

    Error class 289 error class availability flash player 7. Description contains information about an error that occurred in a script. You create an error object using the error constructor function. Typically, you throw a new error object from within a try code block that is then caught by a catch or ...

  • Page 290

    290 chapter 2: actionscript language reference throw new error("strings to not match."); } } try { comparestrings("dog", "dog"); // output: strings to not match. } catch (e_err:error) { trace(e_err.Tostring()); } see also throw , try..Catch..Finally.

  • Page 291

    Error.Message 291 error.Message availability flash player 7. Usage my_err.Message:string description property; contains the message associated with the error object. By default, the value of this property is " error ". You can specify a message property when you create an error object by passing the...

  • Page 292

    292 chapter 2: actionscript language reference error.Name availability flash player 7. Usage myerror.Name:string description property; contains the name of the error object. By default, the value of this property is "error" . Example in the following example, a function throws a specified error depe...

  • Page 293

    Error.Tostring() 293 error.Tostring() availability flash player 7. Usage my_err.Tostring() : string returns a string. Description method; returns the string "error" by default or the value contained in error.Message , if defined. Example in the following example, a function throws an error (with a s...

  • Page 294: Chapter 2

    294 chapter 2: actionscript language reference escape() availability flash player 5. Usage escape(expression:string) : string parameters expression the expression to convert into a string and encode in a url-encoded format. Returns url-encoded string. Description function; converts the parameter to ...

  • Page 295: Chapter 2

    Eval() 295 eval() availability flash player 5 or later for full functionality. You can use the eval() function when exporting to flash player 4, but you must use slash notation and can access only variables, not properties or objects. Usage eval(expression:string) : object parameters expression a st...

  • Page 296

    296 chapter 2: actionscript language reference you can also use the following actionscript: for (var i = 1; i this["square"+i+"_mc"]._rotation = -5; } see also array class , set variable.

  • Page 297: Chapter 2

    Extends 297 extends availability flash player 6. Usage class classname extends otherclassname {} interface interfacename extends otherinterfacename {} 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 ...

  • Page 298

    298 chapter 2: actionscript language reference the following example shows a second as file, called car.As, in the same directory. This class extends the vehicle class, modifying it in three ways. First, the car class adds a variable fullsizespare to track whether the car object has a full-size spar...

  • Page 299: Chapter 2

    False 299 false availability flash player 5. Usage false description constant; a unique boolean value that represents the opposite of true . When automatic data typing converts false to a number, it becomes 0; when it converts false to a string, it becomes "false" . For more information, see “automa...

  • Page 300: Chapter 2

    300 chapter 2: actionscript language reference _focusrect availability flash player 4. Usage _focusrect = boolean; description property (global); specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. If _focusrect is set to its default value of true , ...

  • Page 301: Chapter 2

    For 301 for availability flash player 5. Usage for(init; condition; next) { statement(s); } parameters init an expression to evaluate before beginning the looping sequence; usually an assignment expression. A var statement is also permitted for this parameter. Condition an expression that evaluates ...

  • Page 302

    302 chapter 2: actionscript language reference the following example shows that curly braces ({}) are not necessary if only one statement will execute: var sum:number = 0; for (var i:number = 1; i sum += i; trace(sum); // output: 5050 see also ++ (increment) , –– (decrement) , for..In , var , while ...

  • Page 303: Chapter 2

    For..In 303 for..In availability flash player 5. Usage for(variableiterant in object){ statement(s); } parameters variableiterant the name of a variable to act as the iterant, referencing each property of an object or element in an array. Object the name of an object to be iterated. Statement(s) an ...

  • Page 304

    304 chapter 2: actionscript language reference //output myobject.Name = tara myobject.Age = 27 myobject.City = san francisco 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("mya...

  • Page 305: Chapter 2

    Fscommand() 305 fscommand() availability flash player 3. Usage fscommand("command", "parameters") parameters command a string passed to the host application for any use, or a command passed to flash player. Parameters a string passed to the host application for any use, or a value passed to flash pl...

  • Page 306

    306 chapter 2: actionscript language reference the exec command can contain only the characters a–z, a–z, 0–9, period (.), and underscore (_). The exec command runs in the subdirectory fscommand only. In other words, if you use the fscommand exec command to call an application, the application must ...

  • Page 307

    Fscommand() 307 function mydocument_dofscommand(command, args) { if (command == "messagebox") { alert(args); } } in the flash document, add the fscommand() function to a button: fscommand("messagebox", "this is a message box called from within flash.") you can also use expressions for the fscommand(...

  • Page 308: Chapter 2

    308 chapter 2: actionscript language reference function availability flash player 5. Usage function functionname ([parameter0, parameter1,...Parametern]){ statement(s) } function ([parameter0, parameter1,...Parametern]){ statement(s) } parameters functionname the name of the new function. This param...

  • Page 309

    Function 309 example the following example defines the function sqr , which accepts one parameter and returns the math.Pow(x, 2) of the parameter: function sqr(x:number) { return math.Pow(x, 2); } var y:number = sqr(3); trace(y); // output: 9 if the function is defined and used in the same script, t...

  • Page 310: Chapter 2

    310 chapter 2: actionscript language reference function class availability flash player 6. Description both user-defined and built-in functions in actionscript are represented by function objects, which are instances of the function class. Method summary for the function class method description fun...

  • Page 311

    Function.Apply() 311 function.Apply() availability flash player 6. Usage myfunction.Apply(thisobject:object, argumentsarray:array) parameters thisobject the object to which myfunction is applied. Argumentsarray an array whose elements are passed to myfunction as parameters. Returns any value that th...

  • Page 312

    312 chapter 2: actionscript language reference trace("this == myobj? " + (this == myobj)); trace("arguments: " + arguments); } // instantiate an object var myobj:object = new object(); // create arrays to pass as a parameter to apply() var firstarray:array = new array(1,2,3); var secondarray:array =...

  • Page 313

    Function.Call() 313 function.Call() availability flash player 6. Usage myfunction.Call(thisobject:object, parameter1, ..., parametern) parameters thisobject an object that specifies the value of this within the function body. Parameter1 a parameter to be passed to the myfunction . You can specify ze...

  • Page 314

    314 chapter 2: actionscript language reference var obj:object = new myobject(); mymethod.Call(obj, obj); the trace() statement displays: this == obj? True see also function.Apply().

  • Page 315: Chapter 2

    Get 315 get availability flash player 6. Usage function get property() { // 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. This keyword is supported only when used in ext...

  • Page 316

    316 chapter 2: actionscript language reference 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 t...

  • Page 317: Chapter 2

    Getproperty() 317 getproperty() availability flash player 4. Usage getproperty(my_mc:object, property:object) : object parameters my_mc the instance name of a movie clip for which the property is being retrieved. Property a property of a movie clip. Returns the value of the specified property. Descr...

  • Page 318: Chapter 2

    318 chapter 2: actionscript language reference gettimer() availability flash player 4. Usage gettimer() : number parameters none. Returns the number of milliseconds that have elapsed since the swf file started playing. Description function; returns the number of milliseconds that have elapsed since ...

  • Page 319: Chapter 2

    Geturl() 319 geturl() availability flash 2. The get and post options are available only in flash player 4 and later versions. Usage geturl(url:string [, window:string [, "variables":string]]) : void parameters url the url from which to obtain the document. Window an optional parameter specifying the...

  • Page 320

    320 chapter 2: actionscript language reference in the following example, geturl() is used to send an e-mail message: mybtn_btn.Onrelease = function(){ geturl("mailto:you@somedomain.Com"); }; in the following actionscript, javascript is used to open an alert window when the swf file is embedded in a ...

  • Page 321: Chapter 2

    Getversion() 321 getversion() availability flash player 5. Usage getversion() : string parameters none. Returns a string containing flash player version and platform information. Description function; returns a string containing flash player version and platform information. The getversion function ...

  • Page 322: Chapter 2

    322 chapter 2: actionscript language reference _global object availability flash player 6. Usage _global.Identifier parameters none. Returns a reference to the global object that holds the core actionscript classes, such as string, object, math, and array. Description identifier; creates global vari...

  • Page 323: Chapter 2

    Gotoandplay() 323 gotoandplay() availability flash 2. Usage gotoandplay([scene:string,] frame:object) : void parameters scene an optional string specifying the name of the scene to which the playhead is sent. Frame a number representing the frame number, or a string representing the label of the fra...

  • Page 324: Chapter 2

    324 chapter 2: actionscript language reference gotoandstop() availability flash 2. Usage gotoandstop([scene:string,] frame:object) : void parameters scene an optional string specifying the name of the scene to which the playhead is sent. Frame a number representing the frame number, or a string repr...

  • Page 325: Chapter 2

    If 325 if availability flash player 4. Usage if(condition) { statement(s); } parameters condition an expression that evaluates to true or false . Statement(s) the instructions to execute if or when the condition evaluates to true . Returns nothing. Description statement; evaluates a condition to det...

  • Page 326

    326 chapter 2: actionscript language reference } else { this._parent.Message_txt.Text = "very good, you hit the button in "+difference+" seconds."; } }; see also else.

  • Page 327: Chapter 2

    Implements 327 implements availability flash player 6. Usage myclass implements interface01 [, interface02, ...] 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 wh...

  • Page 328: Chapter 2

    328 chapter 2: actionscript language reference import availability flash player 6. Usage 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 s...

  • Page 329

    Import 329 for more information on importing, see “importing classes” and “using packages” in using actionscript in flash..

  • Page 330: Chapter 2

    330 chapter 2: actionscript language reference #include availability flash player 4. Usage #include "[path] filename.As" note: do not place a semicolon (;) at the end of the line that contains the #include statement. Parameters [path] filename.As the filename and optional path for the script to add ...

  • Page 331

    #include 331 to specify an absolute path for the as file, use the format supported by your platform (macintosh or windows). See the following example section. (this usage is not recommended because it requires the directory structure to be the same on any computer that you use to compile the script....

  • Page 332: Chapter 2

    332 chapter 2: actionscript language reference infinity availability flash player 5. Usage infinity description constant; specifies the ieee-754 value representing positive infinity. The value of this constant is the same as number.Positive_infinity . Chapter 2 actionscript language reference.

  • Page 333: Chapter 2

    #initclip 333 #initclip availability flash player 6. Usage #initclip order parameters order an integer that specifies the execution order of blocks of #initclip code. This is an optional parameter. Description compiler directive; indicates the beginning of a block of initialization actions. When mul...

  • Page 334: Chapter 2

    334 chapter 2: actionscript language reference instanceof availability flash player 6. Usage object instanceof class parameters object an actionscript object. Class a reference to an actionscript constructor function, such as string or date. Returns if object is an instance of class , instanceof ret...

  • Page 335: Chapter 2

    Interface 335 interface availability flash player 6. Usage 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...

  • Page 336

    336 chapter 2: actionscript language reference // filename ib.As 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 mvar = new d(); trace(mvar...

  • Page 337: Chapter 2

    Intrinsic 337 intrinsic availability flash player 6. Usage intrinsic class classname [ extends superclass ] [ implements interfacename [, interfacename... ] ] { // class definition here } note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of you...

  • Page 338

    338 chapter 2: actionscript language reference this.Radius = radius; this.Getarea = function(){ 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 ...

  • Page 339: Chapter 2

    Isfinite() 339 isfinite() availability flash player 5. Usage isfinite(expression:object) : boolean parameters expression a boolean value, variable, or other expression to be evaluated. Returns a boolean value. Description function; evaluates expression and returns true if it is a finite number or fa...

  • Page 340: Chapter 2

    340 chapter 2: actionscript language reference isnan() availability flash player 5. Usage isnan(expression:object) : boolean parameters expression a boolean, variable, or other expression to be evaluated. Returns a boolean value. Description function; evaluates the parameter and returns true if the ...

  • Page 341: Chapter 2

    Key class 341 key class availability flash player 6. Description the key class is a top-level class whose methods and properties you can use without using a constructor. Use the methods of the key class to build an interface that can be controlled by a user with a standard keyboard. The properties o...

  • Page 342

    342 chapter 2: actionscript language reference listener summary for the key class key.Pgup the key code value for the page up key. 33 key.Right the key code value for the right arrow key. 39 key.Shift the key code value for the shift key. 16 key.Space the key code value for the spacebar. 32 key.Tab ...

  • Page 343

    Key.Addlistener() 343 key.Addlistener() availability flash player 6. Usage key.Addlistener (newlistener:object) : void parameters newlistener an object with methods onkeydown and onkeyup . Returns nothing. Description method; registers an object to receive onkeydown and onkeyup notification. When a ...

  • Page 344

    344 chapter 2: actionscript language reference mylistener.Onkeydown = myonkeydown; key.Addlistener(mylistener); my_btn.Onpress = myonpress; my_btn._accprops.Shortcut = "ctrl+7"; accessibility.Updateproperties(); see also key.Getcode() , key.Isdown() , key.Onkeydown , key.Onkeyup , key.Removelistener...

  • Page 345

    Key.Backspace 345 key.Backspace availability flash player 5. Usage key.Backspace:number description property; constant associated with the key code value for the backspace key (8). Example the following example creates a new listener object and defines a function for onkeydown . The last line uses a...

  • Page 346

    346 chapter 2: actionscript language reference key.Capslock availability flash player 5. Usage key.Capslock:number description property; constant associated with the key code value for the caps lock key (20). Example the following example creates a new listener object and defines a function for onke...

  • Page 347

    Key.Control 347 key.Control availability flash player 5. Usage key.Control:number description property; constant associated with the key code value for the control key (17). Example the following example assigns the keyboard shortcut control+7 to a button with an instance name of my_btn and makes in...

  • Page 348

    348 chapter 2: actionscript language reference key.Deletekey availability flash player 5. Usage key.Deletekey:number description property; constant associated with the key code value for the delete key (46). Example the following example lets you draw lines with the mouse pointer using the drawing a...

  • Page 349

    Key.Down 349 key.Down availability flash player 5. Usage key.Down:number description property; constant associated with the key code value for the down arrow key (40). Example the following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. A sound plays...

  • Page 350

    350 chapter 2: actionscript language reference key.End availability flash player 5. Usage key.End:number description property; constant associated with the key code value for the end key (35)..

  • Page 351

    Key.Enter 351 key.Enter availability flash player 5. Usage key.Enter:number description property; constant associated with the key code value for the enter key (13). Example the following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. The car_mc inst...

  • Page 352

    352 chapter 2: actionscript language reference key.Escape availability flash player 5. Usage key.Escape:number description property; constant associated with the key code value for the escape key (27). Example the following example sets a timer. When you press escape, the output panel displays infor...

  • Page 353

    Key.Getascii() 353 key.Getascii() availability flash player 5. Usage key.Getascii() : number parameters none. Returns a number; an integer that represents the ascii value of the last key pressed. Description method; returns the ascii code of the last key pressed or released. The ascii values returne...

  • Page 354

    354 chapter 2: actionscript language reference key.Getcode() availability flash player 5. Usage key.Getcode() : number parameters none. Returns a number; an integer that represents the key code of the last key pressed. Description method; returns the key code value of the last key pressed. To match ...

  • Page 355

    Key.Home 355 key.Home availability flash player 5. Usage key.Home:number description property; constant associated with the key code value for the home key (36). Example the following example attaches a draggable movie clip called car_mc at the x and y coordinates of 0,0. When you press the home key...

  • Page 356

    356 chapter 2: actionscript language reference key.Insert availability flash player 5. Usage key.Insert:number description property; constant associated with the key code value for the insert key (45). Example the following example creates a new listener object and defines a function for onkeydown ....

  • Page 357

    Key.Isdown() 357 key.Isdown() availability flash player 5. Usage key.Isdown(keycode:number) : boolean parameters keycode the key code value assigned to a specific key or a key class property associated with a specific key. To match the returned key code value with the key on a standard keyboard, see...

  • Page 358

    358 chapter 2: actionscript language reference key.Istoggled() availability flash player 5. Usage key.Istoggled(keycode:number) : boolean parameters keycode the key code for the caps lock key (20) or the num lock key (144). Returns a boolean value. Description method: returns true if the caps lock o...

  • Page 359

    Key.Istoggled() 359 numlock_txt.Autosize = true; numlock_txt.Html = true; // var keylistener:object = new object(); keylistener.Onkeydown = function() { capslock_txt.Htmltext = "caps lock: "+key.Istoggled(key.Capslock); numlock_txt.Htmltext = "num lock: "+key.Istoggled(144); }; key.Addlistener(keyli...

  • Page 360

    360 chapter 2: actionscript language reference key.Left availability flash player 5. Usage key.Left:number description property; constant associated with the key code value for the left arrow key (37). Example the following example moves a movie clip called car_mc a constant distance (10) when you p...

  • Page 361

    Key.Onkeydown 361 key.Onkeydown availability flash player 6. Usage keylistener.Onkeydown description listener; notified when a key is pressed. To use onkeydown, you must create a listener object. You can then define a function for onkeydown and use addlistener() to register the listener with the key...

  • Page 362

    362 chapter 2: actionscript language reference key.Onkeyup availability flash player 6. Usage keylistener.Onkeyup description listener; 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...

  • Page 363

    Key.Pgdn 363 key.Pgdn availability flash player 5. Usage key.Pgdn:number description property; constant associated with the key code value for the page down key (34). Example the following example rotates a movie clip called car_mc when you press the page down and page up keys. Var keylistener:objec...

  • Page 364

    364 chapter 2: actionscript language reference key.Pgup availability flash player 5. Usage key.Pgup:number description property; constant associated with the key code value for the page up key (33). Example the following example rotates a movie clip called car_mc when you press the page down and pag...

  • Page 365

    Key.Removelistener() 365 key.Removelistener() availability flash player 6. Usage key.Removelistener (listener:object) : boolean parameters listener an object. Returns if the listener was successfully removed, the method returns true . If the listener was not successfully removed (for example, becaus...

  • Page 366

    366 chapter 2: actionscript language reference key.Right availability flash player 5. Usage key.Right:number description property; constant associated with the key code value for the right arrow key (39). Example the following example moves a movie clip called car_mc a constant distance (10) when yo...

  • Page 367

    Key.Shift 367 key.Shift availability flash player 5. Usage key.Shift:number description property; constant associated with the key code value for the shift key (16). Example the following example scales car_mc when you press shift. Var keylistener:object = new object(); keylistener.Onkeydown = funct...

  • Page 368

    368 chapter 2: actionscript language reference key.Space availability flash player 5. Usage key.Space:number description property; constant associated with the key code value for the spacebar (32). Example the following example moves a movie clip called car_mc a constant distance (10) when you press...

  • Page 369

    Key.Tab 369 key.Tab availability flash player 5. Usage key.Tab:number description property; constant associated with the key code value for the tab key (9). Example the following example creates a text field, and displays the date in the text field when you press tab. This.Createtextfield("date_txt"...

  • Page 370

    370 chapter 2: actionscript language reference key.Up availability flash player 5. Usage key.Up:number description property; constant associated with the key code value for the up arrow key (38). Example the following example moves a movie clip called car_mc a constant distance (10) when you press t...

  • Page 371: Chapter 2

    _level 371 _level availability flash player 4. Usage _leveln description identifier; a reference to the root timeline of _leveln . You must use loadmovienum() to load swf files into the flash player before you use the _level property to target them. You can also use _leveln to target a loaded swf fi...

  • Page 372: Chapter 2

    372 chapter 2: actionscript language reference loadmovie() availability flash player 3. Usage loadmovie(url:string,target:object [, method:string]) : void loadmovie(url:string,target:string [, method:string]) : void parameters url the absolute or relative url of the swf or jpeg file to be loaded. A ...

  • Page 373

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

  • Page 374: Chapter 2

    374 chapter 2: actionscript language reference loadmovienum() availability flash player 4. Flash 4 files opened in flash 5 or later are converted to use the correct syntax. Usage loadmovienum(url:string,level:number [, variables:string]) : void parameters url the absolute or relative url of the swf ...

  • Page 375

    Loadmovienum() 375 the loadmovienum() action also lets you load jpeg files into a swf file while it plays. For images and swf files, the upper left corner of the image aligns with the upper left corner of the stage when the file loads. Also in both cases, the loaded file inherits rotation and scalin...

  • Page 376: Chapter 2

    376 chapter 2: actionscript language reference loadvariables() availability flash player 4; behavior changed in flash player 7. Usage loadvariables (url:string , target:object [, variables:string]) : void parameters url an absolute or relative url where the variables are located. If the swf file iss...

  • Page 377

    Loadvariables() 377 if you want to load variables into a specific level, use loadvariablesnum() instead of loadvariables() . Example the following example loads information from a text file called params.Txt into the target_mc movie clip that is created using createemptymovieclip() . The setinterval...

  • Page 378: Chapter 2

    378 chapter 2: actionscript language reference loadvariablesnum() availability flash player 4; behavior changed in flash player 7. Flash 4 files opened in flash 5 or later are converted to use the correct syntax. Usage loadvariablesnum (url:string ,level:number [, variables:string]) : void parameter...

  • Page 379

    Loadvariablesnum() 379 if you want to load variables into a target movieclip, use loadvariables() instead of loadvariablesnum() . Example the following example loads information from a text file called params.Txt into the main timeline of the swf at level 2 in flash player. The variable names of the...

  • Page 380: Chapter 2

    380 chapter 2: loadvars class availability flash player 6. Description the loadvars class is an alternative to the loadvariables() function for transferring variables between a flash application and a server. You can use the loadvars class to obtain verification of successful data loading and to mon...

  • Page 381

    Loadvars class 381 property summary for the loadvars class event handler summary for the loadvars class constructor for the loadvars class availability flash player 6. Usage new loadvars() : loadvars parameters none. Returns a reference to a loadvars object. Description constructor; creates a loadva...

  • Page 382

    382 chapter 2: loadvars.Addrequestheader() availability flash player 6. Usage my_lv.Addrequestheader(headername:string, headervalue:string) : void my_lv.Addrequestheader(["headername_1":string, "headervalue_1" ... "headername_n", "headervalue_n":string]) : void parameters headername a string that re...

  • Page 383

    Loadvars.Addrequestheader() 383 see also xml.Addrequestheader().

  • Page 384

    384 chapter 2: loadvars.Contenttype availability flash player 6. Usage my_lv.Contenttype:string description property; 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. Example the following example cre...

  • Page 385

    Loadvars.Decode() 385 loadvars.Decode() availability flash player 7. Usage my_lv.Decode(variables:string) : void parameters variables a url-encoded query string containing name/value pairs. Returns nothing. Description method; converts the variable string to properties of the specified loadvars obje...

  • Page 386

    386 chapter 2: loadvars.Getbytesloaded() availability flash player 6. Usage my_lv.Getbytesloaded() : number parameters none. Returns an integer. Description method; returns the number of bytes downloaded by loadvars.Load() or loadvars.Sendandload() . This method returns undefined if no load operatio...

  • Page 387

    Loadvars.Getbytestotal() 387 loadvars.Getbytestotal() availability flash player 6. Usage my_lv.Getbytestotal() : number parameters none. Returns an integer. Description method; returns the total number of bytes downloaded by loadvars.Load() or loadvars.Sendandload() . This method returns undefined i...

  • Page 388

    388 chapter 2: } }; my_lv.Load("[place a valid url pointing to a text file here]");.

  • Page 389

    Loadvars.Load() 389 loadvars.Load() availability flash player 6; behavior changed in flash player 7. Usage my_lv.Load(url:string) : boolean parameters url 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 do...

  • Page 390

    390 chapter 2: trace(this.Tostring()); } else { trace("error loading/parsing loadvars."); } }; my_lv.Load("http://www.Flash-mx.Com/mm/params.Txt"); for an in-depth example, see “using the loadvars class” in using actionscript in flash and the macromedia devnet article “macromedia flash mx and php” a...

  • Page 391

    Loadvars.Loaded 391 loadvars.Loaded availability flash player 6. Usage my_lv.Loaded:boolean description property; 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 loa...

  • Page 392

    392 chapter 2: loadvars.Ondata availability flash player 6. Usage my_lv.Ondata = function(src:string) { // your statements here } parameters src a string or undefined ; the raw (unparsed) data from a loadvars.Load() or loadvars.Sendandload() method call. Returns nothing. Description event handler; i...

  • Page 393

    Loadvars.Onload 393 loadvars.Onload availability flash player 6. Usage my_lv.Onload = function(success:boolean) { // your statements here } parameters success a boolean value that indicates whether the load operation ended in success ( true ) or failure ( false ). Returns a boolean value. Descriptio...

  • Page 394

    394 chapter 2: to view a more robust example, see the login.Fla file in the helpexamples folder. Typical paths to the helpexamples folder are: • windows: \program files\macromedia\flash mx 2004\samples\helpexamples\ • macintosh: hd/applications/macromedia flash mx 2004/samples/helpexamples/ • loadva...

  • Page 395

    Loadvars.Send() 395 loadvars.Send() availability flash player 6. Usage my_lv.Send(url:string,target:string [, method:string]) : boolean parameters url a string; the url to which to upload variables. Target a string; the browser window or frame in which any response will appear. You can enter the nam...

  • Page 396

    396 chapter 2: example the following example copies two values from text fields and sends the data to a cfm script, which is used to handle the information. For example, the script might check if the user got a high score and then insert that data into a database table. Var my_lv:loadvars = new load...

  • Page 397

    Loadvars.Sendandload() 397 loadvars.Sendandload() availability flash player 6; behavior changed in flash player 7. Usage my_lv.Sendandload(url:string , targetobject[, method:string]) : boolean parameters url a string; the url to which to upload variables. If the swf file issuing this call is running...

  • Page 398

    398 chapter 2: 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_...

  • Page 399

    Loadvars.Tostring() 399 loadvars.Tostring() availability flash player 6. Usage my_lv.Tostring() : string parameters none. Returns a string. Description method; returns a string containing all enumerable variables in my_lv , in the mime content encoding application/x-www-form-urlencoded. Example the ...

  • Page 400: Chapter 2

    400 chapter 2: actionscript language reference localconnection class availability flash player 6. Description the localconnection class lets you develop swf files that can send instructions to each other without the use of fscommand() or javascript. Localconnection objects can communicate only among...

  • Page 401

    Localconnection class 401 event handler summary for the localconnection class constructor for the localconnection class availability flash player 6. Usage new localconnection() : localconnection parameters none. Returns a reference to a localconnection object. Description constructor; creates a loca...

  • Page 402

    402 chapter 2: actionscript language reference see also localconnection.Connect() , localconnection.Send().

  • Page 403

    Localconnection.Allowdomain 403 localconnection.Allowdomain availability flash player 6; behavior changed in flash player 7. Usage receiving_lc.Allowdomain = function([sendingdomain:string]) : boolean { // your statements here return true or false } parameters sendingdomain a string that represents ...

  • Page 404

    404 chapter 2: actionscript language reference sendingdomain=="store.Domain.Com"); } also, for files authored for 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 the loc...

  • Page 405

    Localconnection.Allowdomain 405 the following example sends a string to the previous swf file and displays a status message about whether the local connection was able to connect to the file. A textinput component called name_ti , a textarea instance called status_ta and a button instance called sen...

  • Page 406

    406 chapter 2: actionscript language reference localconnection.Allowinsecuredomain availability flash player 7. Usage receiving_lc.Allowinsecuredomain = function([sendingdomain:string]) : boolean { // your statements here return true or false } parameters sendingdomain a string that represents an op...

  • Page 407

    Localconnection.Allowinsecuredomain 407 }; my_lc.Allowinsecuredomain = function(sendingdomain:string) { return (sendingdomain == this.Domain()); } my_lc.Sayhello = function(name:string) { welcome_txt.Text = "hello, "+name; }; my_lc.Connect("lc_name"); see also localconnection.Allowdomain , localconn...

  • Page 408

    408 chapter 2: actionscript language reference localconnection.Close() availability flash player 6. Usage receiving_lc.Close() : void parameters none. Returns nothing. Description method; closes (disconnects) a localconnection object. Issue this command when you no longer want the object to accept c...

  • Page 409

    Localconnection.Connect() 409 localconnection.Connect() availability flash player 6. Usage receiving_lc.Connect(connectionname:string) : boolean parameters connectionname a string that corresponds to the connection name specified in the localconnection.Send() command that wants to communicate with r...

  • Page 410

    410 chapter 2: actionscript language reference if you are implementing communication between swf files in different domains, specifying a string for connectionname that begins with an underscore (_) will make the swf with the receiving localconnection object more portable between domains. Here are t...

  • Page 411

    Localconnection.Connect() 411 playback_pb.Setstyle("themecolor", "haloblue"); this.Createemptymovieclip("timer_mc", this.Getnexthighestdepth()); var receiving_lc:localconnection = new localconnection(); receiving_lc.Playmp3 = function(mp3path:string, mp3name:string) { song_lbl.Text = mp3name; playba...

  • Page 412

    412 chapter 2: actionscript language reference localconnection.Domain() availability flash player 6; behavior changed in flash player 7. Usage my_lc.Domain() : string parameters none. Returns a string representing the domain of the location of the current swf file; for more information, see the desc...

  • Page 413

    sendingdomain=="www.Macromedia.Com"); } in the following example, a sending swf file located at www.Yourdomain.Com invokes a method in a receiving swf file located at www.Mydomain...

  • Page 414

    414 chapter 2: actionscript language reference 52 return (adomain == "mydomain.Com"); 53 } 54 lc.Aresult = function(aparam) { 55 trace("the sum is " + aparam); 56 } // determine our domain and see if we need to truncate it 57 var channeldomain:string = lc.Domain(); 58 if (getversion() >= 7 && this.G...

  • Page 415

    Localconnection.Onstatus 415 localconnection.Onstatus availability flash player 6. Usage sending_lc.Onstatus = function(infoobject:object) : void{ // your statements here } parameters infoobject a parameter defined according to the status message. For details about this parameter, see the descriptio...

  • Page 416

    416 chapter 2: actionscript language reference sending_lc = new localconnection(); sending_lc.Onstatus = function(infoobject:object) { switch (infoobject.Level) { case 'status' : status_ta.Text = "localconnection connected successfully."; break; case 'error' : status_ta.Text = "localconnection encou...

  • Page 417

    Localconnection.Send() 417 localconnection.Send() availability flash player 6. Usage sending_lc.Send (connectionname:string, method:string [, p1,...,pn]) : boolean parameters connectionname a string that corresponds to the connection name specified in the localconnection.Connect() command that wants...

  • Page 418

    418 chapter 2: actionscript language reference • include the superdomain in connectionname in the sending localconnection object—for example, mydomain.Com:myconnectionname . In the receiving object, use localconnection.Allowdomain to specify that connections from the specified superdomain will be ac...

  • Page 419: Chapter 2

    Math class 419 math class availability flash player 5. 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. Description the math class is a top-level class whose...

  • Page 420

    420 chapter 2: actionscript language reference property summary for the math class all the following properties for the math class are constants: math.Pow() computes x raised to the power of the y . Math.Random() returns a pseudo-random number between 0.0 and 1.0. Math.Round() rounds to the nearest ...

  • Page 421

    Math.Abs() 421 math.Abs() availability flash player 5. 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. Usage math.Abs(x:number) : number parameters x a numb...

  • Page 422

    422 chapter 2: actionscript language reference math.Acos() availability flash player 5. 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. Usage math.Acos(x:nu...

  • Page 423

    Math.Asin() 423 math.Asin() availability flash player 5. 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. Usage math.Asin(x:number) : number; parameters x a ...

  • Page 424

    424 chapter 2: actionscript language reference math.Atan() availability flash player 5. 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. Usage math.Atan(tang...

  • Page 425

    Math.Atan2() 425 math.Atan2() availability flash player 5. 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. Usage math.Atan2(y:number, x:number) : number par...

  • Page 426

    426 chapter 2: actionscript language reference math.Ceil() availability flash player 5. 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. Usage math.Ceil(x:nu...

  • Page 427

    Math.Cos() 427 math.Cos() availability flash player 5. 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. Usage math.Cos(x:number) : number parameters x a numb...

  • Page 428

    428 chapter 2: actionscript language reference math.E availability flash player 5. 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. Usage math.E:number descr...

  • Page 429

    Math.Exp() 429 math.Exp() availability flash player 5. 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. Usage math.Exp(x:number) : number parameters x the ex...

  • Page 430

    430 chapter 2: actionscript language reference math.Floor() availability flash player 5. 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. Usage math.Floor(x:...

  • Page 431

    Math.Log() 431 math.Log() availability flash player 5. 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. Usage math.Log(x:number) : number parameters x a numb...

  • Page 432

    432 chapter 2: actionscript language reference math.Ln2 availability flash player 5. 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. Usage math.Ln2:number d...

  • Page 433

    Math.Ln10 433 math.Ln10 availability flash player 5. 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. Usage math.Ln10:number description constant; a mathemat...

  • Page 434

    434 chapter 2: actionscript language reference math.Log2e availability flash player 5. 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. Usage math.Log2e:numb...

  • Page 435

    Math.Log10e 435 math.Log10e availability flash player 5. 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. Usage math.Log10e:number description constant; a ma...

  • Page 436

    436 chapter 2: actionscript language reference math.Max() availability flash player 5. 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. Usage math.Max(x:numb...

  • Page 437

    Math.Min() 437 math.Min() availability flash player 5. 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. Usage math.Min(x:number , y:number) : number paramete...

  • Page 438

    438 chapter 2: actionscript language reference math.Pi availability flash player 5. 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. Usage math.Pi:number par...

  • Page 439

    Math.Pow() 439 math.Pow() availability flash player 5. 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. Usage math.Pow(x:number , y:number) : number paramete...

  • Page 440

    440 chapter 2: actionscript language reference math.Random() availability flash player 5. 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. Usage math.Random(...

  • Page 441

    Math.Round() 441 math.Round() availability flash player 5. 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. Usage math.Round(x:number) : number parameters x ...

  • Page 442

    442 chapter 2: actionscript language reference math.Sin() availability flash player 5. 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. Usage math.Sin(x:numb...

  • Page 443

    Math.Sqrt() 443 math.Sqrt() availability flash player 5. 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. Usage math.Sqrt(x:number) : number parameters x a n...

  • Page 444

    444 chapter 2: actionscript language reference math.Sqrt1_2 availability flash player 5. 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. Usage math.Sqrt1_2:...

  • Page 445

    Math.Sqrt2 445 math.Sqrt2 availability flash player 5. 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. Usage math.Sqrt2 description constant; a mathematical...

  • Page 446

    446 chapter 2: actionscript language reference math.Tan() availability flash player 5. 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. Usage math.Tan(x:numb...

  • Page 447: Chapter 2

    Microphone class 447 microphone class availability flash player 6. Description the microphone class lets you capture audio from a microphone attached to the computer that is running flash player. The microphone class is primarily for use with flash communication server but can be used in a limited f...

  • Page 448

    448 chapter 2: actionscript language reference event handler summary for the microphone class constructor for the microphone class see microphone.Get() . Microphone.Names class property; an array of strings reflecting the names of all available sound capture devices, including sound cards and microp...

  • Page 449

    Microphone.Activitylevel 449 microphone.Activitylevel availability flash player 6. Usage active_mic.Activitylevel:number description read-only property; a numeric value that specifies the amount of sound the microphone is detecting. Values range from 0 (no sound is being detected) to 100 (very loud ...

  • Page 450

    450 chapter 2: actionscript language reference microphone.Gain availability flash player 6. Usage active_mic.Gain:number description read-only property; the amount by which the microphone boosts the signal. Valid values are 0 to 100. The default value is 50. Example the following example uses a prog...

  • Page 451

    Microphone.Get() 451 microphone.Get() availability flash player 6. Usage microphone.Get([index:number]) : microphone note: the correct syntax is microphone.Get() . To assign the microphone object to a variable, use syntax like active_mic = microphone.Get() . Parameters index an optional zero-based i...

  • Page 452

    452 chapter 2: actionscript language reference the user can also specify permanent privacy settings for a particular domain by right-clicking (windows) or control-clicking (macintosh) while a swf file is playing, choosing settings, opening the privacy panel, and selecting remember. You can’t use act...

  • Page 453

    Microphone.Index 453 microphone.Index availability flash player 6. Usage active_mic.Index:number description read-only property; a zero-based integer that specifies the index of the microphone, as reflected in the array returned by microphone.Names . Example the following example displays the names ...

  • Page 454

    454 chapter 2: actionscript language reference microphone.Muted availability flash player 6. Usage active_mic.Muted:boolean description read-only property; a boolean value that specifies whether the user has denied access to the microphone ( true ) or allowed access ( false ). When this value change...

  • Page 455

    Microphone.Name 455 microphone.Name availability flash player 6. Usage active_mic.Name:string description read-only property; a string that specifies the name of the current sound capture device, as returned by the sound capture hardware. Example the following example displays information about the ...

  • Page 456

    456 chapter 2: actionscript language reference microphone.Names availability flash player 6. Usage microphone.Names:array note: the correct syntax is microphone.Names . To assign the return value to a variable, use syntax like mic_array = microphone.Names . To determine the name of the current micro...

  • Page 457

    Microphone.Onactivity 457 microphone.Onactivity availability flash player 6. Usage active_mic.Onactivity = function(activity:boolean) : void { // your statements here } parameters activity a boolean value set to true when the microphone starts detecting sound, and false when it stops. Returns nothin...

  • Page 458

    458 chapter 2: actionscript language reference microphone.Onstatus availability flash player 6. Usage active_mic.Onstatus = function(infoobject:object) : void { // your statements here } parameters infoobject a parameter defined according to the status message. Returns nothing. Description event han...

  • Page 459

    Microphone.Onstatus 459 var active_mic:microphone = microphone.Get(); sound_mc.Attachaudio(active_mic); active_mic.Onstatus = function(infoobj:object) { status_txt._visible = active_mic.Muted; muted_txt.Htmltext = "status: href=\"asfunction:system.Showsettings\">"+infoobj.Code+""; href=\"asfunction:...

  • Page 460

    460 chapter 2: actionscript language reference microphone.Rate availability flash player 6. Usage active_mic.Rate:number description read-only property; the rate at which the microphone is capturing sound, in khz. The default value is 8 khz if your sound capture device supports this value. Otherwise...

  • Page 461

    Microphone.Setgain() 461 microphone.Setgain() availability flash player 6. Usage active_mic.Setgain(gain:number) : void parameters gain an integer that specifies the amount by which the microphone should boost the signal. Valid values are 0 to 100. The default value is 50; however, the user may chan...

  • Page 462

    462 chapter 2: actionscript language reference microphone.Setrate() availability flash player 6. Usage active_mic.Setrate(khz:number) : void parameters khz the rate at which the microphone should capture sound, in khz. Acceptable values are 5, 8, 11, 22, and 44. The default value is 8 khz if your so...

  • Page 463

    Microphone.Setrate() 463 see also microphone.Rate.

  • Page 464

    464 chapter 2: actionscript language reference microphone.Setsilencelevel() availability flash player 6. Usage active_mic.Setsilencelevel(level:number [, timeout:number]) : void parameters level an integer that specifies the amount of sound required to activate the microphone and invoke microphone.O...

  • Page 465

    Microphone.Setsilencelevel() 465 example the following example changes the silence level based on the user’s input in a numericstepper instance called silencelevel_nstep . The progressbar instance called silencelevel_pb modifies its appearance depending on whether the audio stream is considered sile...

  • Page 466

    466 chapter 2: actionscript language reference microphone.Setuseechosuppression() availability flash player 6. Usage active_mic.Setuseechosuppression(suppress:boolean) : void parameters suppress a boolean value indicating whether echo suppression should be used ( true ) or not ( false ). Returns not...

  • Page 467

    Microphone.Setuseechosuppression() 467 active_mic.Setuseechosuppression(evt.Target.Selected); }; useechosuppression_ch.Addeventlistener("click", chlistener); see also microphone.Setgain() , microphone.Useechosuppression.

  • Page 468

    468 chapter 2: actionscript language reference microphone.Silencelevel availability flash player 6. Usage active_mic.Silencelevel:number description read-only property; an integer that specifies the amount of sound required to activate the microphone and invoke microphone.Onactivity(true) . The defa...

  • Page 469

    Microphone.Silencelevel 469 see also microphone.Gain , microphone.Setsilencelevel().

  • Page 470

    470 chapter 2: actionscript language reference microphone.Silencetimeout availability flash player 6. Usage active_mic.Silencetimeout:number description read-only property; a numeric value representing the number of milliseconds between the time the microphone stops detecting sound and the time micr...

  • Page 471

    Microphone.Silencetimeout 471 silencelevel_pb.Label = "activity level: (inactive)"; } }; see also microphone.Setsilencelevel().

  • Page 472

    472 chapter 2: actionscript language reference microphone.Useechosuppression availability flash player 6. Usage active_mic.Useechosuppression:boolean description property (read-only); a boolean value of true if echo suppression is enabled, false otherwise. The default value is false unless the user ...

  • Page 473: Chapter 2

    Mmexecute() 473 mmexecute() availability flash player 7. Usage mmexecute("flash javascript api command;":string) parameters flash javascript api command any command that you can use in a flash javascript (jsfl) file. Returns a string representation of the result, if any, sent by the javascript state...

  • Page 474

    474 chapter 2: actionscript language reference now you can select your file from the bottom of the window > other panels menu. The actionscript trace function does not work from a flash panel; this example uses the javascript fl.Trace version to get the output. It might be easier to copy the results...

  • Page 475: Chapter 2

    Mouse class 475 mouse class availability flash player 5. Description the mouse class is a top-level class whose properties and methods you can access without using a constructor. You can use the methods of the mouse class to hide and show the mouse pointer (cursor) in the swf file. The mouse pointer...

  • Page 476

    476 chapter 2: actionscript language reference mouse.Addlistener() availability flash player 6. Usage mouse.Addlistener (newlistener:object) parameters newlistener an object. Returns nothing. Description method; registers an object to receive notifications of the onmousedown , onmousemove , onmouseu...

  • Page 477

    Mouse.Addlistener() 477 to view the entire script, see the animation.Fla file in the helpexamples folder. The following list shows typical paths to the helpexamples folder: • windows: \program files\macromedia\flash mx 2004\samples\helpexamples\ • macintosh: hd/applications/macromedia flash mx 2004/...

  • Page 478

    478 chapter 2: actionscript language reference mouse.Hide() availability flash player 5. Usage mouse.Hide() : boolean parameters none. Returns a boolean value: true if the pointer is visible; false otherwise. Description method; hides the pointer in a swf file. The pointer is visible by default. Exa...

  • Page 479

    Mouse.Onmousedown 479 mouse.Onmousedown availability flash player 6. Usage somelistener.Onmousedown parameters none. Description listener; notified when the mouse is pressed. To use the onmousedown listener, you must create a listener object. You can then define a function for onmousedown and use ad...

  • Page 480

    480 chapter 2: actionscript language reference see also mouse.Addlistener().

  • Page 481

    Mouse.Onmousemove 481 mouse.Onmousemove availability flash player 6. Usage somelistener.Onmousemove parameters none. Returns nothing. Description listener; notified when the mouse moves. To use the onmousemove listener, you must create a listener object. You can then define a function for onmousemov...

  • Page 482

    482 chapter 2: actionscript language reference the following example hides the standard mouse pointer, and sets the x and y positions of the pointer_mc movie clip instance to the x and y pointer position. Create a movie clip and set its linkage identifier to pointer_id . Add the following actionscri...

  • Page 483

    Mouse.Onmouseup 483 mouse.Onmouseup availability flash player 6. Usage somelistener.Onmouseup parameters none. Returns nothing. Description listener; notified when the mouse is released. To use the onmouseup listener, you must create a listener object. You can then define a function for onmouseup an...

  • Page 484

    484 chapter 2: actionscript language reference mouse.Onmousewheel availability flash player 6 (windows only). Usage somelistener.Onmousewheel = function ( [ delta [, scrolltarget ] ] ) { // your statements here } parameters delta an optional number indicating how many lines should be scrolled for ea...

  • Page 485

    Mouse.Onmousewheel 485 mouselistener.Onmousewheel = function(delta:number) { line_mc._rotation += delta; }; mouselistener.Onmousedown = function() { trace("down"); }; mouse.Addlistener(mouselistener); see also mouse.Addlistener() , textfield.Mousewheelenabled.

  • Page 486

    486 chapter 2: actionscript language reference mouse.Removelistener() availability flash player 6. Usage mouse.Removelistener (listener:object) : boolean parameters listener an object. Returns if the listener object is successfully removed, the method returns true ; if the listener is not successful...

  • Page 487

    Mouse.Removelistener() 487 mouselistener.Onmouseup = function() { this.Isdrawing = false; }; mouse.Addlistener(mouselistener); var clearlistener:object = new object(); clearlistener.Click = function() { canvas_mc.Clear(); }; clear_button.Addeventlistener("click", clearlistener); // var stopdrawingli...

  • Page 488

    488 chapter 2: actionscript language reference mouse.Show() availability flash player 5. Usage mouse.Show() : number parameters none. Returns an integer; either 0 or 1 . If the mouse pointer was hidden before the call to mouse.Show(), then the return value is 0 . If the mouse pointer was visible bef...

  • Page 489: Chapter 2

    Movieclip class 489 movieclip class availability flash player 3. Description the methods for the movieclip class provide the same functionality as actions that target movie clips. There are also additional methods that do not have equivalent actions in the actions toolbox in the actions panel. You d...

  • Page 490

    490 chapter 2: actionscript language reference drawing method summary for the movieclip class movieclip.Globaltolocal() converts stage coordinates to the local coordinates of the specified movie clip. Movieclip.Gotoandplay() sends the playhead to a specific frame in the movie clip and plays the movi...

  • Page 491

    Movieclip class 491 property summary for the movieclip class movieclip.Linestyle() defines the stroke of lines created with the movieclip.Lineto() and movieclip.Curveto() methods. Movieclip.Lineto() draws a line using the current line style. Movieclip.Moveto() moves the current drawing position to s...

  • Page 492

    492 chapter 2: actionscript language reference event handler summary for the movieclip class movieclip._target read-only; the target path of a movie clip instance. Movieclip._totalframes read-only; the total number of frames in a movie clip instance. Movieclip.Trackasmenu a boolean value that indica...

  • Page 493

    Movieclip class 493 movieclip.Onload invoked when the movie clip is instantiated and appears in the timeline. Movieclip.Onmousedown invoked when the left mouse button is pressed. Movieclip.Onmousemove invoked every time the mouse is moved. Movieclip.Onmouseup invoked when the left mouse button is re...

  • Page 494

    494 chapter 2: actionscript language reference movieclip._alpha availability flash player 4. Usage my_mc._alpha:number description property; the alpha transparency value of the movie clip specified by my_mc . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Obj...

  • Page 495

    Movieclip.Attachaudio() 495 movieclip.Attachaudio() availability flash player 6; the ability to attach audio from flash video (flv) files was added in flash player 7. Usage my_mc.Attachaudio(source:object) : void parameters source the object containing the audio to play. Valid values are a microphon...

  • Page 496

    496 chapter 2: actionscript language reference // updates the volume this.Createtextfield("volume_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); updatevolume(); function updatevolume() { volume_txt.Text = "volume: "+audio_sound.Getvolume(); } the following example specifies a microphone as the au...

  • Page 497

    Movieclip.Attachmovie() 497 movieclip.Attachmovie() availability flash player 5. Usage my_mc.Attachmovie(idname:string, newname:string, depth:number [, initobject:object]) : movieclip parameters idname the linkage name of the movie clip symbol in the library to attach to a movie clip on the stage. T...

  • Page 498

    498 chapter 2: actionscript language reference movieclip.Beginfill() availability flash player 6. Usage my_mc.Beginfill([rgb:number[, alpha:number]]) : void parameter rgb a hex color value (for example, red is 0xff0000, blue is 0x0000ff, and so on). If this value is not provided or is undefined, a f...

  • Page 499

    Movieclip.Begingradientfill() 499 movieclip.Begingradientfill() availability flash player 6. Usage my_mc.Begingradientfill(filltype:string, colors:array, alphas:array, ratios:array, matrix:object) : void parameter filltype either the string "linear" or the string "radial" . Colors an array of rgb he...

  • Page 500

    500 chapter 2: actionscript language reference if a matrixtype property does not exist then the remaining parameters are all required; the function fails if any of them are missing. This matrix scales, translates, rotates, and skews the unit gradient, which is defined at (-1,-1) and (1,1). • matrixt...

  • Page 501

    Movieclip.Begingradientfill() 501 returns nothing. Description method; indicates the beginning of a new drawing path. If the first parameter is undefined, or if no parameters are passed, the path has no fill. If an open path exists (that is if the current drawing position does not equal the previous...

  • Page 502

    502 chapter 2: actionscript language reference endfill(); } see also movieclip.Beginfill() , movieclip.Endfill() , movieclip.Linestyle() , movieclip.Lineto() , movieclip.Moveto().

  • Page 503

    Movieclip.Clear() 503 movieclip.Clear() availability flash player 6. Usage my_mc.Clear() : void parameters none. Returns nothing. Description method; removes all the graphics created during runtime using the movie clip draw methods, including line styles specified with movieclip.Linestyle() . Shapes...

  • Page 504

    504 chapter 2: actionscript language reference movieclip.Createemptymovieclip() availability flash player 6. Usage my_mc.Createemptymovieclip(instancename:string, depth:number) : movieclip parameters instancename a string that identifies the instance name of the new movie clip. Depth an integer that...

  • Page 505

    Movieclip.Createtextfield() 505 movieclip.Createtextfield() availability flash player 6. Usage my_mc.Createtextfield(instancename:string, depth:number, x:number, y:number, width:number, height:number) : void parameters instancename a string that identifies the instance name of the new text field. De...

  • Page 506

    506 chapter 2: actionscript language reference variable = null maxchars = null stylesheet = undefined tabinded = undefined a text field created with createtextfield() receives the following default textformat object: font = "times new roman" size = 12 color = 0x000000 bold = false italic = false und...

  • Page 507

    Movieclip._currentframe 507 movieclip._currentframe availability flash player 4. Usage my_mc._currentframe:number description read-only property; returns the number of the frame in which the playhead is located in the timeline specified by my_mc . Example the following example uses the _currentframe...

  • Page 508

    508 chapter 2: actionscript language reference movieclip.Curveto() availability flash player 6. Usage my_mc.Curveto(controlx:number, controly:number, anchorx:number, anchory:number) : void parameters controlx an integer that specifies the horizontal position of the control point relative to the regi...

  • Page 509

    Movieclip.Curveto() 509 the curve drawn in this example is a quadratic bezier curve. Quadratic bezier curves consist of two anchor points and a control point. The curve interpolates the two anchor points, and curves toward the control point. The following actionscript creates a circle using moviecli...

  • Page 510

    510 chapter 2: actionscript language reference movieclip._droptarget availability flash player 4. Usage my_mc._droptarget:string description read-only property; returns the absolute path in slash syntax notation of the movie clip instance on which my_mc was dropped. The _droptarget property always r...

  • Page 511

    Movieclip.Duplicatemovieclip() 511 movieclip.Duplicatemovieclip() availability flash player 5. Usage my_mc.Duplicatemovieclip(newname:string, depth:number [,initobject:object]) : movieclip parameters newname a unique identifier for the duplicate movie clip. Depth a unique number specifying the depth...

  • Page 512

    512 chapter 2: actionscript language reference movieclip.Enabled availability flash player 6. Usage my_mc.Enabled:boolean description property; a boolean value that indicates whether a movie clip is enabled. The default value of enabled is true . If enabled is set to false , the movie clip’s callbac...

  • Page 513

    Movieclip.Endfill() 513 movieclip.Endfill() availability flash player 6. Usage my_mc.Endfill() : void parameters none. Returns nothing. Description method; applies a fill to the lines and curves added since the last call to beginfill() or begingradientfill() . Flash uses the fill that was specified ...

  • Page 514

    514 chapter 2: actionscript language reference movieclip.Focusenabled availability flash player 6. Usage my_mc.Focusenabled:boolean description property; if the value is undefined or false , a movie clip cannot receive input focus unless it is a button. If the focusenabled property value is true , a...

  • Page 515

    Movieclip._focusrect 515 movieclip._focusrect availability flash player 6. Usage my_mc._focusrect:boolean description property; a boolean value that specifies whether a movie clip has a yellow rectangle around it when it has keyboard focus. This property can override the global _focusrect property. ...

  • Page 516

    516 chapter 2: actionscript language reference movieclip._framesloaded availability flash player 4. Usage my_mc._framesloaded:number description read-only property; the number of frames that have been loaded from a streaming swf file. This property is useful for determining whether the contents of a...

  • Page 517

    Movieclip.Getbounds() 517 movieclip.Getbounds() availability flash player 5. Usage my_mc.Getbounds(targetcoordinatespace:object) : object parameters targetcoordinatespace the target path of the timeline whose coordinate system you want to use as a reference point. Returns an object with the properti...

  • Page 518

    518 chapter 2: actionscript language reference see also movieclip.Globaltolocal() , movieclip.Localtoglobal().

  • Page 519

    Movieclip.Getbytesloaded() 519 movieclip.Getbytesloaded() availability flash player 5. Usage my_mc.Getbytesloaded() : number parameters none. Returns an integer indicating the number of bytes loaded. Description method; returns the number of bytes that have already loaded (streamed) for the movie cl...

  • Page 520

    520 chapter 2: actionscript language reference movieclip.Getbytestotal() availability flash player 5. Usage my_mc.Getbytestotal() : number parameters none. Returns an integer indicating the total size, in bytes, of my_mc . Description method; returns the size, in bytes, of the movie clip specified b...

  • Page 521

    Movieclip.Getdepth() 521 movieclip.Getdepth() availability flash player 6. Usage my_mc.Getdepth() : number parameters none. Returns an integer. Description method; returns the depth of a movie clip instance. For more information, see “managing movie clip depths” in using actionscript in flash. You c...

  • Page 522

    522 chapter 2: actionscript language reference movieclip.Getinstanceatdepth() availability flash player 7. Usage my_mc.Getinstanceatdepth(depth:number) : movieclip parameters depth an integer that specifies the depth level to query. Returns a reference to the movieclip instance located at the specif...

  • Page 523

    Movieclip.Getnexthighestdepth() 523 movieclip.Getnexthighestdepth() availability flash player 7. Usage my_mc.Getnexthighestdepth() : number parameters none. Returns an integer that reflects the next available depth index that would render above all other objects on the same level and layer within my...

  • Page 524

    524 chapter 2: actionscript language reference movieclip.Getswfversion() availability flash player 7. Usage my_mc.Getswfversion() : number parameters none. Returns an integer that specifies the flash player version that was targeted when the swf file loaded into my_mc was published. Description meth...

  • Page 525

    Movieclip.Gettextsnapshot() 525 movieclip.Gettextsnapshot() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_mc.Gettextsnapshot() : textsnapshot parameters none. Returns a textsnapshot object that contains ...

  • Page 526

    526 chapter 2: actionscript language reference for (var i in textsnap) { text_mc.Textsnapshot_txt.Htmltext += ""+i+"\t"+textsnap[i]; } text_mc.Textsnapshot_txt.Htmltext += ""; the following text appears in text_mc.Textsnapshot_txt : gettextruninfo[type function] setselectcolor[type function] findtex...

  • Page 527

    Movieclip.Geturl() 527 movieclip.Geturl() availability flash player 5. Usage my_mc.Geturl(url:string [,window:string, variables:string]) : void parameters url string; the url from which to obtain the document. Window string; an optional parameter specifying the name, frame, or expression that specif...

  • Page 528

    528 chapter 2: actionscript language reference movieclip.Globaltolocal() availability flash player 5. Usage my_mc.Globaltolocal(point:object) : void parameters point the name or identifier of an object created with the generic object class . The object specifies the x and y coordinates as properties...

  • Page 529

    Movieclip.Globaltolocal() 529 see also movieclip.Getbounds() , movieclip.Localtoglobal().

  • Page 530

    530 chapter 2: actionscript language reference movieclip.Gotoandplay() availability flash player 5. Usage my_mc.Gotoandplay(frame:object) : void parameters frame a number representing the frame number, or a string representing the label of the frame, to which the playhead is sent. Returns nothing. D...

  • Page 531

    Movieclip.Gotoandstop() 531 movieclip.Gotoandstop() availability flash player 5. Usage my_mc.Gotoandstop(frame:object) : void parameters frame the frame number to which the playhead is sent. Returns nothing. Description method; brings the playhead to the specified frame of the movie clip and stops i...

  • Page 532

    532 chapter 2: actionscript language reference movieclip._height availability flash player 4. Usage my_mc._height:number description property; the height of the movie clip, in pixels. Example the following code example displays the height and width of a movie clip in the output panel: this.Createemp...

  • Page 533

    Movieclip.Hitarea 533 movieclip.Hitarea availability flash player 6. Usage my_mc.Hitarea:object returns a reference to a movie clip. Description property; 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 mov...

  • Page 534

    534 chapter 2: actionscript language reference movieclip.Hittest() availability flash player 5. Usage my_mc.Hittest(x:number, y:number, shapeflag:boolean) : boolean my_mc.Hittest(target:object) : boolean parameters x the x coordinate of the hit area on the stage. Y the y coordinate of the hit area o...

  • Page 535

    Movieclip.Hittest() 535 see also movieclip.Getbounds() , movieclip.Globaltolocal() , movieclip.Localtoglobal().

  • Page 536

    536 chapter 2: actionscript language reference movieclip.Linestyle() availability flash player 6. Usage my_mc.Linestyle([thickness:number[, rgb:number[, alpha:number]]]) : void parameters thickness an integer that indicates the thickness of the line in points; valid values are 0 to 255. If a number ...

  • Page 537

    Movieclip.Lineto() 537 movieclip.Lineto() availability flash player 6. Usage my_mc.Lineto(x:number, y:number) : void parameters x an integer indicating the horizontal position relative to the registration point of the parent movie clip. Y an integer indicating the vertical position relative to the r...

  • Page 538

    538 chapter 2: actionscript language reference movieclip.Loadmovie() availability flash player 5. Usage my_mc.Loadmovie(url:string [,variables:string]) : void parameters url the absolute or relative url of the swf file or jpeg file to be loaded. A relative path must be relative to the swf file at le...

  • Page 539

    Movieclip.Loadmovie() 539 using event handlers with movieclip.Loadmovie() can be unpredictable. If you attach an event handler to a button using on() or if you create a dynamic handler using an event handler method such as movieclip.Onpress , and then you call loadmovie() , the event handler does no...

  • Page 540

    540 chapter 2: actionscript language reference movieclip.Loadvariables() availability flash player 5; behavior changed in flash player 7. Usage my_mc.Loadvariables(url:string [, variables:string]) : void parameters url the absolute or relative url for the external file that contains the variables to...

  • Page 541

    Movieclip.Loadvariables() 541 you can extend the methods and event handlers of the movieclip class by creating a subclass. For more information, see “assigning a class to a movie clip symbol” in using actionscript in flash. Example the following example loads information from a text file called para...

  • Page 542

    542 chapter 2: actionscript language reference movieclip.Localtoglobal() availability flash player 5. Usage my_mc.Localtoglobal(point:object) : void parameters point the name or identifier of an object created with the object class , specifying the x and y coordinates as properties. Returns nothing....

  • Page 543

    Movieclip._lockroot 543 movieclip._lockroot availability flash player 7. Usage my_mc._lockroot:boolean description property; specifies what _root refers to when a swf file is loaded into a movie clip. The _lockroot property is undefined by default. You can set this property within the swf file that ...

  • Page 544

    544 chapter 2: actionscript language reference _lockroot -> true $version -> win 7,0,19,0 the following example loads two swf files, lockroot.Swf and nolockroot.Swf. The lockroot.Fla document contains the previous actionscript. The nolockroot fla file has the following code placed on frame 1 of the ...

  • Page 545

    Movieclip._lockroot 545 nolockroot_mc._lockroot = true; nolockroot_mc.Loadmovie("nolockroot.Swf"); which would then trace 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 nolockroo...

  • Page 546

    546 chapter 2: actionscript language reference movieclip.Menu availability flash player 7. Usage my_mc.Menu:contextmenu = contextmenu parameters contextmenu a contextmenu object. Description property; associates the specified contextmenu object with the movie clip my_mc . The contextmenu class lets ...

  • Page 547

    Movieclip.Moveto() 547 movieclip.Moveto() availability flash player 6. Usage my_mc.Moveto(x:number, y:number) : void parameters x an integer indicating the horizontal position relative to the registration point of the parent movie clip. Y an integer indicating the vertical position relative to the r...

  • Page 548

    548 chapter 2: actionscript language reference movieclip._name availability flash player 4. Usage my_mc . _name:string description property; the instance name of the movie clip specified by my_mc . Example the following example lets you right-click or control-click a movie clip on the stage and sele...

  • Page 549

    Movieclip.Nextframe() 549 movieclip.Nextframe() availability flash player 5. Usage my_mc.Nextframe() : void parameters none. Returns nothing. Description method; sends the playhead to the next frame and stops it. You can extend the methods and event handlers of the movieclip class by creating a subc...

  • Page 550

    550 chapter 2: actionscript language reference movieclip.Ondata availability flash player 6. Usage my_mc.Ondata = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a movie clip receives data from a movieclip.Loadvariables() or movieclip....

  • Page 551

    Movieclip.Ondata 551 // therefore, this function is invoked when symbol_mc is instantiated // and also when replacement.Swf is loaded. Onclipevent( data ) { trace("the movie clip has received data"); } see also onclipevent().

  • Page 552

    552 chapter 2: actionscript language reference movieclip.Ondragout availability flash player 6. Usage my_mc.Ondragout = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is pressed and the pointer rolls outside the objec...

  • Page 553

    Movieclip.Ondragover 553 movieclip.Ondragover availability flash player 6. Usage my_mc.Ondragover = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer is dragged outside and then over the movie clip. You must define a function...

  • Page 554

    554 chapter 2: actionscript language reference movieclip.Onenterframe availability flash player 6. Usage my_mc.Onenterframe = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked repeatedly at the frame rate of the swf file. The actions associat...

  • Page 555

    Movieclip.Onkeydown 555 movieclip.Onkeydown availability flash player 6. Usage my_mc.Onkeydown = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a movie clip has input focus and a key is pressed. The onkeydown event handler is invoked ...

  • Page 556

    556 chapter 2: actionscript language reference when you tab to the movie clip and press a key, key was pressed displays in the output panel. However, this does not occur after you move the mouse, because the movie clip loses focus. Therefore, you should use key.Onkeydown in most cases. See also movi...

  • Page 557

    Movieclip.Onkeyup 557 movieclip.Onkeyup availability flash player 6. Usage my_mc.Onkeyup = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a key is released. The onkeyup event handler is invoked with no parameters. You can use the key....

  • Page 558

    558 chapter 2: actionscript language reference movieclip.Onkillfocus availability flash player 6. Usage my_mc.Onkillfocus = function (newfocus:object) { // your statements here } parameters newfocus the object that is receiving the keyboard focus. Returns nothing. Description event handler; invoked ...

  • Page 559

    Movieclip.Onload 559 movieclip.Onload availability flash player 6. Usage my_mc.Onload = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the movie clip is instantiated and appears in the timeline. You must define a function that execute...

  • Page 560

    560 chapter 2: actionscript language reference the following example displays the equivalent of the previous actionscript example: this.Createemptymovieclip("tester_mc", 1); var mcllistener:object = new object(); mcllistener.Onloadinit = function(target_mc:movieclip) { trace("movie loaded"); }; var ...

  • Page 561

    Movieclip.Onmousedown 561 movieclip.Onmousedown availability flash player 6. Usage my_mc.Onmousedown = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is pressed. You must define a function that executes when the event...

  • Page 562

    562 chapter 2: actionscript language reference movieclip.Onmousemove availability flash player 6. Usage my_mc.Onmousemove = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse moves. You must define a function that executes when ...

  • Page 563

    Movieclip.Onmouseup 563 movieclip.Onmouseup availability flash player 6. Usage my_mc.Onmouseup = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is released. You must define a function that executes when the event hand...

  • Page 564

    564 chapter 2: actionscript language reference movieclip.Onpress availability flash player 6. Usage my_mc.Onpress = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the user clicks the mouse while the pointer is over a movie clip. You m...

  • Page 565

    Movieclip.Onrelease 565 movieclip.Onrelease availability flash player 6. Usage my_mc.Onrelease = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked the mouse button is released over a movie clip. You must define a function that executes when t...

  • Page 566

    566 chapter 2: actionscript language reference movieclip.Onreleaseoutside availability flash player 6. Usage my_mc.Onreleaseoutside = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked after the mouse button has been pressed inside the movie c...

  • Page 567

    Movieclip.Onrollout 567 movieclip.Onrollout availability flash player 6. Usage my_mc.Onrollout = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer moves outside a movie clip area. You must define a function that executes when...

  • Page 568

    568 chapter 2: actionscript language reference movieclip.Onrollover availability flash player 6. Usage my_mc.Onrollover = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer moves over a movie clip area. You must define a funct...

  • Page 569

    Movieclip.Onsetfocus 569 movieclip.Onsetfocus availability flash player 6. Usage my_mc.Onsetfocus = function(oldfocus){ // your statements here } parameters oldfocus the object to lose focus. Returns nothing. Description event handler; invoked when a movie clip receives keyboard focus. The oldfocus ...

  • Page 570

    570 chapter 2: actionscript language reference movieclip.Onunload availability flash player 6. Usage my_mc.Onunload = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked in the first frame after the movie clip is removed from the timeline. Flas...

  • Page 571

    Movieclip._parent 571 movieclip._parent availability flash player 5. Usage my_mc._parent.Property _parent.Property description property; a reference to the movie clip or object that contains the current movie clip or object. The current object is the object containing the actionscript code that refe...

  • Page 572

    572 chapter 2: actionscript language reference movieclip.Play() availability flash player 5. Usage my_mc.Play() : void parameters none. Returns nothing. Description method; moves the playhead in the timeline of the movie clip. You can extend the methods and event handlers of the movieclip class by c...

  • Page 573

    Movieclip.Prevframe() 573 movieclip.Prevframe() availability flash player 5. Usage my_mc.Prevframe() : void parameters none. Returns nothing. Description method; sends the playhead to the previous frame and stops it. You can extend the methods and event handlers of the movieclip class by creating a ...

  • Page 574

    574 chapter 2: actionscript language reference movieclip._quality availability flash player 6. Usage my_mc._quality:string description 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...

  • Page 575

    Movieclip.Removemovieclip() 575 movieclip.Removemovieclip() availability flash player 5. Usage my_mc.Removemovieclip() : void parameters none. Returns nothing. Description method; removes a movie clip instance created with duplicatemovieclip() , movieclip.Duplicatemovieclip() , or movieclip.Attachmo...

  • Page 576

    576 chapter 2: actionscript language reference movieclip._rotation availability flash player 4. Usage my_mc._rotation:number description property; the rotation of the movie clip, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 repre...

  • Page 577

    Movieclip.Setmask() 577 movieclip.Setmask() availability flash player 6. Usage my_mc.Setmask(mask_mc:object) : void parameters my_mc the instance name of a movie clip to be masked. Mask_mc the instance name of a movie clip to be a mask. Returns nothing. Description method; makes the movie clip in th...

  • Page 578

    578 chapter 2: actionscript language reference movieclip._soundbuftime availability flash player 6. Usage my_mc._soundbuftime:number description property (global); an integer that specifies the number of seconds a sound prebuffers before it starts to stream. Note: although you can specify this prope...

  • Page 579

    Movieclip.Startdrag() 579 movieclip.Startdrag() availability flash player 5. Usage my_mc.Startdrag([lock:boolean, [left:number, top:number, right:number, bottom:number]]) : void parameters lock a boolean value specifying whether the draggable movie clip is locked to the center of the mouse position ...

  • Page 580

    580 chapter 2: actionscript language reference movieclip.Stop() availability flash player 5. Usage my_mc.Stop() : void parameters none. Returns nothing. Description method; stops the movie clip currently playing. You can extend the methods and event handlers of the movieclip class by creating a subc...

  • Page 581

    Movieclip.Stopdrag() 581 movieclip.Stopdrag() availability flash player 5. Usage my_mc.Stopdrag() : void parameters none. Returns nothing. Description method; ends a movieclip.Startdrag() method. A movie clip that was made draggable with that method remains draggable until a stopdrag() method is add...

  • Page 582

    582 chapter 2: actionscript language reference movieclip.Swapdepths() availability flash player 5. Usage my_mc.Swapdepths(depth:number) my_mc.Swapdepths(target:string) parameters depth a number specifying the depth level where my_mc is to be placed. Target a string specifying the movie clip instance...

  • Page 583

    Movieclip.Tabchildren 583 movieclip.Tabchildren availability flash player 6. Usage my_mc.Tabchildren:boolean description property; undefined by default. If tabchildren is undefined or true , the children of a movie clip are included in automatic tab ordering. If the value of tabchildren is false , t...

  • Page 584

    584 chapter 2: actionscript language reference movieclip.Tabenabled availability flash player 6. Usage my_mc.Tabenabled:boolean description property; specifies whether my_mc is included in automatic tab ordering. It is undefined by default. If tabenabled is undefined , the object is included in auto...

  • Page 585

    Movieclip.Tabindex 585 movieclip.Tabindex availability flash player 6. Usage my_mc.Tabindex:number description property; lets you customize the tab ordering of objects in a movie. The tabindex property is undefined by default. You can set tabindex on a button, movie clip, or text field instance. If ...

  • Page 586

    586 chapter 2: actionscript language reference movieclip._target availability flash player 4. Usage my_mc._target:string description read-only property; returns the target path of the movie clip instance specified by my_mc in slash notation. Use the eval() function to convert the target path to dot ...

  • Page 587

    Movieclip._totalframes 587 movieclip._totalframes availability flash player 4. Usage my_mc._totalframes:number description read-only property; returns the total number of frames in the movie clip instance specified in the movieclip parameter. Example in the following example, two movie clip buttons ...

  • Page 588

    588 chapter 2: actionscript language reference movieclip.Trackasmenu availability flash player 6. Usage my_mc.Trackasmenu:boolean description property; a boolean value that indicates whether or not other buttons or movie clips can receive mouse release events. This allows you to create menus. You ca...

  • Page 589

    Movieclip.Unloadmovie() 589 movieclip.Unloadmovie() availability flash player 5. Usage my_mc.Unloadmovie() : void parameters none. Returns nothing. Description method; removes the contents of a movie clip instance. The instance properties and clip handlers remain. To remove the instance, including i...

  • Page 590

    590 chapter 2: actionscript language reference movieclip._url availability flash player 4. Usage my_mc . _url:string description read-only property; retrieves the url of the swf or jpeg file from which the movie clip was downloaded. Example the following example displays the url of the image that is...

  • Page 591

    Movieclip.Usehandcursor 591 movieclip.Usehandcursor availability flash player 6. Usage my_mc.Usehandcursor:boolean description property; a boolean value that indicates whether the hand cursor (pointing hand) appears when the mouse rolls over a movie clip. The default value of usehandcursor is true ....

  • Page 592

    592 chapter 2: actionscript language reference movieclip._visible availability flash player 4. Usage my_mc._visible:boolean description property; a boolean value that indicates whether the movie clip specified by my_mc is visible. Movie clips that are not visible ( _visible property set to false ) a...

  • Page 593

    Movieclip._width 593 movieclip._width availability flash player 4 as a read-only property. Usage my_mc._width:number description property; the width of the movie clip, in pixels. Example the following code example displays the height and width of a movie clip in the output panel: this.Createemptymov...

  • Page 594

    594 chapter 2: actionscript language reference movieclip._x availability flash player 3. Usage my_mc._x:number description property; an integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip. If a movie clip is in the main timeline, then its coo...

  • Page 595

    Movieclip._xmouse 595 movieclip._xmouse availability flash player 5. Usage my_mc._xmouse:number description read-only property; returns the x coordinate of the mouse position. Example the following example returns the current x and y coordinates of the mouse on the stage ( _level0 ) and in relation ...

  • Page 596

    596 chapter 2: actionscript language reference movieclip._xscale availability flash player 4. Usage my_mc._xscale:number description property; determines the horizontal scale ( percentage ) of the movie clip as applied from the registration point of the movie clip. The default registration point is ...

  • Page 597

    Movieclip._y 597 movieclip._y availability flash player 3. Usage my_mc._y:number description property; 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, then its coordinate system refers to the upper left corner...

  • Page 598

    598 chapter 2: actionscript language reference movieclip._ymouse availability flash player 5. Usage my_mc._ymouse:number description read-only property; indicates the y coordinate of the mouse position. Example the following example returns the current x and y coordinates of the mouse on the stage (...

  • Page 599

    Movieclip._yscale 599 movieclip._yscale availability flash player 4. Usage my_mc._yscale:number description property; 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 local coordina...

  • Page 600: Chapter 2

    600 chapter 2: actionscript language reference moviecliploader class availability flash player 7. Description this class lets you implement listener callbacks that provide status information while swf or jpeg files are being loaded (downloaded) into movie clips. To use moviecliploader features, use ...

  • Page 601

    Moviecliploader class 601 listener summary for the moviecliploader class constructor for the moviecliploader class availability flash player 7. Usage new moviecliploader() : moviecliploader parameters none. Returns a reference to a moviecliploader object. Description constructor; creates a movieclip...

  • Page 602

    602 chapter 2: actionscript language reference moviecliploader.Addlistener() availability flash player 7. Usage my_mcl.Addlistener(listenerobject:object) : void parameters listenerobject an object that listens for a callback notification from the moviecliploader event handlers. Returns nothing. Desc...

  • Page 603

    Moviecliploader.Getprogress() 603 moviecliploader.Getprogress() availability flash player 7. Usage my_mcl.Getprogress(target_mc:object) : object parameters target_mc a swf or jpeg file that is loaded using moviecliploader.Loadclip() . Returns an object that has two integer properties: bytesloaded an...

  • Page 604

    604 chapter 2: actionscript language reference moviecliploader.Loadclip() availability flash player 7. Usage my_mcl.Loadclip(url:string, target:object ) : boolean parameters url the absolute or relative url of the swf file or jpeg file to be loaded. A relative path must be relative to the swf file a...

  • Page 605

    Moviecliploader.Loadclip() 605 moviecliploader.Getprogress() and moviecliploaderlistener.Onloadprogress do not report the actual bytesloaded and bytestotal values in the authoring player when the files are local. When you use the bandwidth profiler feature in the authoring environment, movieclipload...

  • Page 606

    606 chapter 2: actionscript language reference my_mcl.Loadclip("http://www.Macromedia.Com/software/drk/images/box_drk5.Jpg", clip1_mc); my_mcl.Loadclip("http://www.Macromedia.Com/devnet/images/160x160/ ben_forta.Jpg", clip2_mc); clip2_mc._x = 200; // loads into _level1 my_mcl.Loadclip("http://www.Ma...

  • Page 607

    Moviecliploader.Onloadcomplete 607 moviecliploader.Onloadcomplete availability flash player 7. Usage listenerobject.Onloadcomplete = function([target_mc:object]) { // your statements here } parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Target_mc a m...

  • Page 608

    608 chapter 2: actionscript language reference 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 moviecliploader(); image_mcl.Addlistener(...

  • Page 609

    Moviecliploader.Onloaderror 609 moviecliploader.Onloaderror availability flash player 7. Usage listenerobject.Onloaderror = function(target_mc:object, errorcode:string) { // your statements here } parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Target...

  • Page 610

    610 chapter 2: actionscript language reference } }; mcllistener.Onloadinit = function(target_mc:movieclip) { trace("success"); trace(image_mcl.Getprogress(target_mc).Bytestotal+" bytes loaded"); }; var image_mcl:moviecliploader = new moviecliploader(); image_mcl.Addlistener(mcllistener); image_mcl.L...

  • Page 611

    Moviecliploader.Onloadinit 611 moviecliploader.Onloadinit availability flash player 7. Usage listenerobject.Onloadinit = function([target_mc:movieclip]) { // your statements here } parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Target_mc a movie clip...

  • Page 612

    612 chapter 2: actionscript language reference see also moviecliploader.Onloadstart.

  • Page 613

    Moviecliploader.Onloadprogress 613 moviecliploader.Onloadprogress availability flash player 7. Usage listenerobject.Onloadprogress = function([target_mc:object [, loadedbytes:number [, totalbytes:number ] ] ] ) { // your statements here } parameters listenerobject a listener object that was added us...

  • Page 614

    614 chapter 2: actionscript language reference lineto(100, 10); lineto(0, 10); lineto(0, 0); } with (progressbar_mc.Bar_mc) { beginfill(0xff0000, 100); moveto(0, 0); lineto(100, 0); lineto(100, 10); lineto(0, 10); lineto(0, 0); endfill(); _xscale = 0; } progressbar_mc._x = 2; progressbar_mc._y = 2; ...

  • Page 615

    Moviecliploader.Onloadstart 615 moviecliploader.Onloadstart availability flash player 7. Usage listenerobject.Onloadstart = function([target_mc:object]) { // your statements here } parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Target_mc a movie clip...

  • Page 616

    616 chapter 2: actionscript language reference see also moviecliploader.Onloaderror , moviecliploader.Onloadinit , moviecliploader.Onloadcomplete.

  • Page 617

    Moviecliploader.Removelistener() 617 moviecliploader.Removelistener() availability flash player 7. Usage my_mcl.Removelistener(listenerobject:object) : void parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Returns nothing. Description method; removes t...

  • Page 618

    618 chapter 2: actionscript language reference start_button.Enabled = true; stop_button.Enabled = false; // image_mcl.Removelistener(mcllistener); }; stop_button.Enabled = false;.

  • Page 619

    Moviecliploader.Unloadclip() 619 moviecliploader.Unloadclip() availability flash player 7. Usage my_mcl.Unloadclip(target:object) parameters target the string or integer passed to the corresponding call to my_mcl.Loadclip() . Returns nothing. Description method; removes a movie clip that was loaded ...

  • Page 620: Chapter 2

    620 chapter 2: actionscript language reference nan availability flash player 5. Usage nan description variable; a predefined variable with the ieee-754 value for nan (not a number). To determine if a number is nan , use isnan() . See also isnan() , number.Nan chapter 2 actionscript language referenc...

  • Page 621: Chapter 2

    -infinity 621 -infinity availability flash player 5. Usage -infinity description constant; specifies the ieee-754 value representing negative infinity. The value of this constant is the same as number.Negative_infinity . Chapter 2 actionscript language reference.

  • Page 622: Chapter 2

    622 chapter 2: actionscript language reference netconnection class availability flash player 7. Note: this class is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Description the netconnection class ...

  • Page 623

    Netconnection class 623 see also netstream class , video.Attachvideo().

  • Page 624

    624 chapter 2: actionscript language reference netconnection.Connect() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_nc.Connect(null) : voi...

  • Page 625: Chapter 2

    Netstream class 625 netstream class availability flash player 7. Note: this class is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Description the netstream class provides methods and properties for...

  • Page 626

    626 chapter 2: actionscript language reference event handler summary for the netstream class constructor for the netstream class availability flash player 7. Note: this class is also supported in flash player 6 when used with flash communication server. For more information, see the flash communicat...

  • Page 627

    Netstream.Bufferlength 627 netstream.Bufferlength availability flash player 7. Note: this property is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Bufferlength:number description read-o...

  • Page 628

    628 chapter 2: actionscript language reference netstream.Buffertime availability flash player 7. Note: this property is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Buffertime:number de...

  • Page 629

    Netstream.Bytesloaded 629 netstream.Bytesloaded availability flash player 7. Usage my_ns.Bytesloaded:number description read-only property; the number of bytes of data that have been loaded into the player. You can use this method in conjunction with netstream.Bytestotal to estimate how close the bu...

  • Page 630

    630 chapter 2: actionscript language reference var loaded_interval:number = setinterval(checkbytesloaded, 500, stream_ns); function checkbytesloaded(my_ns:netstream) { var pctloaded:number = math.Round(my_ns.Bytesloaded/my_ns.Bytestotal*100); loaded_txt.Text = math.Round(my_ns.Bytesloaded/1000)+" of...

  • Page 631

    Netstream.Bytestotal 631 netstream.Bytestotal availability flash player 7. Usage my_ns.Bytestotal:number description read-only property; the total size in bytes of the file being loaded into the player. Example the following example creates a progress bar using the drawing api and the bytesloaded an...

  • Page 632

    632 chapter 2: actionscript language reference loaded_txt.Text = math.Round(my_ns.Bytesloaded/1000)+" of "+math.Round(my_ns.Bytestotal/1000)+" kb loaded ("+pctloaded+"%)"; progressbar_mc.Bar_mc._xscale = pctloaded; if (pctloaded>=100) { clearinterval(loaded_interval); } } see also netstream.Bytesloa...

  • Page 633

    Netstream.Close() 633 netstream.Close() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Close() : void parameters none. Returns nothing. D...

  • Page 634

    634 chapter 2: actionscript language reference netstream.Currentfps availability flash player 7. Note: this property is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Currentfps:number de...

  • Page 635

    Netstream.Onstatus 635 netstream.Onstatus availability flash player 7. Note: this handler is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Onstatus = function(infoobject:object) : void{ ...

  • Page 636

    636 chapter 2: actionscript language reference example the following example displays data about the stream in the output panel: var connection_nc:netconnection = new netconnection(); connection_nc.Connect(null); var stream_ns:netstream = new netstream(connection_nc); my_video.Attachvideo(stream_ns)...

  • Page 637

    Netstream.Pause() 637 netstream.Pause() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Pause( [ pauseresume:boolean ] ) : void parameters...

  • Page 638

    638 chapter 2: actionscript language reference netstream.Play() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Play("filename":string); p...

  • Page 639

    Netstream.Play() 639 see also movieclip.Attachaudio() , netstream.Close() , netstream.Pause() , video.Attachvideo().

  • Page 640

    640 chapter 2: actionscript language reference netstream.Seek() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Seek(numberofseconds:numbe...

  • Page 641

    Netstream.Setbuffertime() 641 netstream.Setbuffertime() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Setbuffertime(numberofseconds:numb...

  • Page 642

    642 chapter 2: actionscript language reference netstream.Time availability flash player 7. Note: this property is also supported in flash player 6 when used with flash communication server. For more information, see the flash communication server documentation. Usage my_ns.Time:number description re...

  • Page 643: Chapter 2

    New 643 new availability flash player 5. Usage new constructor() parameters constructor a function followed by any optional parameters in parentheses. The function is usually the name of the object type (for example, array, number, or object) to be constructed. Returns nothing. Description operator;...

  • Page 644: Chapter 2

    644 chapter 2: actionscript language reference newline availability flash player 4. Usage newline parameters none. Returns nothing. Description constant; inserts a carriage return character ( ) that generates a blank line in text output generated by your code. Use newline to make space for inform...

  • Page 645: Chapter 2

    Nextframe() 645 nextframe() availability flash 2. Usage nextframe() : void parameters none. Returns nothing. Description function; sends the playhead to the next frame. Example in the following example, when the user presses the right or down arrow key, the playhead goes to the next frame and stops....

  • Page 646: Chapter 2

    646 chapter 2: actionscript language reference nextscene() availability flash 2. Usage nextscene() : void parameters none. Returns nothing. Description function; sends the playhead to frame 1 of the next scene. Example in the following example, when a user clicks the button that is created at runtim...

  • Page 647: Chapter 2

    Null 647 null availability flash player 5. Usage null parameters none. Returns nothing. Description constant; a special value that can be assigned to variables or returned by a function if no data was provided. You can use null to represent values that are missing or that do not have a defined data ...

  • Page 648: Chapter 2

    648 chapter 2: actionscript language reference number() availability flash player 4; behavior changed in flash player 7. Usage number(expression) : number parameters expression an expression to convert to a number. Returns a number or nan (not a number). Description function; converts the parameter ...

  • Page 649

    Number() 649 see also nan , number class.

  • Page 650: Chapter 2

    650 chapter 2: actionscript language reference number class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the number class is a simple wrapper object for the number data type. You can manipulate primitive numeric values ...

  • Page 651

    Number class 651 constructor for the number class availability flash player 5. Usage new number(value:number) : number parameters value the numeric value of the number object being created or a value to be converted to a number. The default value is 0 if value is not provided. Returns a reference to...

  • Page 652

    652 chapter 2: actionscript language reference number.Max_value availability flash player 5. Usage number.Max_value:number description property; the largest representable number (double-precision ieee-754). This number is approximately 1.79e+308. Example the following actionscript displays the large...

  • Page 653

    Number.Min_value 653 number.Min_value availability flash player 5. Usage number.Min_value description property; the smallest representable number (double-precision ieee-754). This number is approximately 5e-324. Example the following actionscript displays the largest and smallest representable numbe...

  • Page 654

    654 chapter 2: actionscript language reference number.Nan availability flash player 5. Usage number.Nan description property; the ieee-754 value representing not a number ( nan ). See also isnan() , nan.

  • Page 655

    Number.Negative_infinity 655 number.Negative_infinity availability flash player 5. Usage number.Negative_infinity description property; specifies the ieee-754 value representing negative infinity. The value of this property is the same as that of the constant -infinity . Negative infinity is a speci...

  • Page 656

    656 chapter 2: actionscript language reference number.Positive_infinity availability flash player 5. Usage number.Positive_infinity description property; specifies the ieee-754 value representing positive infinity. The value of this property is the same as that of the constant infinity . Positive in...

  • Page 657

    Number.Tostring() 657 number.Tostring() availability flash player 5; behavior changed in flash player 7. Usage mynumber.Tostring(radix:number) : string parameters radix specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If you do not specify the radix parameter, th...

  • Page 658

    658 chapter 2: actionscript language reference number.Valueof() availability flash player 5. Usage mynumber.Valueof() : number parameters none. Returns number. Description method; returns the primitive value type of the specified number object. Example the following example results in the primative ...

  • Page 659: Chapter 2

    Object() 659 object() availability flash player 5. Usage object( [ value ] ) : object parameters value a number, string, or boolean value. Returns an object. Description conversion function; creates a new empty object or converts the specified number, string, or boolean value to an object. This comm...

  • Page 660: Chapter 2

    660 chapter 2: actionscript language reference object class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the object class is at the root of the actionscript class hierarchy. This class contains a small subset of the fea...

  • Page 661

    Object class 661 returns a reference to an object object. Description constructor; creates an object object and stores a reference to the object’s constructor method in the object’s constructor property. Example the following example creates a generic object named myobject: var myobject:object = new...

  • Page 662

    662 chapter 2: actionscript language reference object.Addproperty() availability flash player 6. In actionscript 2.0 classes, you can use get or set instead of this method. Usage myobject.Addproperty(prop:string, getfunc:function, setfunc:function) : boolean parameters prop a string; the name of the...

  • Page 663

    Object.Addproperty() 663 example in the following example, an object has two internal methods, setquantity() and getquantity() . A property, bookcount , can be used to invoke these methods when it is either set or retrieved. A third internal method, gettitle() , returns a read-only value that is ass...

  • Page 664

    664 chapter 2: actionscript language reference book.Prototype.Addproperty("bookcount", book.Prototype.Getquantity, book.Prototype.Setquantity); book.Prototype.Addproperty("bookname", book.Prototype.Gettitle, null); var mybook = new book(); mybook.Bookcount = 5; trace("you ordered "+mybook.Bookcount+...

  • Page 665

    Object.Constructor 665 object.Constructor availability flash player 5 usage myobject.Constructor description property; reference to the constructor function for a given object instance. The constructor property is automatically assigned to all objects when they are created using the constructor for ...

  • Page 666

    666 chapter 2: actionscript language reference object.__proto__ availability flash player 5. Usage myobject.__proto__ description property; refers to the prototype property of the constructor function that created myobject . The __proto__ property is automatically assigned to all objects when they a...

  • Page 667

    Object.Registerclass() 667 object.Registerclass() availability flash player 6. If you are using actionscript 2.0 classes, you can use the actionscript 2.0 class field in the linkage properties or symbol properties dialog box to associate an object with a class instead of using this method. For more ...

  • Page 668

    668 chapter 2: actionscript language reference object.__resolve availability flash player 6. Usage myobject.__resolve = function (name:string) { // your statements here }; parameters name a string representing the name of the undefined property. Returns nothing description property; a reference to a...

  • Page 669

    Object.__resolve 669 var myobject:object = new object(); // define a function for __resolve to call myobject.Myfunction = function (name) { trace("method " + name + " was called"); }; // define the __resolve function myobject.__resolve = function (name) { return function () { this.Myfunction(name); ...

  • Page 670

    670 chapter 2: actionscript language reference trace("method "+name+" was called"); }; // define the __resolve function myobject.__resolve = function(name) { // reserve the name “onstatus” for local use if (name == "onstatus") { return undefined; } trace("resolve called for "+name); // to check when...

  • Page 671

    Object.__resolve 671 myobject.Someothermethod("hello","world"); // output: method someothermethod was called with arguments: hello,world.

  • Page 672

    672 chapter 2: actionscript language reference object.Tostring() availability flash player 5. Usage myobject.Tostring() : string parameters none. Returns a string. Description method; converts the specified object to a string and returns it. Example this example shows the return value for tostring()...

  • Page 673

    Object.Tostring() 673 } function tostring():string { var doors:string = "door"; if (this.Numdoors > 1) { doors += "s"; } return ("a vehicle that is " + this.Color + " and has " + this.Numdoors + " " + doors); } } // code to place into a fla file var myvehicle:vehicle = new vehicle(2, "red"); trace(m...

  • Page 674

    674 chapter 2: actionscript language reference object.Unwatch() availability flash player 6. Usage myobject.Unwatch (prop:string) : boolean parameters prop a string; the name of the object property that should no longer be watched. Returns a boolean value: true if the watchpoint is successfully remo...

  • Page 675

    Object.Valueof() 675 object.Valueof() availability flash player 5. Usage myobject.Valueof() : object parameters none. Returns the primitive value of the specified object or the object itself. Description method; returns the primitive value of the specified object. If the object does not have a primi...

  • Page 676

    676 chapter 2: actionscript language reference object.Watch() availability flash player 6. Usage myobject.Watch( prop:string, callback:function [, userdata:object] ) : boolean parameters prop a string; the name of the object property to watch. Callback the function to invoke when the watched propert...

  • Page 677

    Object.Watch() 677 the object.Watch() method behaves similarly to the object.Watch() function in javascript 1.2 and later. The primary difference is the userdata parameter, which is a flash addition to object.Watch() that netscape navigator does not support. You can pass the userdata parameter to th...

  • Page 678: Chapter 2

    678 chapter 2: actionscript language reference on() availability flash 2. Not all events are supported in flash 2. Usage on(mouseevent) { // your statements here } parameters statement(s) the instructions to execute when the mouseevent occurs. A mouseevent is a trigger called an event. When the even...

  • Page 679

    On() 679 on (release) { trace("x:"+this._x); trace("y:"+this._y); stopdrag(); } see also onclipevent().

  • Page 680: Chapter 2

    680 chapter 2: actionscript language reference onclipevent() availability flash player 5. Usage onclipevent(movieevent){ // your statements here } parameters a movieevent is a trigger called an event. When the event occurs, the statements following it within curly braces ({}) are executed. Any of th...

  • Page 681

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

  • Page 682: Chapter 2

    682 chapter 2: actionscript language reference onupdate availability flash player 6. Usage function onupdate() { ...Statements...; } parameters none. Returns nothing. Description event handler; onupdate is defined for a live preview used with a component. When an instance of a component on the stage...

  • Page 683

    Onupdate 683 buttonlabel.Textcolor = my_mc.Labelcolor; }.

  • Page 684: Chapter 2

    684 chapter 2: actionscript language reference _parent availability flash player 5. Usage _parent.Property _parent._parent.Property description identifier; specifies or returns a reference to the movie clip or object that contains the current movie clip or object. The current object is the object co...

  • Page 685: Chapter 2

    Parsefloat() 685 parsefloat() availability flash player 5. Usage parsefloat(string:string) : number parameters string the string to read and convert to a floating-point number. Returns a number or nan (not a number). Description function; converts a string to a floating-point number. The function re...

  • Page 686: Chapter 2

    686 chapter 2: actionscript language reference parseint() availability flash player 5. Usage parseint(expression:string [, radix:number]) : number parameters expression a string to convert to an integer. Radix an integer representing the radix (base) of the number to parse. Legal values are from 2 t...

  • Page 687

    Parseint() 687 the following examples show octal number parsing and return 511, which is the decimal representation of the octal 777: parseint("0777") parseint("777", 8) see also nan , parsefloat().

  • Page 688: Chapter 2

    688 chapter 2: actionscript language reference play() availability flash 2. Usage play() : void parameters none. Returns nothing. Description function; moves the playhead forward in the timeline. Example in the following example, there are two movie clip instances on the stage with the instance name...

  • Page 689: Chapter 2

    Prevframe() 689 prevframe() availability flash 2. Usage prevframe() : void parameters none. Returns nothing. Description function; sends the playhead to the previous frame. If the current frame is frame 1, the playhead does not move. Example when the user clicks a button called mybtn_btn and the fol...

  • Page 690: Chapter 2

    690 chapter 2: actionscript language reference prevscene() availability flash 2. Usage prevscene() : void parameters none. Returns nothing. Description function; sends the playhead to frame 1 of the previous scene. See also nextscene() chapter 2 actionscript language reference.

  • Page 691: Chapter 2

    Print() 691 print() availability flash player 4 (4.0.20.0) note: if you are authoring for flash player 7 or later, you can create a printjob object, which gives you (and the user) more control over the printing process. For more information, see the printjob class entry. Usage print(target:object, "...

  • Page 692

    692 chapter 2: actionscript language reference example the following example prints all the printable frames in holder_mc with a print area defined by the bounding box of each frame: this.Createemptymovieclip("holder_mc", 999); holder_mc.Loadmovie("http://www.Macromedia.Com/devnet/mx/blueprint/artic...

  • Page 693: Chapter 2

    Printasbitmap() 693 printasbitmap() availability flash player 4 (4.0.20.0) note: if you are authoring for flash player 7 or later, you can create a printjob object, which gives you (and the user) more control over the printing process. For more information, see the printjob class entry. Usage printa...

  • Page 694

    694 chapter 2: actionscript language reference the flash player printing feature supports postscript and non-postscript printers. Non- postscript printers convert vectors to bitmaps. Example the following example prints all the printable frames in holder_mc with a print area defined by the bounding ...

  • Page 695: Chapter 2

    Printasbitmapnum() 695 printasbitmapnum() availability flash player 5. Note: if you are authoring for flash player 7 or later, you can create a printjob object, which gives you (and the user) more control over the printing process. For more information, see the printjob class entry. Usage printasbit...

  • Page 696

    696 chapter 2: actionscript language reference the flash player printing feature supports postscript and non-postscript printers. Non- postscript printers convert vectors to bitmaps. Example the following example prints the contents of the stage when the user clicks the button mybtn_btn . The area t...

  • Page 697: Chapter 2

    Printjob class 697 printjob class availability flash player 7. Description the printjob class lets you create content and print it to one or more pages. This class, in addition to offering improvements to print functionality provided by the print() method, lets you render dynamic content offscreen, ...

  • Page 698

    698 chapter 2: actionscript language reference to implement a print job, use the following methods in sequence. You must place all commands relating to a specific print job in the same frame, from the constructor through printjob.Send() and delete. Replace the [params] to the my_pj.Addpage() method ...

  • Page 699

    Printjob.Addpage() 699 printjob.Addpage() availability flash player 7. Usage my_pj.Addpage(target:object [, printarea:object] [, options:object ] [, framenumber:number]) : boolean parameters target a number or string; the level or instance name of the movie clip to print. Pass a number to specify a ...

  • Page 700

    700 chapter 2: actionscript language reference • if the content that you’re printing includes a bitmap image, use {printasbitmap:true} to include any transparency and color effects. • if the content does not include bitmap images, omit this parameter or use {printasbitmap:false} to print the content...

  • Page 701

    Printjob.Addpage() 701 example the following example shows several ways to issue the addpage() command: my_btn.Onrelease = function() { var pagecount:number = 0; var my_pj:printjob = new printjob(); if (my_pj.Start()) { // print entire current frame of the _root movie in vector format if (my_pj.Addp...

  • Page 702

    702 chapter 2: actionscript language reference } } } } } // if addpage() was successful at least once, print the spooled pages. If (pagecount > 0){ my_pj.Send(); } delete my_pj; } see also printjob.Send() , printjob.Start().

  • Page 703

    Printjob.Send() 703 printjob.Send() availability flash player 7. Usage my_pj.Send() : void parameters none. Returns nothing. Description method; used following printjob.Start() and printjob.Addpage() to send spooled pages to the printer. Because calls to printjob.Send() will not be successful if rel...

  • Page 704

    704 chapter 2: actionscript language reference printjob.Start() availability flash player 7. Usage my_pj.Start() : boolean parameters none. Returns a boolean value: true if the user clicks ok when the print dialog boxes appear; false if the user clicks cancel or if an error occurs. Description metho...

  • Page 705

    Printjob.Start() 705 var myresult:boolean = my_pj.Start(); if(myresult) { // addpage() and send() statements here } delete my_pj; example the following example shows how you might use the value of the orientation property to adjust the printout: // create printjob object var my_pj:printjob = new pri...

  • Page 706: Chapter 2

    706 chapter 2: actionscript language reference printnum() availability flash player 5. Note: if you are authoring for flash player 7 or later, you can create a printjob object, which gives you (and the user) more control over the printing process. For more information, see the printjob class entry. ...

  • Page 707: Chapter 2

    Private 707 private availability flash player 6. Usage class someclassname{ private var name; private 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 708

    708 chapter 2: actionscript language reference import login: var gus:login = new login("gus", "smith"); trace(gus.Username); // output: gus trace(gus.Password); // output: undefined trace(gus.Loginpassword); // error because loginpassword is a private variable, you cannot access it from outside the ...

  • Page 709: Chapter 2

    Public 709 public flash player 6. Usage class someclassname{ public var name; public 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. This keyword is...

  • Page 710: Chapter 2

    710 chapter 2: actionscript language reference _quality availability flash player 5. Usage _quality:string description property (global); sets or retrieves the rendering quality used for a movie clip. Device fonts are always aliased and therefore are unaffected by the _quality property. The _quality...

  • Page 711: Chapter 2

    Removemovieclip() 711 removemovieclip() availability flash player 4. Usage removemovieclip(target) parameters target the target path of a movie clip instance created with duplicatemovieclip() or the instance name of a movie clip created with movieclip.Attachmovie() , movieclip.Duplicatemovieclip() ,...

  • Page 712: Chapter 2

    712 chapter 2: actionscript language reference return availability flash player 5. Usage return[expression] parameters expression a string, number, boolean, array, or object to evaluate and return as a value of the function. This parameter is optional. Returns the evaluated expression parameter, if ...

  • Page 713: Chapter 2

    _root 713 _root availability flash player 5. Usage _root.Movieclip _root.Action _root.Property parameters movieclip the instance name of a movie clip. Action an action or method. Property a property of the movieclip object. Description identifier; specifies or returns a reference to the root movie c...

  • Page 714: Chapter 2

    714 chapter 2: actionscript language reference selection class availability flash player 5. Description the selection class lets you set and control the text field in which the insertion point is located (that is, the field that has focus). Selection-span indexes are zero-based (for example, the fir...

  • Page 715

    Selection.Addlistener() 715 selection.Addlistener() availability flash player 6. Usage selection.Addlistener(newlistener:object) : void parameters newlistener an object with an onsetfocus method. Returns none. Description method; registers an object to receive keyboard focus change notifications. Wh...

  • Page 716

    716 chapter 2: actionscript language reference selection.Getbeginindex() availability flash player 5. Usage selection.Getbeginindex() : number parameters none. Returns an integer. Description method; returns the index at the beginning of the selection span. If no index exists or no text field curren...

  • Page 717

    Selection.Getcaretindex() 717 selection.Getcaretindex() availability flash player 5. Usage selection.Getcaretindex() : number parameters none. Returns an integer. Description method; returns the index of the blinking insertion point (caret) position. If there is no blinking insertion point displayed...

  • Page 718

    718 chapter 2: actionscript language reference selection.Getendindex() availability flash player 5. Usage selection.Getendindex() : number parameters none. Returns an integer. Description method; returns the ending index of the currently focused selection span. If no index exists, or if there is no ...

  • Page 719

    Selection.Getendindex() 719 see the strings.Fla file for the entire script. Typical paths to the helpexamples folder are: • windows: \program files\macromedia\flash mx 2004\samples\helpexamples\ • macintosh: hd/applications/macromedia flash mx 2004/samples/helpexamples/ see also selection.Getbeginin...

  • Page 720

    720 chapter 2: actionscript language reference selection.Getfocus() availability flash player 5. Instance names for buttons and text fields work in flash player 6 and later. Usage selection.Getfocus() : string parameters none. Returns a string or null . Description method; returns a string specifyin...

  • Page 721

    Selection.Onsetfocus 721 selection.Onsetfocus availability flash player 6. Usage somelistener.Onsetfocus = function( [ oldfocus:object [, newfocus:object ] ]){ // statements; } parameters oldfocus the object losing focus. This parameter is optional. Newfocus the object receiving focus. This paramete...

  • Page 722

    722 chapter 2: actionscript language reference status_txt.Htmltext = "setfocus triggered"; status_txt.Htmltext += ""; status_txt.Htmltext += " \toldfocus:\t"+oldfocus; status_txt.Htmltext += " \tnewfocus:\t"+newfocus; status_txt.Htmltext += " \tgetfocus:\t"+selection.Getfocus(); status_txt.Htmltext ...

  • Page 723

    Selection.Removelistener() 723 selection.Removelistener() availability flash player 6. Usage selection.Removelistener(listener:object) parameters listener the object that will no longer receive focus notifications. Returns if listener was successfully removed, the method returns a true value. If lis...

  • Page 724

    724 chapter 2: actionscript language reference selection.Setfocus() availability flash player 5. Instance names for buttons and movie clips work only in flash player 6 and later. Usage selection.Setfocus("instancename":string) parameters instancename a string specifying the path to a button, movie c...

  • Page 725

    Selection.Setfocus() 725 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 false; } status_txt.Text = "success!"; selection.Setfocus(null); re...

  • Page 726

    726 chapter 2: actionscript language reference selection.Setselection() availability flash player 5. Usage selection.Setselection(start:number, end:number) : void parameters start the beginning index of the selection span. End the ending index of the selection span. Returns nothing. Description meth...

  • Page 727: Chapter 2

    Set 727 set availability flash player 6. Usage function set property(varname) { // 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. This keyword is supported only when used...

  • Page 728

    728 chapter 2: actionscript language reference in a fla or as file that is in the same directory as login.As, enter the following actionscriptin frame 1 of the timeline: var gus:login = new login("gus", "smith"); trace(gus.Username); // output: gus gus.Username = "rupert"; trace(gus.Username); // ou...

  • Page 729: Chapter 2

    Set variable 729 set variable availability flash player 4. Usage set("variablestring", expression) parameters variablestring a string that names a variable to hold the value of the expression parameter. Expression a value assigned to the variable. Returns nothing. Description statement; assigns a va...

  • Page 730

    730 chapter 2: actionscript language reference set("name", "jakob"); trace(name); the following code loops three times and creates three new variables, called caption0 , caption1 , and caption2 : for (var i = 0; i set("caption"+i, "this is caption "+i); } trace(caption0); trace(caption1); trace(capt...

  • Page 731: Chapter 2

    Setinterval() 731 setinterval() availability flash player 6. Usage setinterval(functionname:function, interval:number [, param1:object, param2, ..., paramn]) : number parameters functionname a function name or a reference to an anonymous function. Interval the time in milliseconds between calls to t...

  • Page 732

    732 chapter 2: actionscript language reference usage 3: this example uses a method of an object. You must use this syntax when you want to call a method that is defined for an object. Obj = new object(); obj.Interval = function() { trace("interval function called"); } setinterval( obj, "interval", 1...

  • Page 733

    Setinterval() 733 if you work with setinterval() within classes, you need to be sure to use the this keyword when you call the function. The setinterval() function does not have access to class members if you do not use the keyword. This is illustrated in the following example. For a fla file with a...

  • Page 734: Chapter 2

    734 chapter 2: actionscript language reference setproperty() availability flash player 4. Usage setproperty(target:object, property:object, value/expression:object) : void parameters target the path to the instance name of the movie clip whose property is to be set. Property the property to be set. ...

  • Page 735: Chapter 2

    Sharedobject class 735 sharedobject class availability flash player 6. Description shared objects are powerful: they offer real-time data sharing between objects that are persistent on the user’s computer. You can consider local shared objects as cookies. You can use local shared objects to maintain...

  • Page 736

    736 chapter 2: actionscript language reference • if the user selects none (moves the slider all the way to the left), all sharedobject.Flush() commands issued for the object return "pending", and the player asks the user if additional disk space can be allotted to make room for the object. • if the ...

  • Page 737

    Sharedobject.Clear() 737 sharedobject.Clear() availability flash player 7. Usage my_so.Clear() : void parameters none. Returns nothing. Description method; purges all the data from the shared object and deletes the shared object from the disk. The reference to my_so is still active, and my_so is now...

  • Page 738

    738 chapter 2: actionscript language reference sharedobject.Data availability flash player 6. Usage mylocalsharedobject.Data:object description property; the collection of attributes assigned to the data property of the object; these attributes can be shared and/or stored. Each attribute can be an o...

  • Page 739

    Sharedobject.Data 739 the shared object contains the following data: favoritesong: my world is blue favoritenightclub: the bluenote tavern favoritecolor: blue data: [object object] example the following example saves text from a textinput component instance to a shared object named my_so (for the co...

  • Page 740

    740 chapter 2: actionscript language reference sharedobject.Flush() availability flash player 6. Usage mylocalsharedobject.Flush([minimumdiskspace:number]) : boolean parameters minimumdiskspace an optional integer specifying the number of bytes that must be allotted for this object. The default valu...

  • Page 741

    Sharedobject.Flush() 741 example the following function gets a shared object, my_so, and fills writable properties with user- provided settings. Finally, flush() is called to save the settings and allot a minimum of 1000 bytes of disk space. This.Syncsettingscore = function(soname:string, override:b...

  • Page 742

    742 chapter 2: actionscript language reference sharedobject.Getlocal() availability flash player 6. Usage sharedobject.Getlocal(objectname:string [, localpath:string]) : sharedobject note: the correct syntax is sharedobject.Getlocal . To assign the object to a variable, use syntax like mylocal_so = ...

  • Page 743

    Sharedobject.Getlocal() 743 although the localpath parameter is optional, developers should give some thought to its use, especially if other swf files will need to access the shared object. If the data in the shared object are specific to one swf file that will not be moved to another location, the...

  • Page 744

    744 chapter 2: actionscript language reference // get the user of the kookie and go to the frame number saved for this user. If (my_so.Data.User != undefined) { this.User = my_so.Data.User; this.Gotoandstop(my_so.Data.Frame); } the following code block is placed on each swf file frame: // on each fr...

  • Page 745

    Sharedobject.Getsize() 745 sharedobject.Getsize() availability flash player 6. Usage mylocalsharedobject.Getsize() : number parameters none. Returns a numeric value specifying the size of the shared object, in bytes. Description method; gets the current size of the shared object, in bytes. Flash cal...

  • Page 746

    746 chapter 2: actionscript language reference sharedobject.Onstatus availability flash player 6. Usage mylocalsharedobject.Onstatus = function(infoobject:object) { // your statements here } parameters infoobject a parameter defined according to the status message. Returns nothing. Description event...

  • Page 747

    Sharedobject.Onstatus 747 this.Createtextfield("status_txt", this.Getnexthighestdepth(), 10, 30, 300, 100); status_txt.Multiline = true; status_txt.Html = true; var items_array:array = new array(101, 346, 483); var currentuserisadmin:boolean = true; var currentusername:string = "ramona"; var my_so:s...

  • Page 748: Chapter 2

    748 chapter 2: actionscript language reference sound class availability flash player 5. Description the sound class lets you control sound in a movie. You can add sounds to a movie clip from the library while the movie is playing and control those sounds. If you do not specify a target when you crea...

  • Page 749

    Sound class 749 event handler summary for the sound class constructor for the sound class availability flash player 5. Usage new sound([target:object]) : sound parameters target the movie clip instance on which the sound object operates. This parameter is optional. Returns a reference to a sound obj...

  • Page 750

    750 chapter 2: actionscript language reference sound.Attachsound() availability flash player 5. Usage my_sound.Attachsound("idname":string) : void parameters idname the identifier of an exported sound in the library. The identifier is located in the linkage properties dialog box. Returns nothing. De...

  • Page 751

    Sound.Duration 751 sound.Duration availability flash player 6. Usage my_sound.Duration:number description read-only property; the duration of a sound, in milliseconds. Example the following example loads a sound and displays the duration of the sound file in the output panel. Add the following actio...

  • Page 752

    752 chapter 2: actionscript language reference _xscale = 0; } with (pb.Vbar_mc) { linestyle(1, 0x000000); moveto(0, 0); lineto(0, pb_height); } 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_i...

  • Page 753

    Sound.Getbytesloaded() 753 sound.Getbytesloaded() availability flash player 6. Usage my_sound.Getbytesloaded() : number parameters none. Returns an integer indicating the number of bytes loaded. Description method; returns the number of bytes loaded (streamed) for the specified sound object. You can...

  • Page 754

    754 chapter 2: actionscript language reference status_txt.Text = the_sound.Getbytesloaded()+" of "+the_sound.Getbytestotal()+" bytes ("+pct+"%)"+newline; status_txt.Text += the_sound.Position+" of "+the_sound.Duration+" milliseconds ("+pos+"%)"+newline; } see also sound.Getbytestotal().

  • Page 755

    Sound.Getbytestotal() 755 sound.Getbytestotal() availability flash player 6. Usage my_sound.Getbytestotal() : number parameters none. Returns an integer indicating the total size, in bytes, of the specified sound object. Description method; returns the size, in bytes, of the specified sound object. ...

  • Page 756

    756 chapter 2: actionscript language reference sound.Getpan() availability flash player 5. Usage my_sound.Getpan() : number parameters none. Returns an integer. Description method; returns the pan level set in the last setpan() call as an integer from -100 (left) to 100 (right). (0 sets the left and...

  • Page 757

    Sound.Getpan() 757 knob_mc.Left = knob_mc._x-(bar_width/2); knob_mc.Right = knob_mc._x+(bar_width/2); knob_mc.Top = knob_mc._y; knob_mc.Bottom = knob_mc._y; knob_mc.Onpress = function() { this.Startdrag(false, this.Left, this.Top, this.Right, this.Bottom); }; knob_mc.Onrelease = function() { this.St...

  • Page 758

    758 chapter 2: actionscript language reference sound.Gettransform() availability flash player 5. Usage my_sound.Gettransform() : object parameters none. Returns an object with properties that contain the channel percentage values for the specified sound object. Description method; returns the sound ...

  • Page 759

    Sound.Gettransform() 759 knob_ll.Onreleaseoutside = releaseknob; knob_lr.Top = knob_lr._y; knob_lr.Bottom = knob_lr._y+100; knob_lr.Left = knob_lr._x; knob_lr.Right = knob_lr._x; knob_lr._y = knob_lr._y+(100-transform_obj['lr']); knob_lr.Onpress = pressknob; knob_lr.Onrelease = releaseknob; knob_lr....

  • Page 760

    760 chapter 2: actionscript language reference sound.Getvolume() availability flash player 5. Usage my_sound.Getvolume() : number parameters none. Returns an integer. Description method; returns the sound volume level as an integer from 0 to 100, where 0 is off and 100 is full volume. The default se...

  • Page 761

    Sound.Getvolume() 761 this.Isdragging = true; }; knob_mc.Onmousemove = function() { if (this.Isdragging) { this.Volume_txt.Text = this._x; } } knob_mc.Onrelease = function() { this.Stopdrag(); this.Isdragging = false; my_sound.Setvolume(this._x); }; see also sound.Setvolume().

  • Page 762

    762 chapter 2: actionscript language reference sound.Id3 availability flash player 6; behavior updated in flash player 7. Usage my_sound.Id3 :object description read-only property; provides access to the metadata that is part of an mp3 file. Mp3 sound files can contain id3 tags, which provide metada...

  • Page 763

    Sound.Id3 763 flash player 6 supported several id31.0 tags. If these tags are in not in the mp3 file, but corresponding id3 2.0 tags are, the id3 2.0 tags are copied into the id3 1.0 properties, as shown in the following table. This process provides backward compatibility with scripts that you may h...

  • Page 764

    764 chapter 2: actionscript language reference 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("s...

  • Page 765

    Sound.Loadsound() 765 sound.Loadsound() availability flash player 6. Usage my_sound.Loadsound(url:string, isstreaming:boolean) : void parameters url the location on a server of an mp3 sound file. Isstreaming a boolean value that indicates whether the sound is a streaming sound ( true ) or an event s...

  • Page 766

    766 chapter 2: actionscript language reference sound.Onid3 availability flash player 7. Usage my_sound.Onid3 = function(){ // your statements here } parameters none. Returns nothing. Description event handler; invoked each time new id3 data is available for an mp3 file that you load using sound.Atta...

  • Page 767

    Sound.Onload 767 sound.Onload availability flash player 6. Usage my_sound.Onload = function(success:boolean){ // your statements here } parameters success a boolean value of true if my_sound has been loaded successfully, false otherwise. Returns nothing. Description event handler; invoked automatica...

  • Page 768

    768 chapter 2: actionscript language reference sound.Onsoundcomplete availability flash player 6. Usage my_sound.Onsoundcomplete = function(){ // your statements here } parameters none. Returns nothing. Description event handler; invoked automatically when a sound finishes playing. You can use this ...

  • Page 769

    Sound.Position 769 sound.Position availability flash player 6. Usage my_sound.Position:number description read-only property; the number of milliseconds a sound has been playing. If the sound is looped, the position is reset to 0 at the beginning of each loop. Example see sound.Duration for a sample...

  • Page 770

    770 chapter 2: actionscript language reference sound.Setpan() availability flash player 5. Usage my_sound.Setpan(pan:number) : number parameters pan an integer specifying the left-right balance for a sound. The range of valid values is -100 to 100, where -100 uses only the left channel, 100 uses onl...

  • Page 771

    Sound.Settransform() 771 sound.Settransform() availability flash player 5. Usage my_sound.Settransform(soundtransformobject:object) : void parameters soundtransformobject an object created with the constructor for the generic object class. Returns nothing. Description method; sets the sound transfor...

  • Page 772

    772 chapter 2: actionscript language reference mono sounds play all sound input in the left speaker and have the following transform settings by default: ll = 100 lr = 100 rr = 0 rl = 0 example the following example illustrates a setting that can be achieved by using settransform() , but cannot be a...

  • Page 773

    Sound.Setvolume() 773 sound.Setvolume() availability flash player 5. Usage my_sound.Setvolume(volume:number) : void parameters volume a number from 0 to 100 representing a volume level. 100 is full volume and 0 is no volume. The default setting is 100. Returns nothing. Description method; sets the v...

  • Page 774

    774 chapter 2: actionscript language reference sound.Start() availability flash player 5. Usage my_sound.Start([secondoffset:number, loop:number]) : void parameters secondoffset an optional parameter that lets you start playing the sound at a specific point. For example, if you have a 30-second soun...

  • Page 775

    Sound.Stop() 775 sound.Stop() availability flash player 5. Usage my_sound.Stop(["idname":string]) : void parameters idname an optional parameter specifying a specific sound to stop playing. The idname parameter must be enclosed in quotation marks (" "). Returns nothing. Description method; stops all...

  • Page 776: Chapter 2

    776 chapter 2: actionscript language reference _soundbuftime availability flash player 4. Usage _soundbuftime:number = integer parameters integer the number of seconds before the swf file starts to stream. Description property (global); establishes the number of seconds of streaming sound to buffer....

  • Page 777: Chapter 2

    Stage class 777 stage class availability flash player 6. Description the stage class is a top-level class whose methods, properties, and handlers you can access without using a constructor. Use the methods and properties of this class to access and manipulate information about the boundaries of a sw...

  • Page 778

    778 chapter 2: actionscript language reference stage.Addlistener() availability flash player 6. Usage stage.Addlistener(mylistener:object) : void parameters mylistener an object that listens for a callback notification from the stage.Onresize event. Returns nothing. Description method; detects when ...

  • Page 779

    Stage.Align 779 stage.Align availability flash player 6. Usage stage.Align:string description property; indicates the current alignment of the swf file in the player or browser. The following table lists the values for the align property. Any value not listed here centers the swf file in flash playe...

  • Page 780

    780 chapter 2: actionscript language reference stage.Height availability flash player 6. Usage stage.Height:number description property (read-only); indicates the current height, in pixels, of the stage. When the value of stage.Scalemode is noscale , the height property represents the height of flas...

  • Page 781

    Stage.Onresize 781 stage.Onresize availability flash player 6. Usage mylistener.Onresize = function(){ // your statements here } parameters none. Returns nothing. Description listener; invoked when stage.Scalemode is set to noscale and the swf file is resized. You can use this event handler to write...

  • Page 782

    782 chapter 2: actionscript language reference stage.Removelistener() availability flash player 6. Usage stage.Removelistener(mylistener:object) : boolean parameters mylistener an object added to an object’s callback list with addlistener() . Returns a boolean value. Description method; removes a li...

  • Page 783

    Stage.Scalemode 783 stage.Scalemode availability flash player 6. Usage stage.Scalemode:string description property; 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 param...

  • Page 784

    784 chapter 2: actionscript language reference stage.Showmenu availability flash player 6. Usage stage.Showmenu:boolean description property; specifies whether to show or hide the default items in the flash player context menu. If showmenu is set to true (the default), all context menu items appear....

  • Page 785

    Stage.Width 785 stage.Width availability flash player 6. Usage stage.Width:number description property (read-only); indicates the current width, in pixels, of the stage. When the value of stage.Scalemode is "noscale" , the width property represents the width of flash player. This means that stage.Wi...

  • Page 786: Chapter 2

    786 chapter 2: actionscript language reference startdrag() availability flash player 4. Usage startdrag(target:object,[lock:boolean, left:number, top:number, right:number, bottom:number]) : void parameters target the target path of the movie clip to drag. Lock a boolean value specifying whether the ...

  • Page 787: Chapter 2

    Static 787 static availability flash player 6. Usage 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. Th...

  • Page 788

    788 chapter 2: actionscript language reference see also private , public.

  • Page 789: Chapter 2

    Stop() 789 stop() availability flash 2. Usage stop() parameters none. Returns nothing. Description function; stops the swf file that is currently playing. The most common use of this action is to control movie clips with buttons. See also gotoandstop() , movieclip.Gotoandstop() chapter 2 actionscrip...

  • Page 790: Chapter 2

    790 chapter 2: actionscript language reference stopallsounds() availability flash player 3. Usage stopallsounds() : void parameters none. Returns nothing. Description function; stops all sounds currently playing in a swf file without stopping the playhead. Sounds set to stream will resume playing as...

  • Page 791: Chapter 2

    Stopdrag() 791 stopdrag() availability flash player 4. Usage stopdrag() : void parameters none. Returns nothing. Description function; stops the current drag operation. Example the following code, placed in the main timeline, stops the drag action on the movie clip instance my_mc when the user relea...

  • Page 792: Chapter 2

    792 chapter 2: actionscript language reference string() availability flash player 4; behavior changed in flash player 7. Usage string(expression) parameters expression an expression to convert to a string. Returns a string. Description function; returns a string representation of the specified param...

  • Page 793: Chapter 2

    String class 793 string class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the string class is a wrapper for the string primitive data type, and provides methods and properties that let you manipulate primitive string v...

  • Page 794

    794 chapter 2: property summary for the string class constructor for the string class availability flash player 5. Usage new string(value:string) : string parameters value the initial value of the new string object. Returns a reference to a string object. Description constructor; creates a new strin...

  • Page 795

    String.Charat() 795 string.Charat() availability flash player 5. Usage my_str.Charat(index:number) : string parameters index a 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 . Ret...

  • Page 796

    796 chapter 2: string.Charcodeat() availability flash player 5. Usage my_str.Charcodeat(index:number) : number parameters index a number; an integer that specifies 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 -...

  • Page 797

    String.Concat() 797 string.Concat() availability flash player 5. Usage my_str.Concat(value1,...Valuen) : string parameters value1,...Valuen zero or more values to be concatenated. Returns a string. Description method; combines the value of the string object with the parameters and returns the newly ...

  • Page 798

    798 chapter 2: string.Fromcharcode() availability flash player 5. Usage string.Fromcharcode(c1:number,c2,...Cn) : string parameters c1,c2,...Cn a number; decimal integers that represent ascii values. Returns a string. Description method; returns a string comprising the characters represented by the ...

  • Page 799

    String.Indexof() 799 string.Indexof() availability flash player 5. Usage my_str.Indexof(substring:string, [startindex:number]) parameters substring a string; the substring to be searched for within my_str . Startindex a number; an optional integer specifying the starting point in my_str to search fo...

  • Page 800

    800 chapter 2: string.Lastindexof() availability flash player 5. Usage my_str.Lastindexof(substring:string, [startindex:number]) : number parameters substring string; the string for which to search. Startindex number; an optional integer specifying the starting point from which to search for substri...

  • Page 801

    String.Length 801 string.Length availability flash player 5. Usage my_str.Length:number description property; 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 . E...

  • Page 802

    802 chapter 2: string.Slice() availability flash player 5. Usage my_str.Slice(start:number, [end:number]) : string parameters start a number; the zero-based index of the starting point for the slice. If start is a negative number, the starting point is determined from the end of the string, where -1...

  • Page 803

    String.Slice() 803 // slices that omit the end parameter use string.Length, which equals 5 trace("slice(0): "+my_str.Slice(0)); // slice(0): lorem trace("slice(3): "+my_str.Slice(3)); // slice(3): em an example is also in the strings.Fla file in the helpexamples folder. The following list gives typi...

  • Page 804

    804 chapter 2: string.Split() availability flash player 5. Usage my_str.Split("delimiter":string, [limit:number]) : number parameters delimiter a string; the character or string at which my_str splits. Limit a number; the number of items to place into the array. This parameter is optional. Returns a...

  • Page 805

    String.Split() 805 /* output: j o e */ an example is also in the strings.Fla file in the helpexamples folder. The following list gives typical paths to this folder: • windows: \program files\macromedia\flash mx 2004\samples\helpexamples\ • macintosh: hd/applications/macromedia flash mx 2004/samples/...

  • Page 806

    806 chapter 2: string.Substr() availability flash player 5. Usage my_str.Substr(start:number, [length:number]) : string parameters start a number; an integer that indicates the position of the first character in my_str to be used to create the substring. If start is a negative number, the starting p...

  • Page 807

    String.Substring() 807 string.Substring() availability flash player 5. Usage my_str.Substring(start:number, [end:number]) : string parameters start a number; an integer that indicates the position of the first character of my_str used to create the substring. Valid values for start are 0 through str...

  • Page 808

    808 chapter 2: string.Tolowercase() availability flash player 5. Usage my_str.Tolowercase() : string parameters none. Returns a string. Description method; returns a copy of the string object, with all uppercase characters converted to lowercase. The original value is unchanged. Example the followin...

  • Page 809

    String.Touppercase() 809 string.Touppercase() availability flash player 5. Usage my_str.Touppercase() : string parameters none. Returns a string. Description method; returns a copy of the string object, with all lowercase characters converted to uppercase. The original value is unchanged. Example th...

  • Page 810: Chapter 2

    810 chapter 2: actionscript language reference " " (string delimiter) availability flash player 4. Usage "text" parameters text a sequence of zero or more characters. Returns nothing. Description string delimiter; when used before and after characters, quotation marks ("") indicate that the characte...

  • Page 811: Chapter 2

    Super 811 super availability flash player 6. Usage super.Method([arg1, ..., argn]) super([arg1, ..., argn]) parameters method the method to invoke in the superclass. Arg1 optional parameters that are passed to the superclass version of the method (syntax 1) or to the constructor function of the supe...

  • Page 812

    812 chapter 2: actionscript language reference then create a new class called socks that extends the clothes class, as shown in the following example: class socks extends clothes { private var color:string; function socks(param_color:string) { this.Color = param_color; trace("[socks] i am the constr...

  • Page 813: Chapter 2

    Switch 813 switch availability flash player 4. Usage switch (expression){ caseclause: [defaultclause:] } parameters expression any expression. Caseclause a case keyword followed by an expression, a colon, and a group of statements to execute if the expression matches the switch expression parameter ...

  • Page 814

    814 chapter 2: actionscript language reference case "i" : trace("you pressed i or i"); break; default : trace("you pressed some other key"); } }; key.Addlistener(listenerobj); see also === (strict equality) , break , case , default , if.

  • Page 815: Chapter 2

    System.Capabilities object 815 system.Capabilities object availability flash player 6. Description you can use the system.Capabilities object to determine the abilities of the system and player hosting a swf file, which lets you tailor content for different formats. For example, the screen of a cell...

  • Page 816

    816 chapter 2: actionscript language reference system.Capabilities.Hasscreenbroadcast indicates whether the player supports the development of screen broadcast applications to be run through the flash communication server. Sb system.Capabilities.Hasscreenplayback indicates whether the player support...

  • Page 817

    System.Capabilities.Avhardwaredisable 817 system.Capabilities.Avhardwaredisable availability flash player 7. Usage system.Capabilities.Avhardwaredisable:boolean description read-only property; a boolean value that specifies whether access to the user’s camera and microphone has been administratively...

  • Page 818

    818 chapter 2: actionscript language reference system.Capabilities.Hasaccessibility availability flash player 6. Usage system.Capabilities.Hasaccessibility:boolean description read-only property: a boolean value that is true if the player is running in an environment that supports communication betw...

  • Page 819

    System.Capabilities.Hasaudio 819 system.Capabilities.Hasaudio availability flash player 6. Usage system.Capabilities.Hasaudio:boolean description read-only property: a boolean value that is true if the player is running on a system that has audio capabilities; false otherwise. The server string is a...

  • Page 820

    820 chapter 2: actionscript language reference system.Capabilities.Hasaudioencoder availability flash player 6. Usage system.Capabilities.Hasaudioencoder:boolean description read-only property: a boolean value that is true if the player can encode an audio stream, such as that coming from a micropho...

  • Page 821

    System.Capabilities.Hasembeddedvideo 821 system.Capabilities.Hasembeddedvideo availability flash player 6 r65. Usage system.Capabilities.Hasembeddedvideo:boolean description read-only property: a boolean value that is true if the player is running on a system that supports embedded video; false othe...

  • Page 822

    822 chapter 2: actionscript language reference system.Capabilities.Hasmp3 availability flash player 6. Usage system.Capabilities.Hasmp3:boolean description read-only property: a boolean value that is true if the player is running on a system that has an mp3 decoder; false otherwise. The server strin...

  • Page 823

    System.Capabilities.Hasprinting 823 system.Capabilities.Hasprinting availability flash player 6 r65. Usage system.Capabilities.Hasprinting:boolean description read-only property: a boolean value that is true if the player is running on a system that supports printing; false otherwise. The server str...

  • Page 824

    824 chapter 2: actionscript language reference system.Capabilities.Hasscreenbroadcast availability flash player 6 r79. Usage system.Capabilities.Hasscreenbroadcast:boolean description read-only property: a boolean value that is true if the player supports the development of screen broadcast applicat...

  • Page 825

    System.Capabilities.Hasscreenplayback 825 system.Capabilities.Hasscreenplayback availability flash player 6 r79. Usage system.Capabilities.Hasscreenplayback:boolean description read-only property: a boolean value that is true if the player supports the playback of screen broadcast applications that ...

  • Page 826

    826 chapter 2: actionscript language reference system.Capabilities.Hasstreamingaudio availability flash player 6 r65. Usage system.Capabilities.Hasstreamingaudio:boolean description read-only property: a boolean value that is true if the player can play streaming audio; false otherwise. The server s...

  • Page 827

    System.Capabilities.Hasstreamingvideo 827 system.Capabilities.Hasstreamingvideo availability flash player 6 r65. Usage system.Capabilities.Hasstreamingvideo:boolean description read-only property: a boolean value that is true if the player can play streaming video; false otherwise. The server string...

  • Page 828

    828 chapter 2: actionscript language reference system.Capabilities.Hasvideoencoder availability flash player 6. Usage system.Capabilities.Hasvideoencoder:boolean description read-only property: a boolean value that is true if the player can encode a video stream, such as that coming from a web camer...

  • Page 829

    System.Capabilities.Isdebugger 829 system.Capabilities.Isdebugger availability flash player 6. Usage system.Capabilities.Isdebugger:boolean description read-only property; a boolean value that indicates whether the player is an officially released version ( false ) or a special debugging version ( t...

  • Page 830

    830 chapter 2: actionscript language reference system.Capabilities.Language availability flash player 6. Behavior changed in flash player 7. Usage system.Capabilities.Language:string description read-only property; indicates the language of the system on which the player is running. This property is...

  • Page 831

    System.Capabilities.Language 831 example the following example traces the value of this read-only property: trace(system.Capabilities.Language); russian ru simplified chinese zh-cn spanish es swedish sv traditional chinese zh-tw turkish tr language tag.

  • Page 832

    832 chapter 2: actionscript language reference system.Capabilities.Localfilereaddisable availability flash player 7. Usage system.Capabilities.Localfilereaddisable:boolean description read-only property; a boolean value that indicates whether read access to the user’s hard disk has been administrati...

  • Page 833

    System.Capabilities.Manufacturer 833 system.Capabilities.Manufacturer availability flash player 6. Usage system.Capabilities.Manufacturer:string description read-only property; a string that indicates the manufacturer of flash player, in the format "macromedia osname" ( osname could be "windows" , "...

  • Page 834

    834 chapter 2: actionscript language reference system.Capabilities.Os availability flash player 6. Usage system.Capabilities.Os:string description read-only property; a string that indicates the current operating system. The os property can return the following strings: "windows xp" , "windows 2000"...

  • Page 835

    System.Capabilities.Pixelaspectratio 835 system.Capabilities.Pixelaspectratio availability flash player 6. Usage system.Capabilities.Pixelaspectratio:number description read-only property; an integer that indicates the pixel aspect ratio of the screen. The server string is ar . Example the following...

  • Page 836

    836 chapter 2: actionscript language reference system.Capabilities.Playertype availability flash player 7. Usage system.Capabilities.Playertype;string description read-only property; a string that indicates the type of player. This property can have one of the following values: • "standalone" for th...

  • Page 837

    System.Capabilities.Screencolor 837 system.Capabilities.Screencolor availability flash player 6. Usage system.Capabilities.Screencolor:string description read-only property; a string that indicates the screen color. This property can have the value "color ", " gray " or "bw ", which represents color...

  • Page 838

    838 chapter 2: actionscript language reference system.Capabilities.Screendpi availability flash player 6. Usage system.Capabilities.Screendpi:number description read-only property; a number that indicates the dots-per-inch (dpi) resolution of the screen, in pixels. The server string is dp . Example ...

  • Page 839

    System.Capabilities.Screenresolutionx 839 system.Capabilities.Screenresolutionx availability flash player 6. Usage system.Capabilities.Screenresolutionx:number description read-only property; an integer that indicates the maximum horizontal resolution of the screen. The server string is r (which ret...

  • Page 840

    840 chapter 2: actionscript language reference system.Capabilities.Screenresolutiony availability flash player 6. Usage system.Capabilities.Screenresolutiony:number description read-only property; an integer that indicates the maximum vertical resolution of the screen. The server string is r (which ...

  • Page 841

    System.Capabilities.Serverstring 841 system.Capabilities.Serverstring availability flash player 6. Usage system.Capabilities.Serverstring:string description read-only property; a url-encoded string that specifies values for each system.Capabilities property, as shown in the following example: a=t&sa...

  • Page 842

    842 chapter 2: actionscript language reference system.Capabilities.Version availability flash player 6. Usage system.Capabilities.Version:string description read-only property; a string containing the flash player platform and version information (for example, "win 7,0,19,0" ). The server string is ...

  • Page 843: Chapter 2

    System.Security object 843 system.Security object availability flash player 6. Description this object contains methods that specify how swf files in different domains can communicate with each other. Method summary for the system.Security object method description system.Security.Allowdomain() lets...

  • Page 844

    844 chapter 2: actionscript language reference system.Security.Allowdomain() availability flash player 6; behavior changed in flash player 7. Usage system.Security.Allowdomain("domain1":string, "domain2", ... "domainn") : void parameters domain1, domain2, ... Domainn strings that specify domains tha...

  • Page 845

    System.Security.Allowdomain() 845 the opposite situation can also occur; that is, you might create a child swf file that wants to allow its parent to script it, but doesn’t know what the domain of its parent will be. In this situation, call system.Security.Allowdomain(_parent._url) from the child sw...

  • Page 846

    846 chapter 2: actionscript language reference system.Security.Allowinsecuredomain() availability flash player 7. Usage system.Security.Allowinsecuredomain("domain":string) : void parameters domain a string; an exact domain name, such as www.Mydomainname.Com or store.Mydomainname.Com. Returns nothin...

  • Page 847

    System.Security.Allowinsecuredomain() 847 see also system.Security.Allowdomain() , system.Exactsettings.

  • Page 848

    848 chapter 2: actionscript language reference system.Security.Loadpolicyfile() availability flash player 7 (7.0.19.0) usage system.Security.Loadpolicyfile(url:string) : void parameters url a string; the url where the cross-domain policy file to be loaded is located. Returns nothing. Description met...

  • Page 849

    System.Security.Loadpolicyfile() 849 this causes flash player to attempt to retrieve a policy file from the specified host and port. Any port can be used, not only ports 1024 and higher. Upon establishing a connection with the specified port, flash player transmits , terminated by a null byte. An xm...

  • Page 850: Chapter 2

    850 chapter 2: actionscript language reference system class availability flash player 6. Description this is a top-level class that contains the capabilities object (see system.Capabilities object ), the security object (see system.Security object ), and the methods, properties, and event handlers l...

  • Page 851

    System.Exactsettings 851 system.Exactsettings availability flash player 7 or later. Usage system.Exactsettings:boolean description property; a boolean value that specifies whether to use superdomain ( false ) or exact domain ( true ) matching rules when accessing local settings (such as camera or mi...

  • Page 852

    852 chapter 2: actionscript language reference usually you should find that the default value of system.Exactsettings is fine. Often your only requirement is that when a swf file saves a shared object in one session, the same swf file can retrieve the same shared object in a later session. This situ...

  • Page 853

    System.Onstatus 853 system.Onstatus availability flash player 6. Usage system.Onstatus = function(infoobject:object) { // your statements } description event handler: provides a super event handler for certain objects. The localconnection, netstream, and sharedobject classes provide an onstatus even...

  • Page 854

    854 chapter 2: actionscript language reference system.Setclipboard() availability swf files published for flash player 6 or later, playing in flash player 7 or later. Usage system.Setclipboard(string:string) : boolean parameters string a plain-text string of characters to place on the system clipboa...

  • Page 855

    System.Showsettings() 855 system.Showsettings() availability flash player 6. Usage system.Showsettings([panel:number]) : void parameters panel a number; an optional number that specifies which flash player settings panel to display, as shown in the following table: returns nothing. Description metho...

  • Page 856

    856 chapter 2: actionscript language reference system.Usecodepage availability flash player 6. Usage system.Usecodepage:boolean description property; a boolean value that tells flash player whether to use unicode or the traditional code page of the operating system running the player to interpret ex...

  • Page 857: Chapter 2

    Targetpath() 857 targetpath() availability flash player 5. Usage targetpath(movieclipobject:movieclip) : string parameters movieclipobject reference (for example, _root or _parent ) to the movie clip for which the target path is being retrieved. Returns a string containing the target path of the spe...

  • Page 858: Chapter 2

    858 chapter 2: actionscript language reference textfield.Stylesheet class availability flash player 7. Description the textfield.Stylesheet class lets you create a style sheet object that contains text formatting rules such as font size, color, and other formatting styles. You can then apply styles ...

  • Page 859

    Textfield.Stylesheet class 859 constructor for the textfield.Stylesheet class availability flash player 7. Usage new textfield.Stylesheet() : textfield.Stylesheet returns a reference to a textfield.Stylesheet object. Description constructor; creates a textfield.Stylesheet object. Example the followi...

  • Page 860

    860 chapter 2: actionscript language reference textfield.Stylesheet.Clear() availability flash player 7. Usage stylesheet.Clear() : void parameters none. Returns nothing. Description method; removes all styles from the specified style sheet object. Example the following example loads a style sheet c...

  • Page 861

    Textfield.Stylesheet.Getstyle() 861 textfield.Stylesheet.Getstyle() availability flash player 7. Usage stylesheet.Getstyle(stylename:string) : object parameters stylename a string that specifies the name of the style to retrieve. Returns an object. Description method; returns a copy of the style obj...

  • Page 862

    862 chapter 2: actionscript language reference var styleobject:object = my_stylesheet.Getstyle(stylename); for (var propname in styleobject) { var propvalue = styleobject[propname]; trace("\t"+propname+": "+propvalue); } trace(""); } } } } create a new css document called styles.Css, which has two s...

  • Page 863

    Textfield.Stylesheet.Getstylenames() 863 textfield.Stylesheet.Getstylenames() availability flash player 7. Usage stylesheet.Getstylenames() : array parameters none. Returns an array. Description method; returns an array that contains the names (as strings) of all of the styles registered in this sty...

  • Page 864

    864 chapter 2: actionscript language reference textfield.Stylesheet.Load() availability flash player 7. Usage stylesheet.Load(url:string) : void parameters url the url of a css file to load. The url must be in the same domain as the url where the swf file currently resides. Returns nothing. Descript...

  • Page 865

    Textfield.Stylesheet.Onload 865 textfield.Stylesheet.Onload availability flash player 7. Usage stylesheet.Onload = function (success:boolean) {} parameters success a boolean value indicating whether the css file was successfully loaded. Returns nothing. Description callback handler; invoked when a t...

  • Page 866

    866 chapter 2: actionscript language reference textfield.Stylesheet.Parsecss() availability flash player 7. Usage stylesheet.Parsecss(csstext:string) : boolean parameters csstext the css text to parse (a string). Returns a boolean value indicating if the text was parsed successfully ( true ) or not ...

  • Page 867

    Textfield.Stylesheet.Setstyle() 867 textfield.Stylesheet.Setstyle() availability flash player 7. Usage stylesheet.Setstyle(name:string, style:object) : void parameters name a string that specifies the name of the style to add to the style sheet. Style an object that describes the style, or null . Re...

  • Page 868

    868 chapter 2: actionscript language reference this displays the following information in the output panel: emphasized fontweight: bold color: #000000 note: the line of code delete styleobj deletes the original style object passed to setstyle() . While not necessary, this step reduces memory usage, ...

  • Page 869

    Textfield.Stylesheet.Transform() 869 textfield.Stylesheet.Transform() availability flash player 7. Usage stylesheet.Transform(style:object) : textformat parameters style an object that describes the style, containing style rules as properties of the object, or null . Returns a textformat object cont...

  • Page 870: Chapter 2

    870 chapter 2: actionscript language reference textfield class availability flash player 6. Description all dynamic and input text fields in a swf file are instances of the textfield class. You can give a text field an instance name in the property inspector and use the methods and properties of the...

  • Page 871

    Textfield class 871 textfield.Border indicates if the text field has a border. Textfield.Bordercolor indicates the color of the border. Textfield.Bottomscroll read-only; the bottommost visible line in a text field. Textfield.Embedfonts indicates whether the text field uses embedded font outlines or ...

  • Page 872

    872 chapter 2: actionscript language reference event handler summary for the textfield class listener summary for the textfield class textfield.Textheight the height of the text field’s bounding box. Textfield.Textwidth the width of the text field’s bounding box. Textfield.Type indicates whether a t...

  • Page 873

    Textfield.Addlistener() 873 textfield.Addlistener() availability flash player 6. Usage my_txt.Addlistener(listener:object) : void parameters listener an object with an onchanged or onscroller event handler. Returns nothing. Description method; registers an object to receive notification when the onc...

  • Page 874

    874 chapter 2: actionscript language reference }; my_txt.Addlistener(txtlistener); see also textfield.Onchanged , textfield.Onscroller , textfield.Removelistener().

  • Page 875

    Textfield._alpha 875 textfield._alpha availability flash player 6. Usage my_txt._alpha:number description property; sets or retrieves the alpha transparency value of the text field specified by my_txt . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Transpare...

  • Page 876

    876 chapter 2: actionscript language reference textfield.Autosize availability flash player 6. Usage my_txt.Autosize:string my_txt.Autosize:boolean description property; controls automatic sizing and alignment of text fields. Acceptable values for autosize are "none" (the default), "left" , "right" ...

  • Page 877

    Textfield.Autosize 877 center_txt.Text = "short text"; center_txt.Border = true; right_txt.Text = "short text"; right_txt.Border = true; true_txt.Text = "short text"; true_txt.Border = true; false_txt.Text = "short text"; false_txt.Border = true; // create a mouse listener object to detect mouse cli...

  • Page 878

    878 chapter 2: actionscript language reference textfield.Background availability flash player 6. Usage my_txt.Background:boolean description property; if true , the text field has a background fill. If false , the text field has no background fill. Example the following example creates a text field ...

  • Page 879

    Textfield.Backgroundcolor 879 textfield.Backgroundcolor availability flash player 6. Usage my_txt.Backgroundcolor:number description property; the color of the text field background. Default is 0xffffff (white). This property may be retrieved or set, even if there currently is no background, but the...

  • Page 880

    880 chapter 2: actionscript language reference textfield.Border availability flash player 6. Usage my_txt.Border:boolean description property; if true , the text field has a border. If false , the text field has no border. Example the following example creates a text field called my_txt , sets the b...

  • Page 881

    Textfield.Bordercolor 881 textfield.Bordercolor availability flash player 6. Usage my_txt.Bordercolor:number description property; the color of the text field border, the default is 0x000000 (black). This property may be retrieved or set, even if there is currently no border. Example the following e...

  • Page 882

    882 chapter 2: actionscript language reference textfield.Bottomscroll availability flash player 6. Usage my_txt.Bottomscroll:number description read-only property; an integer (one-based index) that indicates the bottommost line that is currently visible in my_txt . Think of the text field as a “wind...

  • Page 883

    Textfield.Condensewhite 883 textfield.Condensewhite availability flash player 6. Usage my_txt.Condensewhite:boolean description property; a boolean value that specifies whether extra white space (spaces, line breaks, and so on) in an html text field should be removed when the field is rendered in a ...

  • Page 884

    884 chapter 2: actionscript language reference textfield.Embedfonts availability flash player 6. Usage my_txt.Embedfonts:boolean description property; a boolean value that, when true , renders the text field using embedded font outlines. If false , it renders the text field using device fonts. Examp...

  • Page 885

    Textfield.Getdepth() 885 textfield.Getdepth() availability flash player 6. Usage my_txt.Getdepth() : number parameters none. Returns an integer. Description method; returns the depth of a text field. Example the following example demonstrates text fields residing at different depths. Create a dynami...

  • Page 886

    886 chapter 2: actionscript language reference textfield.Getfontlist() availability flash player 6. Usage textfield.Getfontlist() : array parameters none. Returns an array. Description method; a static method of the global textfield class . You don’t specify a specific text field (such as my_txt ) w...

  • Page 887

    Textfield.Getnewtextformat() 887 textfield.Getnewtextformat() availability flash player 6. Usage my_txt.Getnewtextformat() : textformat parameters none. Returns a textformat object. Description method; returns a textformat object containing a copy of the text field’s text format object. The text for...

  • Page 888

    888 chapter 2: actionscript language reference textfield.Gettextformat() availability flash player 6. Usage my_txt.Gettextformat() : object my_txt.Gettextformat(index:number) : object my_txt.Gettextformat(beginindex:number, endindex:number) : object parameters index an integer that specifies a chara...

  • Page 889

    Textfield._height 889 textfield._height availability flash player 6. Usage my_txt._height:number description property; the height of the text field, in pixels. Example the following code example sets the height and width of a text field: my_txt._width = 200; my_txt._height = 200;.

  • Page 890

    890 chapter 2: actionscript language reference textfield.Hscroll availability flash player 6. Usage my_txt.Hscroll:number returns an integer. Description property; indicates the current horizontal scrolling position. If the hscroll property is 0, the text is not horizontally scrolled. For more infor...

  • Page 891

    Textfield.Html 891 textfield.Html availability flash player 6. Usage my_txt.Html:boolean description property; a flag that indicates whether the text field contains an html representation. If the html property is true , the text field is an html text field. If html is false , the text field is a non...

  • Page 892

    892 chapter 2: actionscript language reference textfield.Htmltext availability flash player 6. Usage my_txt.Htmltext:string description property; if the text field is an html text field, this property contains the html representation of the text field’s contents. If the text field is not an html tex...

  • Page 893

    Textfield.Length 893 textfield.Length availability flash player 6. Usage my_txt.Length:number returns a number. Description read-only property; indicates the number of characters in a text field. This property returns the same value as text.Length , but is faster. A character such as tab ( \t ) coun...

  • Page 894

    894 chapter 2: actionscript language reference textfield.Maxchars availability flash player 6. Usage my_txt.Maxchars:number description property; indicates the maximum number of characters that the text field can contain. A script may insert more text than maxchars allows; the maxchars property indi...

  • Page 895

    Textfield.Maxhscroll 895 textfield.Maxhscroll availability flash player 6. Usage my_txt.Maxhscroll:number description read-only property; indicates the maximum value of textfield.Hscroll . Example see the example for textfield.Hscroll ..

  • Page 896

    896 chapter 2: actionscript language reference textfield.Maxscroll availability flash player 6. Usage textfield.Maxscroll:number description read-only property; indicates the maximum value of textfield.Scroll . For more information on scrolling text, see “creating scrolling text” in using actionscri...

  • Page 897

    Textfield.Menu 897 textfield.Menu availability flash player 7. Usage my_txt.Menu = contextmenu parameters contextmenu a contextmenu object. Description property; associates the contextmenu object contextmenu with the text field my_txt . The contextmenu class lets you modify the context menu that app...

  • Page 898

    898 chapter 2: actionscript language reference textfield.Mousewheelenabled availability flash player 7. Usage my_txt.Mousewheelenabled:boolean description property; a boolean value that indicates whether flash player should automatically scroll multiline text fields when the mouse pointer clicks a t...

  • Page 899

    Textfield.Multiline 899 textfield.Multiline availability flash player 6. Usage my_txt.Multiline:boolean description property; indicates whether the text field is a multiline text field. If the value is true , the text field is multiline; if the value is false , the text field is a single-line text f...

  • Page 900

    900 chapter 2: actionscript language reference textfield._name availability flash player 6. Usage my_txt . _name:string description property; the instance name of the text field specified by my_txt . Example the following example demonstrates text fields residing at different depths. Create a dynami...

  • Page 901

    Textfield.Onchanged 901 textfield.Onchanged availability flash player 6. Usage my_txt.Onchanged = function(){ // your statements here } mylistenerobj.Onchanged = function(){ // your statements here } parameters none. Returns the instance name of the text field. Description event handler/listener; in...

  • Page 902

    902 chapter 2: actionscript language reference textfield.Onkillfocus availability flash player 6. Usage my_txt.Onkillfocus = function(newfocus:object){ // your statements here } parameters newfocus the object that is receiving the focus. Returns nothing. Description event handler; invoked when a tex...

  • Page 903

    Textfield.Onscroller 903 textfield.Onscroller availability flash player 6. Usage my_txt.Onscroller = function(textfieldinstance:textfield){ // your statements here } mylistenerobj.Onscroller = function(textfieldinstance:textfield){ // your statements here } parameters textfieldinstance a reference t...

  • Page 904

    904 chapter 2: actionscript language reference example the following example creates a text field called my_txt , and uses two buttons called scrollup_btn and scrolldown_btn to scroll the contents of the text field. When the onscroller event handler is called, a trace statement is used to display in...

  • Page 905

    Textfield.Onsetfocus 905 textfield.Onsetfocus availability flash player 6. Usage my_txt.Onsetfocus = function(oldfocus:object){ // your statements here } parameters oldfocus the object to lose focus. Returns nothing. Description event handler; invoked when a text field receives keyboard focus. The o...

  • Page 906

    906 chapter 2: actionscript language reference textfield._parent availability flash player 6. Usage my_txt._parent.Property _parent.Property description property; a reference to the movie clip or object that contains the current text field or object. The current object is the one containing the acti...

  • Page 907

    Textfield.Password 907 textfield.Password availability flash player 6. Usage my_txt.Password:boolean description property; if the value of password is true , the text field is a password text field and hides the input characters using asterisks instead of the actual characters. If false , the text f...

  • Page 908

    908 chapter 2: actionscript language reference textfield._quality availability flash player 6. Usage my_txt._quality:string description 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 prope...

  • Page 909

    Textfield.Removelistener() 909 textfield.Removelistener() availability flash player 6. Usage my_txt.Removelistener(listener:object) parameters listener the object that will no longer receive notifications from textfield.Onchanged or textfield.Onscroller . Returns if listener was successfully removed...

  • Page 910

    910 chapter 2: actionscript language reference textfield.Removetextfield() availability flash player 6. Usage my_txt.Removetextfield() : void description method; removes the text field specified by my_txt . This operation can only be performed on a text field that was created with movieclip.Createte...

  • Page 911

    Textfield.Replacesel() 911 textfield.Replacesel() availability flash player 6. Usage my_txt.Replacesel(text:string) : void parameters text a string. Returns nothing. Description method; replaces the current selection with the contents of the text parameter. The text is inserted at the position of th...

  • Page 912

    912 chapter 2: actionscript language reference textfield.Replacetext() availability flash player 7. Usage my_txt.Replacetext(beginindex:number, endindex:number, text:string) : void description method; replaces a range of characters, specified by the beginindex and endindex parameters, in the specifi...

  • Page 913

    Textfield.Restrict 913 textfield.Restrict availability flash player 6. Usage my_txt.Restrict:string description property; indicates the set of characters that a user may enter into the text field. If the value of the restrict property is null , you can enter any character. If the value of the restri...

  • Page 914

    914 chapter 2: actionscript language reference textfield._rotation availability flash player 6. Usage my_txt._rotation:number description property; the rotation of the text field, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 repr...

  • Page 915

    Textfield.Scroll 915 textfield.Scroll availability flash player 6. Usage my_txt.Scroll description property; defines the vertical position of text in a text field. The scroll property is useful for directing users to a specific paragraph in a long passage, or creating scrolling text fields. This pro...

  • Page 916

    916 chapter 2: actionscript language reference textfield.Selectable availability flash player 6. Usage my_txt.Selectable:boolean description property; a boolean value that indicates whether the text field is selectable. The value true indicates that the text is selectable. The selectable property co...

  • Page 917

    Textfield.Setnewtextformat() 917 textfield.Setnewtextformat() availability flash player 6. Usage my_txt.Setnewtextformat(textformat:textformat) : void parameters textformat a textformat object. Returns nothing. Description method; sets the default new text format of a text field; that is, the text f...

  • Page 918

    918 chapter 2: actionscript language reference textfield.Settextformat() availability flash player 6. Usage my_txt.Settextformat (textformat:textformat) : void my_txt.Settextformat (index:number, textformat:textformat) : void my_txt.Settextformat (beginindex:number, endindex:number, textformat:textf...

  • Page 919

    Textfield.Settextformat() 919 notice that any text inserted manually by the user, or replaced by means of textfield.Replacesel() , receives the text field's default formatting for new text, and not the formatting specified for the text insertion point. To set a text field’s default formatting for ne...

  • Page 920

    920 chapter 2: actionscript language reference textfield.Stylesheet availability flash player 7. Usage my_txt.Stylesheet = textfield stylesheet description property; attaches a style sheet to the text field specified by my_txt . For information on creating style sheets, see the textfield.Stylesheet ...

  • Page 921

    Textfield.Stylesheet 921 if (success) { news_txt.Stylesheet = styleobj; news_txt.Htmltext = newstext; } }; styleobj.Load("styles2.Css"); }; clearcss_btn.Onrelease = function() { news_txt.Stylesheet = undefined; news_txt.Htmltext = newstext; }; the following styles are applied to the text field. Save...

  • Page 922

    922 chapter 2: actionscript language reference textfield.Tabenabled availability flash player 6. Usage my_txt.Tabenabled:boolean description property; specifies whether my_txt is included in automatic tab ordering. It is undefined by default. If the tabenabled property is undefined or true , the obj...

  • Page 923

    Textfield.Tabindex 923 textfield.Tabindex availability flash player 6. Usage my_txt.Tabindex:number parameters none. Returns nothing. Description property; lets you customize the tab ordering of objects in a swf file. You can set the tabindex property on a button, movie clip, or text field instance;...

  • Page 924

    924 chapter 2: actionscript language reference one_txt.Tabindex = 3; two_txt.Tabindex = 1; three_txt.Tabindex = 2; four_txt.Tabindex = 4; see also button.Tabindex , movieclip.Tabindex.

  • Page 925

    Textfield._target 925 textfield._target availability flash player 6. Usage my_txt._target:string description read-only property; the target path of the text field instance specified by my_txt. The _self target specifies the current frame in the current window, _blank specifies a new window, _parent ...

  • Page 926

    926 chapter 2: actionscript language reference textfield.Text availability flash player 6. Usage my_txt.Text:string description property; indicates the current text in the text field. Lines are separated by the carriage return character ('\r', ascii 13). This property contains the normal, unformatte...

  • Page 927

    Textfield.Textcolor 927 textfield.Textcolor availability flash player 6. Usage my_txt.Textcolor:number description property; 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. ...

  • Page 928

    928 chapter 2: actionscript language reference textfield.Textheight availability flash player 6. Usage my_txt.Textheight:number description property; indicates the height of the text. Example the following example creates a text field, and assigns a string of text to the field. A trace statement is ...

  • Page 929

    Textfield.Textwidth 929 textfield.Textwidth availability flash player 6. Usage my_txt.Textwidth:number description property; indicates the width of the text. Example see the example for textfield.Textheight . See also textfield.Textheight.

  • Page 930

    930 chapter 2: actionscript language reference textfield.Type availability flash player 6. Usage my_txt.Type:string description property; specifies the type of text field. There are two values: "dynamic" , which specifies a dynamic text field that cannot be edited by the user, and "input" , which sp...

  • Page 931

    Textfield._url 931 textfield._url availability flash player 6. Usage my_txt . _url:string description read-only property; retrieves the url of the swf file that created the text field. Example the following example retrieves the url of the swf file that created the text field, and a swf file that lo...

  • Page 932

    932 chapter 2: actionscript language reference textfield.Variable availability flash player 6. Usage my_txt . Variable:string description property; the name of the variable that the text field is associated with. The type of this property is string. Example the following example creates a text field...

  • Page 933

    Textfield._visible 933 textfield._visible availability flash player 6. Usage my_txt._visible:boolean description property; 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. Example the following ...

  • Page 934

    934 chapter 2: actionscript language reference textfield._width availability flash player 6. Usage my_txt._width:number description property; the width of the text field, in pixels. Example the following example creates two text fields that you can use to change the width and height of a third text ...

  • Page 935

    Textfield.Wordwrap 935 textfield.Wordwrap availability flash player 6. Usage my_txt.Wordwrap:boolean description property; a boolean value that indicates if the text field has word wrap. If the value of wordwrap is true , the text field has word wrap; if the value is false , the text field does not ...

  • Page 936

    936 chapter 2: actionscript language reference textfield._x availability flash player 6. Usage my_txt._x:number description property; 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 co...

  • Page 937

    Textfield._xmouse 937 textfield._xmouse availability flash player 6. Usage my_txt._xmouse:number description read-only property; returns the x coordinate of the mouse position relative to the text field. Example the following example creates three text fields on the stage. The mouse_txt instance dis...

  • Page 938

    938 chapter 2: actionscript language reference textfield._xscale availability flash player 6. Usage my_txt._xscale:number description property; determines the horizontal scale of the text field as applied from the registration point of the text field, expressed as a percentage. The default registrat...

  • Page 939

    Textfield._y 939 textfield._y availability flash player 6. Usage my_txt._y:number description property; the y coordinate of a text field relative to the local coordinates of the parent movie clip. If a text field is in the main timeline, then its coordinate system refers to the upper left corner of ...

  • Page 940

    940 chapter 2: actionscript language reference textfield._ymouse availability flash player 6. Usage my_txt._ymouse:number description read-only property; indicates the y coordinate of the mouse position relative to the text field. Example see the example for textfield._xmouse . See also textfield._x...

  • Page 941

    Textfield._yscale 941 textfield._yscale availability flash player 6. Usage my_txt._yscale:number description property; the vertical scale of the text field as applied from the registration point of the text field, expressed as a percentage. The default registration point is (0,0). Example see the ex...

  • Page 942: Chapter 2

    942 chapter 2: actionscript language reference textformat class availability flash player 6. Description the textformat class represents character formatting information. You must use the constructor new textformat() to create a textformat object before calling its methods. You can set textformat pa...

  • Page 943

    Textformat class 943 constructor for the textformat class availability flash player 6. Usage new textformat([font:string, [size:number, [color:number, [bold:boolean, [italic:boolean, [underline:boolean, [url:string, [target:string, [align:string, [leftmargin:number, [rightmargin:number, [indent:numb...

  • Page 944

    944 chapter 2: actionscript language reference leftmargin indicates the left margin of the paragraph, in points. Rightmargin indicates the right margin of the paragraph, in points. Indent an integer that indicates the indentation from the left margin to the first character in the paragraph. Leading ...

  • Page 945

    Textformat.Align 945 textformat.Align availability flash player 6. Usage my_fmt.Align:string description property; indicates the alignment of the paragraph, represented as a string. The alignment of the paragraph, represented as a string. If "left" , the paragraph is left-aligned. If "center" , the ...

  • Page 946

    946 chapter 2: actionscript language reference textformat.Blockindent availability flash player 6. Usage my_fmt.Blockindent:number description property; a number that indicates the block indentation in points. Block indentation is applied to an entire block of text; that is, to all lines of the text...

  • Page 947

    Textformat.Bold 947 textformat.Bold availability flash player 6. Usage my_fmt.Bold:boolean description property; 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 , then the text is boldface. ...

  • Page 948

    948 chapter 2: actionscript language reference textformat.Bullet availability flash player 6. Usage my_fmt.Bullet:boolean description property; a boolean value that indicates that the text is part of a bulleted list. In a bulleted list, each paragraph of text is indented. To the left of the first li...

  • Page 949

    Textformat.Color 949 textformat.Color availability flash player 6. Usage my_fmt.Color:number description property; indicates the color of text. A number containing three 8-bit rgb components; for example, 0xff0000 is red, and 0x00ff00 is green. Example the following example creates a text field and ...

  • Page 950

    950 chapter 2: actionscript language reference textformat.Font availability flash player 6. Usage my_fmt.Font:string description property; the name of the font for text in this text format, as a string. The default value is null , which indicates that the property is undefined. Example the following...

  • Page 951

    Textformat.Gettextextent() 951 textformat.Gettextextent() availability flash player 6. The optional width parameter is supported in flash player 7. Usage my_fmt.Gettextextent(text:string, [width:number]) : object parameters text a string. Width an optional number that represents the width, in pixels...

  • Page 952

    952 chapter 2: actionscript language reference the following figure illustrates these measurements. When setting up your textformat object, set all the attributes exactly as they will be set for the creation of the text field, including font name, font size, and leading. The default value for leadin...

  • Page 953

    Textformat.Gettextextent() 953 // create a textformat object. Var my_fmt:textformat = new textformat(); // specify formatting properties for the textformat object: my_fmt.Font = "arial"; my_fmt.Bold = true; my_fmt.Leading = 4; // the string of text to be displayed var texttodisplay:string = "macrome...

  • Page 954

    954 chapter 2: actionscript language reference textformat.Indent availability flash player 6. Usage my_fmt.Indent:number description property; 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 ...

  • Page 955

    Textformat.Italic 955 textformat.Italic availability flash player 6. Usage my_fmt.Italic:boolean description property; a boolean value that indicates whether text in this text format is italicized. The default value is null , which indicates that the property is undefined. Example the following exam...

  • Page 956

    956 chapter 2: actionscript language reference textformat.Leading availability flash player 6. Usage my_fmt.Leading:number description property; the amount of vertical space (called leading) between lines. The default value is null , which indicates that the property is undefined. Example the follow...

  • Page 957

    Textformat.Leftmargin 957 textformat.Leftmargin availability flash player 6. Usage my_fmt.Leftmargin:number description property; the left margin of the paragraph, in points. The default value is null , which indicates that the property is undefined. Example the following example creates a text fiel...

  • Page 958

    958 chapter 2: actionscript language reference textformat.Rightmargin availability flash player 6. Usage my_fmt.Rightmargin:number description property; the right margin of the paragraph, in points. The default value is null , which indicates that the property is undefined. Example the following exa...

  • Page 959

    Textformat.Size 959 textformat.Size availability flash player 6. Usage my_fmt.Size:number description property; the point size of text in this text format. The default value is null , which indicates that the property is undefined. Example the following example creates a text field and sets the text...

  • Page 960

    960 chapter 2: actionscript language reference textformat.Tabstops availability flash player 6. Usage my_fmt.Tabstops:array description property; 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...

  • Page 961

    Textformat.Target 961 textformat.Target availability flash player 6. Usage my_fmt.Target:string description property; indicates the target window where the hyperlink is displayed. If the target window is an empty string, the text is displayed in the default target window _self . You can choose a cus...

  • Page 962

    962 chapter 2: actionscript language reference textformat.Underline availability flash player 6. Usage my_fmt.Underline:boolean description property; a boolean value that indicates whether the text that uses this text format is underlined ( true ) or not ( false ). This underlining is similar to tha...

  • Page 963

    Textformat.Url 963 textformat.Url availability flash player 6. Usage my_fmt.Url:string description property; indicates the url that text in this text format hyperlinks to. If the url property is an empty string, the text does not have a hyperlink. The default value is null , which indicates that the...

  • Page 964: Chapter 2

    964 chapter 2: actionscript language reference textsnapshot object availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Description textsnapshot objects let you work with static text in a movie clip. You can use them, f...

  • Page 965

    Textsnapshot.Findtext() 965 textsnapshot.Findtext() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Findtext( startindex:number, texttofind:string, casesensitive:boolean ) : number parameters startind...

  • Page 966

    966 chapter 2: actionscript language reference textsnapshot.Getcount() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Getcount() : number parameters none. Returns an integer representing the number o...

  • Page 967

    Textsnapshot.Getselected() 967 textsnapshot.Getselected() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Getselected(from:number, to:number) : boolean parameters from an integer that indicates the po...

  • Page 968

    968 chapter 2: actionscript language reference textsnapshot.Getselectedtext() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Getselectedtext( [ includelineendings:boolean ] ) : string parameters incl...

  • Page 969

    Textsnapshot.Getselectedtext() 969 when you test the swf file, you see a colored rectangle around the specified characters. See also textsnapshot.Getselected().

  • Page 970

    970 chapter 2: actionscript language reference textsnapshot.Gettext() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Gettext(from:number, to:number [, includelineendings:boolean ] ) : string paramete...

  • Page 971

    Textsnapshot.Gettext() 971 trace(count); // output: 20 trace(thetext); // output: textsnapshot example see also textsnapshot.Getselectedtext().

  • Page 972

    972 chapter 2: actionscript language reference textsnapshot.Hittesttextnearpos() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Hittesttextnearpos(x:number, y:number [, maxdistance:number] ) : number...

  • Page 973

    Textsnapshot.Hittesttextnearpos() 973 var my_mc:movieclip = this; var my_ts:textsnapshot = my_mc.Gettextsnapshot(); my_mc.Onmousemove = function() { // find which character the mouse pointer is over (if any) var hitindex:number = my_ts.Hittesttextnearpos(_xmouse, _ymouse, 0); // deselect everything ...

  • Page 974

    974 chapter 2: actionscript language reference textsnapshot.Setselectcolor() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Setselectcolor(hexcolor:number); parameters hexcolor the color used for the...

  • Page 975

    Textsnapshot.Setselectcolor() 975 trace(thetext); // output: txt trace(firstcharisselected); // output: true trace(secondcharisselected); // output: false when you test the swf file, you see a colored rectangle around the specified characters..

  • Page 976

    976 chapter 2: actionscript language reference textsnapshot.Setselected() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Setselected(from:number, to:number, select:boolean) : void parameters from an ...

  • Page 977

    Textsnapshot.Setselected() 977 note: if characters don’t appear to be selected when you run the code, you must also place a dynamic text field on the stage. See “description” in this entry. // this example assumes that the movie clip contains // the static text "textsnapshot example" var my_snap:tex...

  • Page 978: Chapter 2

    978 chapter 2: actionscript language reference this availability flash player 5. Usage this description identifier; references an object or movie clip instance. When a script executes, this references the movie clip instance that contains the script. When a method is called, this contains a referenc...

  • Page 979

    This 979 } } inside the fla or as file, add the following actionscript: var obj:simple = new simple(); obj.Num = 0; obj.Func = function() { return true; }; obj.Callfunc(); // output: true you get a syntax error when you use the incorrect version of simple.As. Example in the following example, the ke...

  • Page 980: Chapter 2

    980 chapter 2: actionscript language reference throw availability flash player 7. Usage throw expression description statement; 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 thr...

  • Page 981

    Throw 981 if (email.Indexof("@") == -1) { throw new invalidemailaddress(); } } try { checkemail("joe smith"); } catch (e) { this.Createtextfield("error_txt", this.Getnexthighestdepth(), 0, 0, 100, 22); error_txt.Autosize = true; error_txt.Text = e.Tostring(); } see also error class , try..Catch..Fin...

  • Page 982: Chapter 2

    982 chapter 2: actionscript language reference trace() availability flash player 4. Usage trace(expression) parameters expression an expression to evaluate. When a swf file is opened in the flash authoring tool (using the test movie command), the value of the expression parameter is displayed in the...

  • Page 983: Chapter 2

    True 983 true availability flash player 5. Usage true description 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" . Example the following example shows th...

  • Page 984: Chapter 2

    984 chapter 2: actionscript language reference try..Catch..Finally availability flash player 7. Usage try { // ... Try block ... } finally { // ... Finally block ... } try { // ... Try block ... } catch(error[:errortype1]) { // ... Catch block ... } [catch(error[:errortypen]) { // ... Catch block .....

  • Page 985

    Try..Catch..Finally 985 if an error is thrown within a function, and the function does not include a catch handler, then the actionscript interpreter exits that function, as well as any caller functions, until a catch block is found. During this process, finally handlers are called at all levels. Ex...

  • Page 986

    986 chapter 2: actionscript language reference the following example demonstrates a try..Catch statement. The code within the try block is executed. If an exception is thrown by any code within the try block, control passes to the catch block, which shows the error message in a text field using the ...

  • Page 987

    Try..Catch..Finally 987 } } 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(); ...

  • Page 988: Chapter 2

    988 chapter 2: actionscript language reference typeof availability flash player 5. Usage typeof(expression) : string parameters expression a string, movie clip, button, object, or function. Description operator; a unary operator placed before a single parameter. The typeof operator causes the flash ...

  • Page 989: Chapter 2

    Undefined 989 undefined availability flash player 5. Usage undefined parameters none. Returns nothing. Description a special value, usually used to indicate that a variable has not yet been assigned a value. A reference to an undefined value returns the special value undefined . The actionscript cod...

  • Page 990

    990 chapter 2: actionscript language reference the following result is displayed in the output panel. The value of x is undefined x is undefined typeof (x) is undefined null and undefined are equal.

  • Page 991: Chapter 2

    Unescape() 991 unescape() availability flash player 5. Usage unescape(x:string) : string parameters x a string with hexadecimal sequences to escape. Returns a string decoded from a url-encoded parameter. Description function; evaluates the parameter x as a string, decodes the string from url-encoded...

  • Page 992: Chapter 2

    992 chapter 2: actionscript language reference unloadmovie() availability flash player 3. Usage unloadmovie(target:movieclip) : void unloadmovie(target:string) : void parameters target the target path of a movie clip. Returns none. Description function; removes a movie clip that was loaded by means ...

  • Page 993: Chapter 2

    Unloadmovienum() 993 unloadmovienum() availability flash player 3. Usage unloadmovienum(level:number) : void parameters level the level ( _leveln ) of a loaded movie. Returns nothing. Description function; removes a swf or image that was loaded by means of loadmovienum() from flash player. To unload...

  • Page 994: Chapter 2

    994 chapter 2: actionscript language reference updateafterevent() availability flash player 5. Usage updateafterevent() : void parameters none. Returns nothing. Description function; updates the display (independent of the frames per second set for the movie) when you call it within an onclipevent()...

  • Page 995: Chapter 2

    Var 995 var availability flash player 5. Usage var variablename [= value1][...,variablenamen [=valuen]] parameters variablename an identifier. Value the value assigned to the variable. Returns nothing. Description statement; used to declare local or timeline variables. If you declare variables insid...

  • Page 996: Chapter 2

    996 chapter 2: actionscript language reference video class availability flash player 6; the ability to play flash video (flv) files was added in flash player 7. Description the video class lets you display live streaming video on the stage without embedding it in your swf file. You capture the video...

  • Page 997

    Video.Attachvideo() 997 video.Attachvideo() availability flash player 6; the ability to work with flash video (flv) files was added in flash player 7. Usage my_video.Attachvideo(source:object) : void parameters source a camera object that is capturing video data or a netstream object. To drop the co...

  • Page 998

    998 chapter 2: actionscript language reference video.Clear() availability flash player 6. Usage my_video.Clear() : void parameters none. Returns nothing. Description method; clears the image currently displayed in the video object. This is useful when, for example, you want to display standby inform...

  • Page 999

    Video.Deblocking 999 video.Deblocking availability flash player 6. Usage my_video.Deblocking:number description property; a number that specifies the behavior for the deblocking filter that the video compressor applies as needed when streaming the video. The following are acceptable values: • 0 (the...

  • Page 1000

    1000 chapter 2: actionscript language reference video.Height availability flash player 6. Usage my_video.Height:number description property (read-only); an integer specifying the height of the video stream, in pixels. For live streams, this value is the same as the camera.Height property of the came...

  • Page 1001

    Video.Height 1001 my_mc._height = my_mc.My_video.Height; }; see also movieclip._height , video.Width.

  • Page 1002

    1002 chapter 2: actionscript language reference video.Smoothing availability flash player 6. Usage my_video.Smoothing:boolean description property; a boolean value that specifies whether the video should be smoothed (interpolated) when it is scaled. For smoothing to work, the player must be in high-...

  • Page 1003

    Video.Width 1003 video.Width availability flash player 6. Usage my_video.Width:number description property (read-only); an integer specifying the width of the video stream, in pixels. For live streams, this value is the same as the camera.Width property of the camera object that is capturing the vid...

  • Page 1004: Chapter 2

    1004 chapter 2: actionscript language reference void availability flash player 5. Usage void (expression) function functionname():void {} description usage 1: operator; a unary operator that discards the expression value and returns an undefined value. The void operator is often used in comparisons ...

  • Page 1005: Chapter 2

    While 1005 while availability flash player 4. Usage while(condition) { statement(s); } parameters condition an expression that evaluates to true or false . Statement(s) the instructions to execute if the condition evaluates to true . Returns nothing. Description statement; evaluates a condition and ...

  • Page 1006

    1006 chapter 2: actionscript language reference i += 3; } the following result is displayed in the output panel. 0 3 6 9 12 15 18 see also do while , continue , for , for..In.

  • Page 1007: Chapter 2

    With 1007 with availability flash player 5. Usage with (object:object) { statement(s); } parameters object an instance of an actionscript object or movie clip. Statement(s) an action or group of actions enclosed in curly braces ({}). Returns nothing. Description statement; lets you specify an object...

  • Page 1008

    1008 chapter 2: actionscript language reference instead of using with() , you can use direct paths. If you find that paths are long and cumbersome to type, you can create a local variable and store the path in the variable, which you can then reuse in your code, as shown in the following actionscrip...

  • Page 1009: Chapter 2

    Xml class 1009 xml class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description use the methods and properties of the xml class to load, parse, send, build, and manipulate xml document trees. You must use the constructor new xml(...

  • Page 1010

    1010 chapter 2: actionscript language reference property summary for the xml class collections summary for the xml class event handler summary for the xml class property description xml.Contenttype the mime type transmitted to the server. Xml.Doctypedecl sets and returns information about an xml doc...

  • Page 1011

    Xml class 1011 constructor for the xml class availability flash player 5. Usage new xml([source:string]) : xml parameters source a string; the xml text parsed to create the new xml object. Returns a reference to an xml object. Description constructor; creates a new xml object. You must use the const...

  • Page 1012

    1012 chapter 2: actionscript language reference xml.Addrequestheader() availability flash player 6. Usage my_xml.Addrequestheader(headername:string, headervalue:string) : void my_xml.Addrequestheader(["headername_1":string, "headervalue_1":string ... "headername_n":string, "headervalue_n":string]) :...

  • Page 1013

    Xml.Appendchild() 1013 xml.Appendchild() availability flash player 5. Usage my_xml.Appendchild(childnode:xmlnode) : void parameters childnode an xmlnode that represents the node to be moved from its current location to the child list of the my_xml object. Returns nothing. Description method; appends...

  • Page 1014

    1014 chapter 2: actionscript language reference var clone:xmlnode = doc2.Firstchild.Clonenode(true); doc1.Appendchild(clone); trace ("doc1: " + doc1); // output: doc1: trace ("doc2: " + doc2); // output: doc2: // create a new node to append to root node (named clone) of doc1 var newnode:xmlnode = do...

  • Page 1015

    Xml.Attributes 1015 xml.Attributes availability flash player 5. Usage my_xml.Attributes:array description property; an associative array that contains all the attributes of the specified xml object. Associative arrays use keys as indexes, instead of the simple ordinal integer indexes used by regular...

  • Page 1016

    1016 chapter 2: actionscript language reference xml.Childnodes availability flash player 5. Usage my_xml.Childnodes:array description read-only property; an array of the specified xml object’s children. Each element in the array is a reference to an xml object that represents a child node. This is a...

  • Page 1017

    Xml.Clonenode() 1017 xml.Clonenode() availability flash player 5. Usage my_xml.Clonenode(deep:boolean) : xmlnode parameters deep a boolean value; if set to true , the children of the specified xml object will be recursively cloned. Returns an xmlnode object. Description method; constructs and return...

  • Page 1018

    1018 chapter 2: actionscript language reference // 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 ...

  • Page 1019

    Xml.Contenttype 1019 xml.Contenttype availability flash player 6. Usage my_xml.Contenttype:string description property; the mime content type that is sent to the server when you call the xml.Send() or xml.Sendandload() method. The default is application/x-www-form-urlencoded , which is the standard ...

  • Page 1020

    1020 chapter 2: actionscript language reference xml.Createelement() availability flash player 5. Usage my_xml.Createelement(name:string) : xmlnode parameters name the tag name of the xml element being created. Returns an xmlnode; an xml element. Description method; creates a new xml element with the...

  • Page 1021

    Xml.Createtextnode() 1021 xml.Createtextnode() availability flash player 5. Usage my_xml.Createtextnode(text:string) : xmlnode parameters text a string; the text used to create the new text node. Returns an xmlnode. Description method; creates a new xml text node with the specified text. The new nod...

  • Page 1022

    1022 chapter 2: actionscript language reference see also xml.Createelement().

  • Page 1023

    Xml.Doctypedecl 1023 xml.Doctypedecl availability flash player 5. Usage my_xml . Doctypedecl:string description property; specifies information about the xml document’s doctype declaration. After the xml text has been parsed into an xml object, the xml.Doctypedecl property of the xml object is set t...

  • Page 1024

    1024 chapter 2: actionscript language reference xml.Firstchild availability flash player 5. Usage my_xml.Firstchild:xmlnode description read-only property; evaluates the specified xml object and references the first child in the parent node’s child list. This property is null if the node does not ha...

  • Page 1025

    Xml.Firstchild 1025 for (var stringnode:xmlnode = childnode.Firstchild; stringnode != null; stringnode = stringnode.Nextsibling, j++) { masterarray[i][j] = stringnode.Firstchild.Nodevalue; } to view the entire script, see xml_languagepicker.Fla in the helpexamples folder: • windows: \program files\m...

  • Page 1026

    1026 chapter 2: actionscript language reference xml.Getbytesloaded() availability flash player 6. Usage my_xml.Getbytesloaded() : number parameters none. Returns an integer that indicates the number of bytes loaded. Description method; returns the number of bytes loaded (streamed) for the xml docume...

  • Page 1027

    Xml.Getbytestotal() 1027 xml.Getbytestotal() availability flash player 6. Usage my_xml.Getbytestotal() : number parameters none. Returns an integer. Description method; returns the size, in bytes, of the xml document. Example see example for xml.Getbytesloaded() . See also xml.Getbytesloaded().

  • Page 1028

    1028 chapter 2: actionscript language reference xml.Haschildnodes() availability flash player 5. Usage my_xml.Haschildnodes() : boolean parameters none. Returns a boolean value. Description method; returns true if the specified xml object has child nodes; otherwise, returns false . Example the follo...

  • Page 1029

    Xml.Ignorewhite 1029 xml.Ignorewhite availability flash player 5. Usage my_xml.Ignorewhite:boolean xml.Prototype.Ignorewhite:boolean parameters boolean a boolean ( true or false ) value. Description property; default setting is false . When set to true , text nodes that contain only white space are ...

  • Page 1030

    1030 chapter 2: actionscript language reference /* output (line breaks added for clarity): ceramic tile linoleum */ if you then change the setting of flooring.Ignorewhite to false , or simply remove that line of code entirely, the fourteen space characters in the foyer tag will be preserved: ... // ...

  • Page 1031

    Xml.Insertbefore() 1031 xml.Insertbefore() availability flash player 5. Usage my_xml.Insertbefore(childnode:xmlnode, beforenode:xmlnode) : void parameters childnode the xmlnode object to be inserted. Beforenode the xmlnode object before the insertion point for the childnode . Returns nothing. Descri...

  • Page 1032

    1032 chapter 2: actionscript language reference xml.Lastchild availability flash player 5. Usage my_xml.Lastchild:xmlnode description read-only property; an xmlnode value that references the last child in the node’s child list. The xml.Lastchild property is null if the node does not have children. T...

  • Page 1033

    Xml.Lastchild 1033 the following example creates a new xml packet and uses the xml.Lastchild property to iterate through the child nodes of the root node: // create a new xml document var doc:xml = new xml(" rootnode>"); var rootnode:xmlnode = doc.Firstchild; // use lastchild to iterate through the ...

  • Page 1034

    1034 chapter 2: actionscript language reference xml.Load() availability flash player 5; behavior changed in flash player 7. Usage my_xml.Load(url:string) : void parameters url a string that represents the url where the xml document to be loaded is located. If the swf file that issues this call is ru...

  • Page 1035

    Xml.Load() 1035 flooring.Ignorewhite = true; // after loading is complete, trace the xml object flooring.Onload = function(success) { trace(flooring); }; // load the xml into the flooring object flooring.Load("flooring.Xml"); for the contents of the flooring.Xml file, and the output that this exampl...

  • Page 1036

    1036 chapter 2: actionscript language reference xml.Loaded availability flash player 5. Usage my_xml.Loaded:boolean description read-only property; a boolean value that is true if the document-loading process initiated by the xml.Load() call has completed successfully; otherwise, it is false . Examp...

  • Page 1037

    Xml.Nextsibling 1037 xml.Nextsibling availability flash player 5. Usage my_xml.Nextsibling:xmlnode description read-only property; 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 can...

  • Page 1038

    1038 chapter 2: actionscript language reference xml.Nodename availability flash player 5. Usage my_xml.Nodename:string description property; a string representing the node name of the xml object. If the xml object is an xml element ( nodetype == 1), nodename is the name of the tag that represents th...

  • Page 1039

    Xml.Nodename 1039 trace(anode.Nodename+":\t"+anode.Firstchild.Nodevalue); } } } the following node names are displayed in the output panel: output: username:hank password:rudolph see also xml.Nodetype.

  • Page 1040

    1040 chapter 2: actionscript language reference xml.Nodetype availability flash player 5. Usage my_xml.Nodetype:number description read-only property; 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 leve...

  • Page 1041

    Xml.Nodetype 1041 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 xml.Nodevalue.

  • Page 1042

    1042 chapter 2: actionscript language reference xml.Nodevalue availability flash player 5. Usage my_xml.Nodevalue:node description property; the node value of the xml object. If the xml object is a text node, the nodetype is 3, and the nodevalue is the text of the node. If the xml object is an xml e...

  • Page 1043

    Xml.Nodevalue 1043 trace("using firstchild.Nodevalue:"); for (var i = 0; i trace("\t"+my_xml.Firstchild.Childnodes[i].Firstchild.Nodevalue); } the following information is displayed in the output panel: using firstchild: morton good&evil using firstchild.Nodevalue: morton good&evil see also xml.Node...

  • Page 1044

    1044 chapter 2: actionscript language reference xml.Ondata availability flash player 5. Usage my_xml.Ondata = function(src:string) { // your statements here } parameters src a string or undefined ; the raw data, usually in xml format, that is sent by the server. Returns nothing. Description event ha...

  • Page 1045

    Xml.Onload 1045 xml.Onload availability flash player 5. Usage my_xml.Onload = function (success:boolean) { //your statements here } parameters success a boolean value that evaluates to true if the xml object is successfully loaded with a xml.Load() or xml.Sendandload() operation; otherwise, it is fa...

  • Page 1046

    1046 chapter 2: actionscript language reference xml.Parentnode availability flash player 5. Usage my_xml.Parentnode:xmlnode description read-only property; an xmlnode value that references the parent node of the specified xml object, or returns null if the node has no parent. This is a read-only pro...

  • Page 1047

    Xml.Parsexml() 1047 xml.Parsexml() availability flash player 5. Usage my_xml.Parsexml(source:string) : void parameters source a string that represents the xml text to be parsed and passed to the specified xml object. Returns nothing. Description method; parses the xml text specified in the source pa...

  • Page 1048

    1048 chapter 2: actionscript language reference xml.Previoussibling availability flash player 5. Usage my_xml.Previoussibling:xmlnode description read-only property; an xmlnode value that references the previous sibling in the parent node’s child list. The property has a value of null if the node do...

  • Page 1049

    Xml.Removenode() 1049 xml.Removenode() availability flash player 5. Usage my_xml.Removenode() : void parameters none. Returns nothing. Description method; removes the specified xml object from its parent. Also deletes all descendants of the node. Example the following example creates an xml packet, ...

  • Page 1050

    1050 chapter 2: actionscript language reference xml.Send() availability flash player 5. Usage my_xml.Send(url:string, [window:string]) : void parameters url string; the destination url for the specified xml object. Window string; the browser window to show data that the server returns: • _self speci...

  • Page 1051

    Xml.Sendandload() 1051 xml.Sendandload() availability flash player 5; behavior changed in flash player 7. Usage my_xml.Sendandload(url:string, targetxmlobject:xml) : void parameters url a string; the destination url for the specified xml object. If the swf file issuing this call is running in a web ...

  • Page 1052

    1052 chapter 2: actionscript language reference var login_str:string = " password=\""+password_txt.Text+"\" />"; var my_xml:xml = new xml(login_str); var myloginreply_xml:xml = new xml(); myloginreply_xml.Ignorewhite = true; myloginreply_xml.Onload = myonload; my_xml.Sendandload("http://www.Flash-mx...

  • Page 1053

    Xml.Status 1053 xml.Status availability flash player 5. Usage my_xml.Status:number description property; 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: • ...

  • Page 1054

    1054 chapter 2: actionscript language reference 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 = ...

  • Page 1055

    Xml.Tostring() 1055 xml.Tostring() availability flash player 5. Usage my_xml.Tostring() : string parameters none. Returns a string. Description method; evaluates the specified xml object, constructs a textual representation of the xml structure, including the node, children, and attributes, and retu...

  • Page 1056

    1056 chapter 2: actionscript language reference xml.Xmldecl availability flash player 5. Usage my_xml.Xmldecl:string description property; a string that specifies information about a document’s xml declaration. After the xml document is parsed into an xml object, this property is set to the text of ...

  • Page 1057

    Xml.Xmldecl 1057 see also xml.Doctypedecl , xml.Tostring().

  • Page 1058: Chapter 2

    1058 chapter 2: actionscript language reference xmlnode class availability flash player 5. Description an xml document is represented in flash by the xml class. Each element of the hierarchical document is represented by an xmlnode object. The xmlnode class supports the following properties, methods...

  • Page 1059: Chapter 2

    Xmlsocket class 1059 xmlsocket class availability flash player 5. Description the xmlsocket class implements client sockets that let the computer running flash player communicate with a server computer identified by an ip address or domain name. The xmlsocket class is useful for client-server applic...

  • Page 1060

    1060 chapter 2: actionscript language reference method summary for the xmlsocket class event handler summary for the xmlsocket class constructor for the xmlsocket class availability flash player 5. Usage new xmlsocket() : xmlsocket parameters none. Returns a reference to an xmlsocket object. Descrip...

  • Page 1061

    Xmlsocket.Close() 1061 xmlsocket.Close() availability flash player 5. Usage myxmlsocket.Close() : void parameters none. Returns nothing. Description method; closes the connection specified by xmlsocket object. Example the following simple example creates an xmlsocket object, attempts to connect to t...

  • Page 1062

    1062 chapter 2: actionscript language reference xmlsocket.Connect() availability flash player 5; behavior changed in flash player 7. Usage myxmlsocket.Connect(host:string, port:number) : boolean parameters host string; a fully qualified dns domain name or an ip address in the form aaa.Bbb.Ccc.Ddd. Y...

  • Page 1063

    Xmlsocket.Connect() 1063 if xmlsocket.Connect() returns a value of true , the initial stage of the connection process is successful; later, the xmlsocket.Onconnect method is invoked to determine whether the final connection succeeded or failed. If xmlsocket.Connect() returns false , a connection cou...

  • Page 1064

    1064 chapter 2: actionscript language reference xmlsocket.Onclose availability flash player 5. Usage myxmlsocket.Onclose = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked only when an open connection is closed by the server. The default imp...

  • Page 1065

    Xmlsocket.Onconnect 1065 xmlsocket.Onconnect availability flash player 5. Usage myxmlsocket.Onconnect = function(success:boolean) { // your statements here } parameters success a boolean value indicating whether a socket connection is successfully established ( true or false ). Returns nothing. Desc...

  • Page 1066

    1066 chapter 2: actionscript language reference if (!Socket.Connect(null, 2000)) { gotoandstop("connectionfailed"); } else { gotoandstop("waitforconnection"); } see also function , xmlsocket.Connect().

  • Page 1067

    Xmlsocket.Ondata 1067 xmlsocket.Ondata availability flash player 5. Usage xmlsocket.Ondata = function(src:string) { // your statements here } parameters src a string containing the data sent by the server. Returns nothing. Description event handler; invoked when a message has been downloaded from th...

  • Page 1068

    1068 chapter 2: actionscript language reference xmlsocket.Onxml availability flash player 5. Usage myxmlsocket.Onxml = function(object:xml) { // your statements here } parameter object an xml object that contains a parsed xml document received from a server. Returns nothing. Description event handle...

  • Page 1069

    Xmlsocket.Send() 1069 xmlsocket.Send() availability flash player 5. Usage myxmlsocket.Send(object:xml) : void parameters object an xml object or other data to transmit to the server. Returns nothing. Description method; converts the xml object or data specified in the object parameter to a string an...

  • Page 1070

    1070 chapter 2: actionscript language reference.

  • Page 1071: Appendix

    1071 appendix deprecated language elements the evolution of actionscript has deprecated many elements of the language. This appendix lists the deprecated items in alphabetical order and suggests alternatives..

  • Page 1072

    1072 appendix: deprecated language elements add availability flash player 4. This function was deprecated in flash 5; macromedia recommends you use the add ( + ) operator when creating content for flash player 5 or later. Usage string1 add string2 parameters string1, string2 a string. Returns nothin...

  • Page 1073

    And 1073 and availability flash player 4. This function was deprecated in flash 5; macromedia recommends that you use the logical and ( &&) operator. Usage condition1 and condition2 parameters condition1,condition2 conditions or expressions that evaluate to true or false . Returns nothing. Descripti...

  • Page 1074

    1074 appendix: deprecated language elements button._highquality availability flash player 6. The global version of this function was deprecated in flash 5 in favor of _quality . Usage my_btn._highquality:number description property (global); specifies the level of anti-aliasing applied to the curren...

  • Page 1075

    Call() 1075 call() availability flash player 4. This action was deprecated in flash 5 in favor of the function statement. Usage call(frame) parameters frame the label or number of a frame in the timeline. Returns nothing. Description action; executes the script in the called frame without moving the...

  • Page 1076

    1076 appendix: deprecated language elements chr availability flash player 4. This function was deprecated in flash 5 in favor of string.Fromcharcode() . Usage chr(number) parameters number an ascii code number. Returns nothing. Description string function; converts ascii code numbers to characters. ...

  • Page 1077

    Eq (equal — string specific) 1077 eq (equal — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the == (equality) operator. Usage expression1 eq expression2 parameters expression1, expression2 numbers, strings, or variables. Returns nothing. Descriptio...

  • Page 1078

    1078 appendix: deprecated language elements ge (greater than or equal to — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the >= (greater than or equal to) operator. Usage expression1 ge expression2 parameters expression1 , expression2 numbers, stri...

  • Page 1079

    Gt (greater than — string specific) 1079 gt (greater than — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the > (greater than) operator. Usage expression1 gt expression2 parameters expression1, expression2 numbers, strings, or variables. Descriptio...

  • Page 1080

    1080 appendix: deprecated language elements _highquality availability flash player 4. This function was deprecated in flash 5 in favor of _quality . Usage _highquality description property (global); specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) to app...

  • Page 1081

    (inequality) 1081 (inequality) availability flash 2 . This operator was deprecated in flash 5; macromedia recommends that you use the != (inequality) operator. Usage expression1 expression2 parameters expression1,expression2 a number, string, boolean value, variable, object, array, or function. Retu...

  • Page 1082

    1082 appendix: deprecated language elements ifframeloaded availability flash player 3. This action was deprecated in flash 5; macromedia recommends that you use the movieclip._framesloaded property. Usage ifframeloaded([scene,] frame) { statement(s); } parameters scene an optional string that specif...

  • Page 1083

    Int 1083 int availability flash player 4. This function was deprecated in flash 5 in favor of math.Round() . Usage int(value) parameters value a number to be rounded to an integer. Returns nothing. Description function; converts a decimal number to an integer value by truncating the decimal value. T...

  • Page 1084

    1084 appendix: deprecated language elements le (less than or equal to — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the operator. Usage expression1 le expression2 parameters expression1,expression2 numbers, strings, or variables. Returns nothing....

  • Page 1085

    Length 1085 length availability flash player 4. This function, along with all the string functions, was deprecated in flash 5. Macromedia recommends that you use the methods of the string class and the string.Length property to perform the same operations. Usage length(expression) length(variable) p...

  • Page 1086

    1086 appendix: deprecated language elements lt (less than — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the operator. Usage expression1 lt expression2 parameters expression1 , expression2 numbers, strings, or variables. Description operator (comp...

  • Page 1087

    Maxscroll 1087 maxscroll availability flash player 4. This function was deprecated in favor of the textfield.Maxscroll property. Usage variable_name.Maxscroll description read-only property; indicates the line number of the top line of visible text in a text field when the bottom line in the field i...

  • Page 1088

    1088 appendix: deprecated language elements mbchr availability flash player 4. This function was deprecated in favor of the string.Fromcharcode() method. Usage mbchr(number) parameters number the number to convert to a multibyte character. Returns a string. Description string function; converts an a...

  • Page 1089

    Mblength 1089 mblength availability flash player 4. This function was deprecated in favor of the string class . Usage mblength(string) parameters string a string. Returns a number. Description string function; returns the length of the multibyte character string..

  • Page 1090

    1090 appendix: deprecated language elements mbord availability flash player 4. This function was deprecated in flash 5 in favor of string.Charcodeat() . Usage mbord(character) parameters character the character to convert to a multibyte number. Returns a number. Description string function; converts...

  • Page 1091

    Mbsubstring 1091 mbsubstring availability flash player 4. This function was deprecated in flash 5 in favor of string.Substr() . Usage mbsubstring(value, index, count) parameters value the multibyte string from which to extract a new multibyte string. Index the number of the first character to extrac...

  • Page 1092

    1092 appendix: deprecated language elements movieclip._highquality availability flash player 6. This function was deprecated in favor of _quality . Usage my_mc._highquality:number description property; specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) to ...

  • Page 1093

    Ne (not equal — string specific) 1093 ne (not equal — string specific) availability flash player 4. This operator was deprecated in favor of the != (inequality) operator. Usage expression1 ne expression2 parameters expression1, expression2 numbers, strings, or variables. Returns a boolean value. Des...

  • Page 1094

    1094 appendix: deprecated language elements not availability flash player 4. This operator was deprecated in favor of the ! (logical not) operator. Usage not expression parameters expression a variable or other expression that converts to a boolean value. Description operator; performs a logical not...

  • Page 1095

    (logical or) operator. Usage condition1 or condition2 parameters condition1,2 an expression that evaluates to true or false . Returns nothing. Description operator; evaluates condition1 and condition2 , and if either e...

  • Page 1096

    1096 appendix: deprecated language elements ord availability flash player 4. This function was deprecated in favor of the methods and properties of the string class. Usage ord(character) parameters character the character to convert to an ascii code number. Returns nothing. Description string functi...

  • Page 1097

    Random 1097 random availability flash player 4. This function was deprecated in flash 5 in favor of math.Random() . Usage random(value) parameters value an integer. Returns an integer. Description function; returns a random integer between 0 and one less than the integer specified in the value param...

  • Page 1098

    1098 appendix: deprecated language elements scroll availability flash player 4. This property was deprecated in favor of the scroll property of the textfield class. Usage textfieldvariablename.Scroll = x description property; controls the display of information in a text field associated with a vari...

  • Page 1099

    Substring 1099 substring availability flash player 4. This function was deprecated in favor of string.Substr() . Usage substring("string", index, count) parameters string the string from which to extract the new string. Index the number of the first character to extract. Count the number of characte...

  • Page 1100

    1100 appendix: deprecated language elements telltarget availability flash player 3. This function was deprecated in flash 5; macromedia recommends that you use dot (.) notation and the with statement. Usage telltarget("target") { statement(s); } parameters target a string that specifies the target p...

  • Page 1101

    Telltarget 1101 if you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement: on(release) { with(_parent.Ball) { gotoandplay(2); _alpha = 15; _xscale = 50; _yscale = 50; } } see also with.

  • Page 1102

    1102 appendix: deprecated language elements textfield._highquality availability flash player 6. This function was deprecated in favor of _quality . Usage my_txt._highquality description property (global); specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) ...

  • Page 1103

    Togglehighquality() 1103 togglehighquality() availability flash 2. This function was deprecated in flash 5 in favor of _quality . Usage togglehighquality() parameters none. Returns nothing. Description function; turns anti-aliasing on and off in flash player. Anti-aliasing smooths the edges of objec...

  • Page 1104

    1104 appendix: deprecated language elements.