Page 2
Open Sesame!, Roundtrip, Roundtrip HTML, Shockwave, Sitespring, SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, and Xtra are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc.
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 manual lists all ActionScript elements—operators, keywords, statements, actions, properties,...
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 or Macromedia Flash MX Professional 2004 to create content for Flash Player 6, you can use only ActionScript elements that are available to Flash Player 6.
A set of ActionScript example files can be found in the HelpExamples folder in the Flash installation directory. Typical paths to this folder are: • Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\ • Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/ The HelpExamples folder contains a set of FLA files that are complete projects with working ActionScript code.
CHAPTER 2 ActionScript Language Reference –– (decrement) Availability Flash Player 4. Usage ––expression expression–– Parameters A number or a variable that evaluates to a number. expression Returns A number. Description Operator (arithmetic); a pre-decrement and post-decrement unary operator that subtracts 1 from .
Page 26
The following example loops from 10 to 1, and each iteration of the loop decreases the counter variable by 1. for (var i = 10; i>0; i--) { trace(i); Chapter 2: ActionScript Language Reference...
++ (increment) Availability Flash Player 4. Usage ++expression expression++ Parameters A number or a variable that evaluates to a number. expression Returns A number. Description Operator (arithmetic); a pre-increment and post-increment unary operator that adds 1 to . The can be a variable, element in an array, or property of an object. expression expression The pre-increment form of the operator (...
Page 28
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<10) { a.push(++i); trace(a.toString());//traces: 1,2,3,4,5,6,7,8,9,10 This example also uses ++ as a pre-increment operator. var a:Array = [];...
! (logical NOT) Availability Flash Player 4. Usage !expression Parameters An expression or a variable that evaluates to a Boolean value. expression Returns A Boolean value. Description Operator (logical); inverts the Boolean value of a variable or expression. If is a expression variable with the absolute or converted value , the value of...
!= (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 equal to , the result is . As with the equality ( ) operator, the definition of expression2 false...
Page 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: true false The following example illustrates comparison by reference with two arrays: var a:Array = [ 1, 2, 3 ];...
!== (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 performs the same as the inequality operator except that data types are not converted. For more information, see “Automatic data typing”...
% (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.
%= (modulo assignment) Availability Flash Player 4. Usage expression1 %= expression2 Parameters None. Returns A number. Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 % . The following two expressions are equivalent: expression2 x %= y x = x % y For more information, see “Operator precedence and associativity”...
& (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.
&& (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 (the expression on the left side of the operator) and returns if the expression1 false...
&= (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 the value of . For example, the expression1 expression1 & expression2 following two expressions are equivalent: x &= y;...
() (parentheses) Availability Flash Player 4. Usage (expression1 [, expression2]) (expression1, expression2) function(parameter1,..., parameterN) Parameters Numbers, strings, variables, or text. expression1, expression2 The function to be performed on the contents of the parentheses. function A series of parameters to execute before the results are passed as parameter1...parameterN parameters to the function outside the parentheses.
Page 42
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 function traceParameter(param):Void { trace(param);...
– (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 the sign of the numerical expression Usage 2: When used for subtracting, it performs an arithmetic subtraction on two numerical expressions, subtracting...
* (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 product is an integer. If either or both expressions are floating-point numbers, the product is a floating-point number.
*= (multiplication assignment) Availability Flash Player 4. Usage expression1 *= expression2 Parameters None. Returns The value of . If an expression cannot be converted to a numeric expression1 * expression2 value, it returns (not a number). Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 *...
, (comma) Availability Flash Player 4. Usage (expression1, expression2 [, expressionN...]) Parameters None. Returns The value of , and so on. expression1 expression2 Description Operator; evaluates , then , and so on. This operator is primarily used expression1 expression2 with the loop statement and is often used with the parentheses () operator.
Page 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 returns the value of the last expression in the series: var v:Number = 0;...
. (dot) Availability Flash Player 4. Usage object.property_or_method instancename.variable instancename.childinstance instancename.childinstance.variable Parameters An instance of a class. The object can be an instance of any of the built-in ActionScript object classes or a custom class. This parameter is always to the left of the dot (.) operator. The name of a property or method associated with an object.
Page 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 targeting instances within the SWF file and when you need to set properties and values for those instances. .
: (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.0 and Flash Player 6 or later in the Flash tab of your FLA file’s Publish Settings dialog box.
Page 51
Usage 2: The following example shows how to specify a function’s parameter type by defining a function named that takes a parameter named of type Number: randomInt() integer function randomInt(integer:Number):Number { return Math.round(Math.random()*integer); trace(randomInt(8)); Usage 3: The following example defines a function named that takes a parameter squareRoot() named...
?: (conditional) Availability Flash Player 4. Usage expression1 ? expression2 : expression3 Parameters An expression that evaluates to a Boolean value; usually a comparison expression, expression1 such as x < 5 Values of any type. expression2 expression3 Returns The value of expression2 expression3 Description...
/ (division) Availability Flash Player 4. Usage expression1 / expression2 Parameters A number or a variable that evaluates to a number. expression Returns A floating-point number. Description Operator (arithmetic); divides . The result of the division expression1 expression2 operation is a double-precision floating-point number. For more information, see “Operator precedence and associativity”...
// (comment delimiter) Availability Flash 1. Usage // comment Parameters Any characters. comment Returns Nothing. Description Comment; indicates the beginning of a script comment. Any characters that appear between the comment delimiter ( and the end-of-line character are interpreted as a comment and ignored by the ActionScript interpreter.
/* (comment delimiter) Availability Flash Player 5. Usage /* comment */ comment comment Parameters Any characters. comment Returns Nothing. Description Comment; indicates one or more lines of script comments. Any characters that appear between the opening comment tag ( ) and the closing comment tag ( ), are interpreted as a comment and ignored by the ActionScript interpreter.
/= (division assignment) Availability Flash Player 4. Usage expression1 /= expression2 Parameters A number or a variable that evaluates to a number. expression1,expression2 Returns A number. Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 / . For example, the following two statements are equivalent: expression2 x /= y x = x / y...
[] (array access) Availability Flash Player 4. Usage myArray = [a0, a1,...aN] myArray[i] = value myObject[propertyName] Parameters The name of an array. myArray Elements in an array; any native type or object instance, including nested arrays. a0, a1,...aN An integer index greater than or equal to 0. The name of an object.
Page 58
Usage 2: Surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the following example: var my_array:Array = new Array();...
Page 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 function to eval() accomplish the same result:...
^ (bitwise XOR) Availability Flash Player 5. Usage expression1 ^ expression2 Parameters A number. expression1,expression2 Returns A 32-bit integer. Description Operator (bitwise); converts to 32-bit unsigned integers, and expression1 expression2 returns a 1 in each bit position where the corresponding bits in expression1 expression2 but not both, are 1.
^= (bitwise XOR assignment) Availability Flash Player 5. Usage expression1 ^= expression2 Parameters Integers and variables. expression1,expression2 Returns A 32-bit integer. Specifically, the value of expression1 ^ expression2 Description Operator (bitwise compound assignment); assigns the value of expression1 expression1 ^ .
, and with accompanying values: city state balance var account:Object = {name:"Macromedia, Inc.", address:"600 Townsend Street", city:"San Francisco", state:"California", zip:"94103", balance:"1000"}; for (i in account) { trace("account."+i+" = "+account[i]); Chapter 2: ActionScript Language Reference...
Page 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 using constructor functions: var person:Object = new Object();...
| (bitwise OR) Availability Flash Player 5. Usage expression1 | expression2 Parameters A number. expression1,expression2 Returns A 32-bit integer. Description Operator (bitwise); converts to 32-bit unsigned integers, and expression1 expression2 returns a 1 in each bit position where the corresponding bits of either expression1 are 1.
|| (logical OR) Availability Flash Player 4. Usage expression1 || expression2 Parameters A Boolean value or an expression that converts to a Boolean expression1, expression2 value. Returns A Boolean value. Description Operator (logical); evaluates (the expression on the left side of the operator) and expression1 returns if the expression evaluates to...
Page 66
function fx2():Boolean { trace("fx2 called"); return true; if (fx1() || fx2()) { trace("IF statement entered"); /* The following is sent to the Output panel: fx1 called IF statement entered See also ! (logical NOT), (inequality), !== (strict inequality), && (logical AND), (equality), (strict equality)
|= (bitwise OR assignment) Availability Flash Player 5. Usage expression1 |= expression2 Parameters A number or variable. expression1,expression2 Returns An integer. Description Operator (bitwise compound assignment); assigns the value of expression1 expression1 | . For example, the following two statements are equivalent: expression2 x |= y;...
~ (bitwise NOT) Availability Flash Player 5. Usage ~ expression Parameters A number. expression Returns A 32-bit integer. Description Operator (bitwise); also known as the one’s complement operator or the bitwise complement operator. Converts the to a 32-bit signed integer, and then applies a bitwise one’s expression complement.
Page 69
/* To set the read-only flag in the flags variable, the following code uses the bitwise OR: */ flags |= ReadOnlyFlag; trace(flags); /* To clear the read-only flag in the flags variable, first construct a mask by using bitwise NOT on ReadOnlyFlag. In the mask, every bit is a 1 except for the read-only flag.
+ (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 into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity.
Page 71
Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable is an input text field on the Stage. After a user enters a deposit deposit amount, the script attempts to add .
+= (addition assignment) Availability Flash Player 4. Usage expression1 += expression2 Parameters A number or string. expression1,expression2 Returns A string or a number. Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 + . For example, the following two statements have the same result: expression2 x += y;...
< (less than) 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 <...
<< (bitwise left shift) Availability Flash Player 5. Usage expression1 << expression2 Parameters A number or expression to be shifted left. expression1 A number or expression that converts to an integer from 0 to 31. expression2 Returns A 32-bit integer. Description Operator (bitwise);...
Page 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 << 2); // output: 8 See also >>= (bitwise right shift and assignment), >>...
<<= (bitwise left shift and assignment) Availability Flash Player 5. Usage expression1 <<= expression2 Parameters A number or expression to be shifted left. expression1 A number or expression that converts to an integer from 0 to 31. expression2 Returns A 32-bit integer. Description Operator (bitwise compound assignment);...
<= (less than or equal to) 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 to maintain data type integrity.
= (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 authoring environment undergo a conversion process to maintain data type integrity.
Page 79
The following example uses assignment by reference to create the variable, moonsOfJupiter which contains a reference to a newly created Array object. Assignment by value is then used to copy the value to the first element of the array referenced by the variable "Callisto"...
-= (subtraction assignment) Availability Flash Player 4. Usage expression1 -= expression2 Parameters A number or expression that evaluates to a number. expression1,expression2 Returns A number. Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 - . For example, the following two statements are equivalent: expression2 x -= y;...
== (equality) Availability Flash Player 5. Usage expression1 == expression2 Parameters A number, string, Boolean value, variable, object, array, expression1,expression2 or function. Returns A Boolean value. Description Operator (equality); tests two expressions for equality. The result is if the expressions true are equal.
Page 82
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 for these two arrays. false Although the arrays appear equal, comparison by reference requires that they both refer to the same array.
=== (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 data types are not converted. (For more information, see “Automatic data typing”...
Page 84
// 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 are references differently than it treats variables that contain literal values.
> (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 >...
>= (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 brought >= into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity.
>> (bitwise right shift) Availability Flash Player 5. Usage expression1 >> expression2 Parameters A number or expression to be shifted right. expression1 A number or expression that converts to an integer from 0 to 31. expression2 Returns A 32-bit integer. Description Operator (bitwise);...
Page 88
The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:Number = -1 >> 1; trace(x); // outputs -1 The following example shows the result of the previous example: var x:Number = -1 This is because -1 decimal equals 11111111111111111111111111111111 binary (thirty-two 1’s), shifting right by one bit causes the least significant (bit farthest to the right) to be discarded and the most significant bit to be filled in with 1.
>>= (bitwise right shift and assignment) Availability Flash Player 5. Usage expression1 >>= expression2 Parameters A number or expression to be shifted right. expression1 A number or expression that converts to an integer from 0 to 31. expression2 Returns A 32-bit integer. Description Operator (bitwise compound assignment);...
>>> (bitwise unsigned right shift) Availability Flash Player 5. Usage expression1 >>> expression2 Parameters A number or expression to be shifted right. expression1 A number or expression that converts to an integer between 0 and 31. expression2 Returns A 32-bit unsigned integer. Description Operator (bitwise);...
>>>= (bitwise unsigned right shift and assignment) Availability Flash Player 5. Usage expression1 >>>= expression2 Parameters A number or expression to be shifted left. expression1 A number or expression that converts to an integer from 0 to 31. expression2 Returns A 32-bit integer.
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. The methods of the Accessibility class are static—that is, you don’t have to create an instance of the class to use its methods.
Accessibility.isActive() Availability Flash Player 6. Usage Accessibility.isActive() : Boolean Parameters None. Returns A Boolean value: if the Flash Player is communicating with an accessibility aid (usually a true screen reader); otherwise. false Description Method; indicates whether an accessibility aid is currently active and the player is communicating with it.
Accessibility.updateProperties() Availability Flash Player 6 (6.0.65). Usage Accessibility.updateProperties() : Void Parameters None. Returns Nothing. Description Method; causes all changes to (accessibility properties) objects to take effect. For _accProps information on setting accessibility properties, see _accProps If you modify the accessibility properties for multiple objects, only one call to is necessary;...
CHAPTER 2 ActionScript Language Reference _accProps Availability Flash Player 6.65. Usage _accProps.propertyName instanceName._accProps.propertyName Parameters An accessibility property name (see the following description for valid names). propertyName The instance name assigned to an instance of a movie clip, button, dynamic text instanceName field, or input text field.
Page 96
Property Data type Equivalent in Accessibility panel Applies to description String Description Whole SWF files Movie clips Buttons Dynamic text Input text String Shortcut* Movie clips shortcut Buttons Input text For the Shortcut field, use names of the form Control+A. Adding a keyboard shortcut to the Accessibility panel doesn’t create a keyboard shortcut;...
Page 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 its default value ( for Boolean false values;...
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 arguments object is automatically created for that function.
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 property to make an anonymous function that is recursive, as arguments.callee shown in the following example: factorial = function (x:Number) { if (x<=1) { return 1;...
arguments.caller Availability Flash Player 6. Usage arguments.caller:Function Description Property; refers to the calling function. The value of this property is if the current function null was not called by another function. Example The following example defines two functions—a caller function, named function1, which calls a another function, named function2: // define the caller function, named function1 var function1:Function = function () {...
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 , which returns the number getArgLength of arguments that are passed into the function. Although the method expects three arguments, you can pass as many arguments as you want.
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 One or more elements to place in the array. element Returns An array. Description Conversion function;...
CHAPTER 2 ActionScript Language Reference 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 position in the array.
Page 104
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 An integer that specifies the number of elements in the array. length A list of two or more arbitrary values. The values can be of type element0...elementN Boolean, Number, String, Object, or Array.
Page 105
Usage 3: The following example creates the new Array object with an initial go_gos_array 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 initial elements of the array are identified, as shown in the following example: go_gos_array go_gos_array[0] = "Belinda";...
Array.concat() Availability Flash Player 5. Usage my_array.concat( [ value0:Object, value1,...valueN ]) : Array Parameters Numbers, elements, or strings to be concatenated in a new array. If you value0,...valueN don’t pass any values, a duplicate of is created. my_array Returns An array. Description Method;...
Array.join() Availability Flash Player 5. Usage my_array.join([separator:String]) : String Parameters A character or string that separates array elements in the returned string. If you omit separator this parameter, a comma (,) is used as the default separator. Returns A string. Description Method;...
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 assign a value to an array element (for example, ), if is a number, and...
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 the array containing four elements, and then removes myPets_array its last element:...
Array.push() Availability Flash Player 5. Usage my_array.push(value,...) : Number Parameters One or more values to append to the array. value Returns An integer representing the length of the new array. Description Method; adds one or more elements to the end of an array and returns the array’s new length. Example The following example creates the array with two elements,...
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(1, 2, 3, 4, 5, 6); trace(numbers_array);...
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 the array and then removes the first element from the myPets_array array and assigns it to the variable shifted...
Array.slice() Availability Flash Player 5. Usage my_array.slice( [ start:Number [ , end:Number ] ] ) : Array Parameters A number specifying the index of the starting point for the slice. If is a negative start start number, the starting point begins at the end of the array, where -1 is the last element. A number specifying the index of the ending point for the slice.
Array.sort() Availability Flash Player 5; additional capabilities added in Flash Player 7. Usage my_array.sort() : Array my_array.sort(compareFunction:Function) : Array my_array.sort(option:Number | option |... ) : Array my_array.sort(compareFunction:Function, option:Number | option |... ) : Array Parameters A comparison function used to determine the sorting order of elements in compareFunction an array.
Page 115
By default, works as described in the following list: Array sort() • 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 the sorted array in no particular order.
Page 116
trace("Sorted:"); //displays Sorted: trace(passwords_array); //displays ana:ring,anne:home,jay:mag,mom:glam,regina:silly See also Array.sortOn() | (bitwise OR) Chapter 2: ActionScript Language Reference...
Page 118
By default, works as described in the following list: Array sortOn() • 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 the sorted array in no particular order.
Page 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...
Page 120
// 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 : The name city first sort uses as the first sort value and as the second. The second sort uses as the name city...
Array.splice() Availability Flash Player 5. Usage my_array.splice(start:Number, deleteCount:Number [, value0:Object, value1...valueN]) : Array Parameters An integer that specifies the index of the element in the array where the insertion or start deletion begins. An integer that specifies the number of elements to be deleted. This number deleteCount includes the element specified in the parameter.
Page 122
The following example creates an array and splices it using element index 1 for the start parameter, the number 0 for the parameter, and the string for the deleteCount chair value parameter. This does not remove anything from the original array, and adds the string chair index 1: var myFurniture_array:Array = new Array("couch", "bed", "desk", "lamp");...
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 with index , is my_array.length-1 converted to a concatenated string and separated by commas.
Array.unshift() Availability Flash Player 5. Usage my_array.unshift(value1:Object,value2,...valueN) : Number Parameters One or more numbers, elements, or variables to be inserted at the value1,...valueN beginning of the array. Returns An integer representing the new length of the array. Description Method; adds one or more elements to the beginning of an array and returns the array’s new length.
CHAPTER 2 ActionScript Language Reference asfunction Availability Flash Player 5. Usage asfunction:function:Function,"parameter":String Parameters An identifier for a function. function A string that is passed to the function named in the parameter. parameter function Returns Nothing. Description Protocol; a special protocol for URLs in HTML text fields. In HTML text fields, text can be linked using the HTML tag.
CHAPTER 2 ActionScript Language Reference Boolean() Availability Flash Player 5; behavior changed in Flash Player 7. Usage Boolean(expression) : Boolean Parameters An expression to convert to a Boolean value. expression Returns A Boolean value. Description Function; converts the parameter to a Boolean value and returns a value as described expression in the following list: •...
Page 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 evaluate as if the file is published for Flash Player 7, true but will evaluate as...
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 the Boolean class to retrieve the primitive data type or string representation of a Boolean object.
Boolean.toString() Availability Flash Player 5. Usage myBoolean.toString() : String Parameters None. Returns A string; "true" "false" Description Method; returns the string representation ( ) of the Boolean object. "true" "false" Example This example creates a variable of type Boolean and uses to convert the value to a toString() string for use in the trace statement:...
Boolean.valueOf() Availability Flash Player 5. Usage myBoolean.valueOf() : Boolean Parameters None. Returns A Boolean value. Description Method: returns if the primitive value type of the specified Boolean object is true; true false otherwise. Example The following example shows how this method works, and also shows that the primitive value type of a new Boolean object is false var x:Boolean = new Boolean();...
CHAPTER 2 ActionScript Language Reference break Availability Flash Player 4. Usage break Parameters None. Returns Nothing. Description Statement; appears within a loop ( ) or within a block of for..in do while while statements associated with a particular case within a statement.
Page 132
See also for..in do while while switch case continue throw try..catch..finally Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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
Property Description Button.useHandCursor A Boolean value that indicates whether the pointing hand is displayed when the mouse passes over a button. A Boolean value that indicates whether a button instance is hidden Button._visible or visible. The width of a button instance, in pixels. Button._width The x coordinate of a button instance.
Button._alpha Availability Flash Player 6. Usage my_btn._alpha:Number Description Property; the alpha transparency value of the button specified by . Valid values are 0 (fully my_btn transparent) to 100 (fully opaque). The default value is 100. Objects in a button with _alpha to 0 are active, even though they are invisible.
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 ), the button is visible but cannot be clicked. The default false value is .
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 default, the property of a button instance is null; meaning, the button instance does not override _focusrect the global property.
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 on the Stage, you can trace their depth using the myBtn1_btn myBtn2_btn following ActionScript: trace(myBtn1_btn.getDepth()); trace(myBtn2_btn.getDepth());...
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 to a specified width my_btn and height. my_btn._width = 500; my_btn._height = 200; Button._height...
Button.menu Availability Flash Player 7. Usage my_btn.menu = contextMenu Parameters A ContextMenu object. contextMenu Description Property; associates the ContextMenu object with the button object contextMenu my_button The ContextMenu class lets you modify the context menu that appears when the user right-clicks (Windows) or Control-clicks (Macintosh) in Flash Player.
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) { if (this[i] instanceof Button) { trace(this[i]._name);...
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 then dragged outside of the button. You must define a function that executes when the event handler is invoked.
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 must define a function that executes when the event handler is invoked. Example The following example defines a function for the handler that sends a...
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 onKeyDown event handler is invoked with no parameters. You can use the Key.getAscii() Key.getCode() methods to determine which key was pressed.
Page 145
See also Button.onKeyUp Button.onKeyDown...
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 event onKeyUp handler is invoked with no parameters. You can use the Key.getAscii() Key.getCode() methods to determine which key was pressed.
Page 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 instance) and start pressing keys on your keyboard. When my_btn you press keys, they are displayed in the Output panel.
Button.onKillFocus Availability Flash Player 6. Usage my_btn.onKillFocus = function (newFocus:Object) : Void { // your statements here Parameters The object that is receiving the focus. newFocus Returns Nothing. Description Event handler; invoked when a button loses keyboard focus. The handler receives onKillFocus one parameter, , which is an object representing the new object receiving the focus.
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 invoked. Example In the following example, a function that sends a trace()
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 when the event handler is invoked. Example In the following example, a function that sends a trace()
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 the button is pressed while the pointer is inside the button. You must define a function that executes when the event handler is invoked.
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 function that executes when the event handler is invoked. Example In the following example, a function that sends a trace()
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 the event handler is invoked. Example In the following example, a function that sends a trace()
Button.onSetFocus Availability Flash Player 6. Usage my_btn.onSetFocus = function(oldFocus:Object) : Void { // your statements here Parameters The object to lose keyboard focus. oldFocus Returns Nothing. Description Event handler; invoked when a button receives keyboard focus. The parameter is the oldFocus object that loses the focus.
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 code that references _parent to specify a relative path to movie clips or objects that are above the current _parent movie clip or object.
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 property. _quality property can be set to the following values: _quality •...
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. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement is the same as my_btn._rotation = 450...
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 property for a Button object, it is actually a global property, and you can specify its value simply as _soundbuftime.
Button.tabEnabled Availability Flash Player 6. Usage my_btn.tabEnabled:Boolean Description Property; specifies whether is included in automatic tab ordering. It is my_btn undefined default. If the property is , the object is included in automatic tab tabEnabled undefined true ordering. If the property is also set to a value, the object is included in custom tab tabIndex ordering as well.
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 by default. undefined If any currently displayed object in the SWF file contains a property, automatic tab...
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 and add the following code to my_btn Frame 1 of the Timeline: trace(my_btn._target);...
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 second button, the event is onRelease registered for the second button.
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 . Enter the following one_btn two_btn ActionScript in Frame 1 of the Timeline: var one_btn:Button;...
Button.useHandCursor Availability Flash Player 6. Usage my_btn.useHandCursor:Boolean Description Property; a Boolean value that, when set to (the default), indicates whether a pointing hand true (hand cursor) displays when the mouse rolls over a button. If this property is set to , the false arrow pointer is used instead.
Button._visible Availability Flash Player 6. Usage my_btn._visible:Boolean Description Property; a Boolean value that indicates whether the button specified by is visible. my_btn Buttons that are not visible ( property set to ) are disabled. _visible false Example Create two buttons on the Stage with the instance names .
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 , and displays the my_btn width in the Output panel. Enter the following ActionScript in Frame 1 of the Timeline: my_btn.onRelease = function() { trace(this._width);...
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 corner of the Stage as (0, 0).
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 button called my_btn that is placed on the Stage. Enter the following ActionScript in Frame 1 of the Timeline: this.createTextField("mouse_txt", 999, 5, 5, 150, 40);...
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 system affects the property settings, which are defined in pixels.
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 left corner of the Stage as (0, 0).
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 is placed on the Stage. Enter the following ActionScript in Frame 1 of the Timeline: this.createTextField("mouse_txt", 999, 5, 5, 150, 40);...
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). Example The following example scales a button called my_btn. When you click and release the button, it grows 10% on the x and y axis.
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 running Macromedia Flash Player—for example, to monitor a video feed from a web camera...
Page 174
Property (read-only) Description Camera.motionLevel The amount of motion required to invoke Camera.onActivity(true) The number of milliseconds between the time when the camera stops Camera.motionTimeOut detecting motion and the time is invoked. Camera.onActivity(false) Camera.muted A Boolean value that specifies whether the user has allowed or denied access to the camera.
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 motion is being detected).
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 video can use as much bandwidth as needed to maintain the desired frame quality.
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 method to set a related Camera.setMode() property— —which specifies the maximum frame rate at which you would like the Camera.fps camera to capture data.
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; that is, if the camera doesn’t support the value you set here, this frame rate will not be achieved.
Camera.get() Availability Flash Player 6. Usage Camera.get([index:Number]) : Camera Note: The correct syntax is . To assign the Camera object to a variable, use syntax like Camera.get() active_cam = Camera.get() Parameters An optional zero-based integer that specifies which camera to get, as determined from index the array returned by the property.
Page 180
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 ActionScript to set the Allow or Deny value for a user, but you can display the Privacy panel for the user by using .
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 instance in a Label component instance on the Stage.
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 displays an array of cameras in a text field that is created at runtime, and tells you which camera you are currently using.
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 . Acceptable values range from 0 to 100. The default value is 50. Camera.onActivity(true) Video can be displayed regardless of the value of the property.
Page 184
/* 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, the activityLevel has fallen below the value defined in the motionLevel property (and stayed below that level for 2 seconds), so set the isActive parameter to false.
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 is invoked. The default value is 2000 Camera.onActivity(false) (2 seconds). To set this value, use Camera.setMotionLevel() Example In the following example, the ProgressBar instance changes its halo theme color when the activity...
Page 186
See also Camera.onActivity, Camera.setMotionLevel() Chapter 2: ActionScript Language Reference...
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 ( ) or allowed access ( ) in the Flash Player Privacy Settings panel. When this true false value changes,...
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 default camera in a text field. In Windows, this name is the same as the device name listed in the Scanners and Cameras Control Panel.
Camera.names Availability Flash Player 6. Usage Camera.names:Array Note: The correct syntax is . To assign the return value to a variable, use syntax like Camera.names . To determine the name of the current camera, use cam_array = Camera.names active_cam.name Description Read-only class property;...
Camera.onActivity Availability Flash Player 6. Usage active_cam.onActivity = function(activity:Boolean) : Void { // your statements here Parameters A Boolean value set to when the camera starts detecting motion, when activity true false it stops. Returns Nothing. Description Event handler; invoked when the camera starts or stops detecting motion. If you want to respond to this event handler, you must create a function to process its value.
Camera.onStatus Availability Flash Player 6. Usage active_cam.onStatus = function(infoObject:Object) : Void { // your statements here Parameters A parameter defined according to the status message. infoObject Returns Nothing. Description Event handler; invoked when the user allows or denies access to the camera. If you want to respond to this event handler, you must create a function to process the information object generated by the camera.
Page 192
trace("Camera access granted"); break; See also Camera.get(), Camera.muted, System.showSettings(); System.onStatus Chapter 2: ActionScript Language Reference...
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 from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). The default value is 0, which means that picture quality can vary as needed to avoid exceeding available bandwidth.
Camera.setMode() Availability Flash Player 6. Usage active_cam.setMode(width:Number, height:Number, fps:Number [,favorSize:Boolean]) : Void Parameters The requested capture width, in pixels. The default value is 160. width The requested capture height, in pixels. The default value is 120. height The requested rate at which the camera should capture data, in frames per second. The default value is 15.
Page 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 give it the instance name .
Camera.setMotionLevel() Availability Flash Player 6. Usage active_cam.setMotionLevel(sensitivity:Number [, timeout:Number]) : Void Parameters A numeric value that specifies the amount of motion required to invoke sensitivity . Acceptable values range from 0 to 100. The default value is 50. Camera.onActivity(true) An optional numeric parameter that specifies how many milliseconds must elapse timeout without activity before Flash considers activity to have stopped and invokes the event handler.
Page 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" is on the Stage active_cam = Camera.get();...
Camera.setQuality() Availability Flash Player 6. Usage active_cam.setQuality(bandwidth:Number, frameQuality:Number) : Void Parameters An integer that specifies the maximum amount of bandwidth that the current bandwidth outgoing video feed can use, in bytes per second. To specify that Flash video can use as much bandwidth as needed to maintain the value of , pass 0 for .
Page 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 // with a minimum quality of 50 active_cam.setQuality(8192,50);...
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, Camera.setMode() Example The following code displays the current width, height and FPS of a video instance in a Label component instance on the Stage.
CHAPTER 2 ActionScript Language Reference case Availability Flash Player 4. Usage case expression: statement(s) Parameters Any expression. expression Any statement or sequence of statements. statement(s) Returns Nothing. Description Statement; defines a condition for the statement. If the parameter equals the switch expression parameter of the...
Page 202
See also break default === (strict equality) switch Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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 file’s Publish Settings dialog box.
Page 204
To indicate that objects can add and access dynamic properties at runtime, precede the class statement with the keyword. To declare that a class implements an interface, use the dynamic keyword. To create subclasses of a class, use the keyword. (A class can implements extends extend only one class, but can implement several interfaces.) You can use...
Page 205
JPEG_mcl.loadClip(image, target_mc); In an external script file or in the Actions panel, use the operator to create a ImageLoader object. var jakob_mc:MovieClip = this.createEmptyMovieClip("jakob_mc", this.getNextHighestDepth()); var jakob:ImageLoader = new ImageLoader("http://www.macromedia.com/devnet/mx/ blueprint/articles/nielsen/spotlight_jnielsen.jpg", jakob_mc, {_x:10, _y:10, _alpha:70, _rotation:-5}); See also dynamic extends...
CHAPTER 2 ActionScript Language Reference clearInterval() Availability Flash Player 6. Usage clearInterval( intervalID:Number ) : Void Parameters A numeric (integer) identifier returned from a call to intervalID setInterval() Returns Nothing. Description Function; cancels an interval created by a call to setInterval() Example The following example first sets and then clears an interval call:...
CHAPTER 2 ActionScript Language Reference 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 to create a Color object before calling its methods.
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 call. setRGB() Example The following code retrieves the RGB value for the Color object , converts the value to my_color a hexadecimal string, and assigns it to the...
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 last call. Color.setTransform() Example The following example gets the transform object, and then sets new percentages for colors and alpha of relative to their current values.
Color.setRGB() Availability Flash Player 5. Usage my_color.setRGB(0xRRGGBB:Number) : Void Parameters The hexadecimal or RGB color to be set. , and each consist of two 0xRRGGBB hexadecimal digits that specify the offset of each color component. The tells the ActionScript compiler that the number is a hexadecimal value. Description Method;...
Color.setTransform() Availability Flash Player 5. Usage my_color.setTransform(colorTransformObject:Object) : Void Parameters An object created with the constructor. This instance of colorTransformObject new Object Object class must have the following properties that specify color transform values: . These properties are explained below. Returns Nothing.
Page 212
Example This example creates a new Color object for a target SWF file, creates a generic object called with the properties defined above, and uses the method to myColorTransform setTransform() pass the to a Color object. To use this code in a Flash (FLA) document, colorTransformObject place it on Frame 1 on the main Timeline and place a movie clip on the Stage with the instance name...
CHAPTER 2 ActionScript Language Reference 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 properties of the ContextMenu class to add custom menu items, control the display of the built-in context menu items (for example, Zoom In and Print), or create copies of menus.
Page 214
Property summary for the ContextMenu class Property Description An object whose members correspond to built-in context ContextMenu.builtInItems menu items. An array, undefined by default, that contains ContextMenu.customItems ContextMenuItem objects. Event handler summary for the ContextMenu class Property Description Invoked before the menu is displayed. ContextMenu.onSelect Constructor for the ContextMenu class Availability...
Page 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; } else { menuObj.customItems[0].enabled = true; function itemHandler(obj, item) { //...put code here...
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 , and . Setting these variables to removes the corresponding rewind forward_back print false menu items from the specified ContextMenu object. These properties are enumerable and are set by default.
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 This example creates a copy of the ContextMenu object named whose built-in menu items my_cm are hidden, and adds a menu item with the text “Save...”.
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, or modify these custom menu items. To add new menu items, you first create a new ContextMenuItem object, and then add it to the array (for example, using Array.push()).
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 running, the Debugging menu item shows, although it is dimmed for SWF files that don’t have remote debugging enabled.
ContextMenu.onSelect Availability Flash Player 7. Usage my_cm.onSelect = function (item:Object, item_menu:ContextMenu) : Void{ // your code here Parameters A reference to the object (movie clip, button, or selectable text field) that was under the item mouse pointer when the Flash Player context menu was invoked and whose property is set menu to a valid ContextMenu object.
Menu items are compared without regard to case, punctuation, or white space. None of the following words can appear in a custom item: Macromedia, Flash Player, or Settings. Method summary for the ContextMenuItem class...
Page 222
Constructor for the ContextMenuItem class Availability Flash Player 7. Usage new ContextMenuItem(caption:String, callbackFunction:Function, [ separatorBefore:Boolean, [ enabled:Boolean, [ visible:Boolean] ] ] ) : ContextMenuItem Parameters A string that specifies the text associated with the menu item. caption A function that you define, which is called when the menu item is selected. callbackFunction A Boolean value that indicates whether a separator bar should appear above separatorBefore...
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 (Pause Game) in the Output panel: var my_cm:ContextMenu = new ContextMenu();...
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 the original object. Example This example creates a new ContextMenuItem object named with the caption original_cmi Pause and a callback handler set to the function...
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 two new context menu items: Start and Stop. When the user selects Start, the number of milliseconds from when the SWF file started is traced.
ContextMenuItem.onSelect Availability Flash Player 7. Usage menuItem_cmi.onSelect = function (obj:Object, menuItem:ContextMenuItem) : Void // your statements here Parameters A reference to the movie clip (or Timeline), button, or selectable text field that the user right-clicked or Control-clicked. A reference to the selected ContextMenuItem object. menuItem Returns Nothing.
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 Note: A separator bar always appears between any custom menu items and the built-in menu items. Example This example creates three menu items, labeled Open, Save, and Print.
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 property is true Example The following example creates two new context menu items: Start and Stop. When the user selects Start, the number of milliseconds from when the SWF file started is displayed.
CHAPTER 2 ActionScript Language Reference 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 effect outside a loop.
Page 230
In a loop, causes the Flash interpreter to skip the rest of the loop body. In the continue following example, if the i modulo 3 equals 0, then the statement is skipped: trace(i) trace("example 3"); for (var i = 0; i<10; i++) { if (i%3 == 0) { continue;...
CHAPTER 2 ActionScript Language Reference 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 actions, retrieve the XML definition of a custom action, and retrieve the list of registered custom actions.
CustomActions.get() Availability Flash Player 6. Usage CustomActions.get(customName:String) : String Parameters The name of the custom action definition to retrieve. customName Returns If the custom action XML definition is located, returns a string; otherwise, returns undefined Description Method; reads the contents of the custom action XML definition file named customName The name of the definition file must be a simple filename, without the .xml file extension, and without any directory separators (':', '/' or '\').
CustomActions.install() Availability Flash Player 6. Usage CustomActions.install(customName:String, customXML:String) : Boolean Parameters The name of the custom action definition to install. customName The text of the XML definition to install. customXML Returns A Boolean value of if an error occurs during installation; otherwise, a value of false true returned to indicate that the custom action has been successfully installed.
Page 234
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); CustomActions.install("dogclass", this.firstChild); trace(CustomActions.list());...
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 of the array are simple names, without the .xml file extension, and without any directory separators (for example, “:”, “/”, or “\”).
CustomActions.uninstall() Availability Flash Player 6. Usage CustomActions.uninstall(customName:String) : Boolean Parameters The name of the custom action definition to uninstall. customName Returns A Boolean value of if no custom actions are found with the name . If the false customName custom actions were successfully removed, a value of is returned.
CHAPTER 2 ActionScript Language Reference 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.
Page 238
Method Description Date.getMilliseconds() Returns the milliseconds according to local time. Returns the minutes according to local time. Date.getMinutes() Returns the month according to local time. Date.getMonth() Date.getSeconds() Returns the seconds according to local time. Date.getTime() Returns the number of milliseconds since midnight January 1, 1970, universal time.
Page 239
Method Description Date.setUTCHours() Sets the hour according to universal time. Returns the new time in milliseconds. Date.setUTCMilliseconds() Sets the milliseconds according to universal time. Returns the new time in milliseconds. Sets the minutes according to universal time. Returns the new time Date.setUTCMinutes() in milliseconds.
Page 240
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 object for Mary’s birthday, August 12, 1974 (because the month parameter is zero-based, the example uses 7 for the month, not 8): var maryBirthday:Date = new Date (74, 7, 12);...
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 operating system on which Flash Player is running.
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 Date object according to local time.
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. Local time is determined by the operating system on which Flash Player is running.
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 determined by the operating system on which Flash Player is running. Example The following example uses the constructor to create a Date object based on the current time and uses the...
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 determined by the operating system on which Flash Player is running.
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 is determined by the operating system on which Flash Player is running. Example The following example uses the constructor to create a Date object based on the current time, and uses the...
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 the operating system on which Flash Player is running.
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 is determined by the operating system on which Flash Player is running. Example The following example uses the constructor to create a Date object based on the current time and uses the...
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 specific instant in time when comparing two or more Date objects.
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 The following example returns the difference between the local daylight saving time for San Francisco and universal time.
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 example creates a new Date object and uses Date.getUTCDate() Date.getDate().
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 universal time. Example The following example creates a new Date object and uses Date.getUTCDay()
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 new Date object and uses Date.getUTCFullYear() Date.getFullYear().
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 The following example creates a new Date object and uses Date.getUTCHours() Date.getHours().
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. Example The following example creates a new Date object and uses to return the getUTCMilliseconds() milliseconds value from the Date object.
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. Example The following example creates a new Date object and uses to return the getUTCMinutes() minutes value from the Date object:...
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 example creates a new Date object and uses Date.getUTCMonth() Date.getMonth().
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. Example The following example creates a new Date object and uses to return the getUTCSeconds() seconds value from the Date object:...
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 running. The year is the full year minus 1900.
Date.setDate() Availability Flash Player 5. Usage my_date.setDate(date) : Number Parameters An integer from 1 to 31. date Returns An integer. Description Method; sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.
Date.setFullYear() Availability Flash Player 5. Usage my_date.setFullYear(year:Number [, month:Number [, date:Number]] ) : Number Parameters A four-digit number specifying a year. Two-digit numbers do not represent four-digit year years; for example, 99 is not the year 1999, but the year 99. An integer from 0 (January) to 11 (December).
Date.setHours() Availability Flash Player 5. Usage my_date.setHours(hour) : Number Parameters An integer from 0 (midnight) to 23 (11 p.m.). hour Returns An integer. Description Method; sets the hours for the specified Date object according to local time and returns the new time in milliseconds.
Date.setMilliseconds() Availability Flash Player 5. Usage my_date.setMilliseconds(millisecond:Number) : Number Parameters An integer from 0 to 999. millisecond Returns An integer. Description Method; sets the milliseconds for the specified Date object according to local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.
Date.setMinutes() Availability Flash Player 5. Usage my_date.setMinutes(minute:Number) : Number Parameters An integer from 0 to 59. minute Returns An integer. Description Method; sets the minutes for a specified Date object according to local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.
Date.setMonth() Availability Flash Player 5. Usage my_date.setMonth(month:Number [, date:Number ]) : Number Parameters An integer from 0 (January) to 11 (December). month An integer from 1 to 31. This parameter is optional. date Returns An integer. Description Method; sets the month for the specified Date object in local time and returns the new time in milliseconds.
Date.setSeconds() Availability Flash Player 5. Usage my_date.setSeconds(second:Number) : Number Parameters An integer from 0 to 59. second Returns An integer. Description Method; sets the seconds for the specified Date object in local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.
Date.setTime() Availability Flash Player 5. Usage my_date.setTime(milliseconds:Number) : Number Parameters A number; an integer value where 0 is midnight on January 1, universal time. milliseconds Returns An integer. Description Method; sets the date for the specified Date object in milliseconds since midnight on January 1, 1970, and returns the new time in milliseconds.
Date.setUTCDate() Availability Flash Player 5. Usage my_date.setUTCDate(date:Number) : Number Parameters A number; an integer from 1 to 31. date Returns An integer. Description Method; sets the date for the specified Date object in universal time and returns the new time in milliseconds.
Date.setUTCFullYear() Availability Flash Player 5. Usage my_date.setUTCFullYear(year:Number [, month:Number [, date:Number]]) : Number Parameters An integer that represents the year specified as a full four-digit year, such as 2000. year An integer from 0 (January) to 11 (December). This parameter is optional. month An integer from 1 to 31.
Date.setUTCHours() Availability Flash Player 5. Usage my_date.setUTCHours(hour:Number [, minute:Number [, second:Number [, millisecond:Number]]]) : Number Parameters A number; an integer from 0 (midnight) to 23 (11 p.m.). hour A number; an integer from 0 to 59. This parameter is optional. minute A number;...
Date.setUTCMilliseconds() Availability Flash Player 5. Usage my_date.setUTCMilliseconds(millisecond:Number) : Number Parameters An integer from 0 to 999. millisecond Returns An integer. Description Method; sets the milliseconds for the specified Date object in universal time and returns the new time in milliseconds. Example The following example initially creates a new Date object, setting the date to 8:30 a.m.
Date.setUTCMinutes() Availability Flash Player 5. Usage my_date.setUTCMinutes(minute:Number [, second:Number [, millisecond:Number]]) : Number Parameters An integer from 0 to 59. minute An integer from 0 to 59. This parameter is optional. second An integer from 0 to 999. This parameter is optional. millisecond Returns An integer.
Date.setUTCMonth() Availability Flash Player 5. Usage my_date.setUTCMonth(month:Number [, date:Number]) : Number Parameters An integer from 0 (January) to 11 (December). month An integer from 1 to 31. This parameter is optional. date Returns An integer. Description Method; sets the month, and optionally the day, for the specified Date object in universal time and returns the new time in milliseconds.
Date.setUTCSeconds() Availability Flash Player 5. Usage my_date.setUTCSeconds(second:Number [, millisecond:Number]) : Number Parameters An integer from 0 to 59. second An integer from 0 to 999. This parameter is optional. millisecond Returns An integer. Description Method; sets the seconds for the specified Date object in universal time and returns the new time in milliseconds.
Date.setYear() Availability Flash Player 5. Usage my_date.setYear(year:Number) : Number Parameters A number that represents the year. If is an integer between 0–99, sets the year year setYear year at 1900 + ; otherwise, the year is the value of the parameter.
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 information in the Date object as a string: dateOfBirth_date var dateOfBirth_date:Date = new Date(74, 7, 12, 18, 15);...
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 A four-digit integer that represents the year (for example, 2000). year An integer from 0 (January) to 11 (December). month An integer from 1 to 31.
CHAPTER 2 ActionScript Language Reference default Availability Flash Player 6. Usage default: statements Parameters Any statements. statements Returns Nothing. Description Statement; defines the default case for a statement. The statements execute if the switch parameter of the statement doesn’t equal (using the strict equality [ expression switch operation) any of the...
CHAPTER 2 ActionScript Language Reference delete Availability Flash Player 5. Usage delete reference Parameters The name of the variable or object to eliminate. reference Returns A Boolean value. Description Operator; destroys the object reference specified by the parameter, and returns reference true the reference is successfully deleted;...
Page 280
Usage 3: The following example deletes an object property: var my_array:Array = new Array(); my_array[0] = "abc"; // my_array.length == 1 my_array[1] = "def"; // my_array.length == 2 my_array[2] = "ghi"; // my_array.length == 3 // my_array[2] is deleted, but Array.length is not changed delete my_array[2];...
CHAPTER 2 ActionScript Language Reference do while Availability Flash Player 4. Usage do { statement(s) } while (condition) Parameters The condition to evaluate. condition The statement(s) to execute as long as the parameter evaluates statement(s) condition true Returns Nothing. Description Statement;...
Page 282
See also break, continue, while Chapter 2: ActionScript Language Reference...
, and this new clip is moved on the Stage so it does not overlap the original clip, and newImg_mc the same image is loaded into the second clip. this.createEmptyMovieClip("img_mc", this.getNextHighestDepth()); img_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg"); duplicateMovieClip(img_mc, "newImg_mc", this.getNextHighestDepth()); newImg_mc._x = 200; newImg_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg");...
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 later in the Flash tab of your FLA file’s Publish Settings dialog box.
Page 285
/* output: craig.age = 32 craig.name = Craiggers If you add an undeclared function, , an error is generated, as shown in the following dance example: trace(""); craig.dance = true; for (i in craig) { trace("craig."+i +" = "+ craig[i]); /* output: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: There is no property with the name 'dance'.
CHAPTER 2 ActionScript Language Reference else Availability Flash Player 4. Usage if (condition){ statement(s); } else { statement(s); Parameters An expression that evaluates to condition true false An alternative series of statements to run if the condition specified in the statement(s) statement is false...
CHAPTER 2 ActionScript Language Reference else if Availability Flash Player 4. Usage if (condition){ statement(s); } else if (condition){ statement(s); Parameters An expression that evaluates to condition true false An alternative series of statements to run if the condition specified in the statement(s) statement is false...
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 See also #initclip Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference Error class Availability Flash Player 7. Description Contains information about an error that occurred in a script. You create an Error object using constructor function. Typically, you throw a new Error object from within a code Error block that is then caught by a...
Page 290
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 Chapter 2: ActionScript Language Reference...
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 " ". You can specify a property when you create an Error object by Error message passing the error string to the constructor function.
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 depending on the two numbers that you try to divide.
Error.toString() Availability Flash Player 7. Usage my_err.toString() : String Returns A string. Description Method; returns the string by default or the value contained in "Error" Error.message if defined. Example In the following example, a function throws an error (with a specified message) if the two strings that are passed to it are not identical: function compareStrings(str1_str:String, str2_str:String):Void { if (str1_str != str2_str) {...
CHAPTER 2 ActionScript Language Reference escape() Availability Flash Player 5. Usage escape(expression:String) : String Parameters The expression to convert into a string and encode in a URL-encoded format. expression Returns URL-encoded string. Description Function; converts the parameter to a string and encodes it in a URL-encoded format, where all nonalphanumeric characters are replaced with % hexadecimal sequences.
CHAPTER 2 ActionScript Language Reference eval() Availability Flash Player 5 or later for full functionality. You can use the function when exporting to eval() Flash Player 4, but you must use slash notation and can access only variables, not properties or objects.
Page 296
You can also use the following ActionScript: for (var i = 1; i<=3; i++) { this["square"+i+"_mc"]._rotation = -5; See also Array class, set variable Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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 box.
Page 298
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 to track whether the car object has a full-size spare tire. Second, it adds a new fullSizeSpare method specific to cars, , that activates the car’s anti-theft alarm.
CHAPTER 2 ActionScript Language Reference false Availability Flash Player 5. Usage false Description Constant; a unique Boolean value that represents the opposite of . When automatic data true typing converts to a number, it becomes 0; when it converts to a string, it becomes false false .
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 is set to its default value of , then a yellow rectangle _focusrect true...
CHAPTER 2 ActionScript Language Reference Availability Flash Player 5. Usage for(init; condition; next) { statement(s); Parameters An expression to evaluate before beginning the looping sequence; usually an assignment init expression. A statement is also permitted for this parameter. An expression that evaluates to .
Page 302
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<=100; i++) sum += i; trace(sum); // output: 5050 See also (increment), –– (decrement), for..in, var, while, do while Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference for..in Availability Flash Player 5. Usage for(variableIterant in object){ statement(s); Parameters The name of a variable to act as the iterant, referencing each property of an variableIterant object or element in an array. The name of an object to be iterated. object An instruction to execute for each iteration.
Page 304
//output myObject.name = Tara myObject.age = 27 myObject.city = San Francisco The following example shows using to iterate over the elements of an array: for..in var myArray:Array = new Array("one", "two", "three"); for (var index in myArray) trace("myArray["+index+"] = " + myArray[index]); // output: myArray[2] = three myArray[1] = two...
Player, such as a web browser. You can also use the function to pass messages to fscommand() Macromedia Director, or to Visual Basic, Visual C++, and other programs that can host ActiveX controls. Usage 1: To send a message to Flash Player, you must use predefined commands and parameters.
Page 306
Usage 3: The function can send messages to Macromedia Director that are fscommand() interpreted by Lingo (Director’s scripting language) as strings, events, or executable Lingo code. If the message is a string or an event, you must write the Lingo code to receive the message from the function and carry out an action in Director.
Page 307
function myDocument_DoFSCommand(command, args) { if (command == "messagebox") { alert(args); In the Flash document, add the function to a button: fscommand() fscommand("messagebox", "This is a message box called from within Flash.") You can also use expressions for the function and parameters, as in the fscommand() following example: fscommand("messagebox", "Hello, "...
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 The name of the new function. This parameter is optional. functionname An identifier that represents a parameter to pass to the function. This parameter is parameter optional.
Page 309
Example The following example defines the function , which accepts one parameter and returns the of the parameter: Math.pow(x, 2) 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, the function definition may appear after using the function: var y:Number = sqr(3);...
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 Function.apply() Invokes the function represented by a Function object, with parameters passed in through an array.
Function.apply() Availability Flash Player 6. Usage myFunction.apply(thisObject:Object, argumentsArray:Array) Parameters The object to which is applied. thisObject myFunction An array whose elements are passed to as parameters. argumentsArray myFunction Returns Any value that the called function specifies. Description Method; specifies the value of to be used within any function that ActionScript calls.
Page 312
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 = new Array("a", "b", "c"); // use apply() to set the value of this to be myObj and send firstArray theFunction.apply(myObj,firstArray);...
Function.call() Availability Flash Player 6. Usage myFunction.call(thisObject:Object, parameter1, ..., parameterN) Parameters An object that specifies the value of within the function body. thisObject this A parameter to be passed to the . You can specify zero or parameter1 myFunction more parameters. parameterN Returns Nothing.
Page 314
var obj:Object = new myObject(); myMethod.call(obj, obj); statement displays: trace() this == obj? true See also Function.apply() Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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 external script files, not in scripts written in the Actions panel.
Page 316
Enter the following ActionScript in a frame on the Timeline: var giants:Team = new Team("San Fran", "SFO"); trace(giants.name); giants.name = "San Francisco"; trace(giants.name); /* output: San Fran San Francisco When you trace giants.name, you use the get method to return the value of the property. See also Object.addProperty(), Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference getProperty() Availability Flash Player 4. Usage getProperty(my_mc:Object, property:Object) : Object Parameters The instance name of a movie clip for which the property is being retrieved. my_mc A property of a movie clip. property Returns The value of the specified property. Description Function;...
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 the SWF file started playing. Example In the following example, the functions are used to create a...
This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window. var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc:MovieClip) { target_mc.onRelease = function() { getURL("http://www.macromedia.com/software/flash/flashpro/", "_blank"); var logo:MovieClipLoader = new MovieClipLoader(); logo.addListener(listenerObject); logo.loadClip("http://www.macromedia.com/images/shared/product_boxes/159x120/ 159x120_box_flashpro.jpg", this.createEmptyMovieClip("macromedia_mc", this.getNextHighestDepth()));...
Page 320
= "Gus"; var lastName:String = "Richardson"; var age:Number = 92; myBtn_btn.onRelease = function() { getURL("http://www.macromedia.com", "_blank", "GET"); The following ActionScript uses to send variables in the HTTP header. Make sure you test POST your documents in a browser window, because otherwise your variables are sent using var firstName:String = "Gus";...
CHAPTER 2 ActionScript Language Reference 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. function returns information only for Flash Player 5 or later versions of getVersion Flash Player.
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 variables, objects, or classes. For example, you could create a library that is exposed as a global ActionScript object, similar to the Math or Date object.
CHAPTER 2 ActionScript Language Reference gotoAndPlay() Availability Flash 2. Usage gotoAndPlay([scene:String,] frame:Object) : Void Parameters An optional string specifying the name of the scene to which the playhead is sent. scene A number representing the frame number, or a string representing the label of the frame, frame to which the playhead is sent.
CHAPTER 2 ActionScript Language Reference gotoAndStop() Availability Flash 2. Usage gotoAndStop([scene:String,] frame:Object) : Void Parameters An optional string specifying the name of the scene to which the playhead is sent. scene A number representing the frame number, or a string representing the label of the frame, frame to which the playhead is sent.
Page 325
CHAPTER 2 ActionScript Language Reference Availability Flash Player 4. Usage if(condition) { statement(s); Parameters An expression that evaluates to condition true false The instructions to execute if or when the condition evaluates to statement(s) true Returns Nothing. Description Statement; evaluates a condition to determine the next action in a SWF file. If the condition is , Flash runs the statements that follow the condition inside curly braces ( ).
Page 326
} else { this._parent.message_txt.text = "Very good, you hit the button in "+difference+" seconds."; See also else Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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 when used in external script files, not in scripts written in the Actions panel.
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 supported in the Actions panel as well as in external class files.
Page 329
For more information on importing, see “Importing classes” and “Using packages” in Using ActionScript in Flash. import...
• The global Include directory, which is one of the following: Windows 2000 or Windows XP: C:\Documents and Settings\user\Local Settings\ Application Data\Macromedia\Flash MX 2004\language\Configuration\Include Windows 98: C:\Windows\Application Data\Macromedia\Flash MX 2004\ language\Configuration\Include Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/ Flash MX 2004/language/Configuration/Include •...
Page 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.) Note: If you place files in the First Run/Include directory or in the global Include directory, back up these files.
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...
CHAPTER 2 ActionScript Language Reference #initclip Availability Flash Player 6. Usage #initclip order Parameters An integer that specifies the execution order of blocks of code. This is an order #initclip optional parameter. Description Compiler directive; indicates the beginning of a block of initialization actions. When multiple clips are initialized at the same time, you can use the parameter to specify which order...
CHAPTER 2 ActionScript Language Reference instanceof Availability Flash Player 6. Usage object instanceof class Parameters An ActionScript object. object A reference to an ActionScript constructor function, such as String or Date. class Returns is an instance of returns otherwise. Also, object class instanceof...
CHAPTER 2 ActionScript Language Reference 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 used in external script files, not in scripts written in the Actions panel.
Page 336
// 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.k()); // 15 trace(mvar.n(7)); // 49 trace(mvar.o()); // "o"...
CHAPTER 2 ActionScript Language Reference 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 your FLA file’s Publish Settings dialog box.
Page 338
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 uses the Circle class var myCircle:Circle = new Circle(5); trace(myCircle.getArea()); trace(myCircle.getDiameter()); myCircle.setRadius("10"); trace(myCircle.radius); trace(myCircle.getArea()); trace(myCircle.getDiameter());...
CHAPTER 2 ActionScript Language Reference isFinite() Availability Flash Player 5. Usage isFinite(expression:Object) : Boolean Parameters A Boolean value, variable, or other expression to be evaluated. expression Returns A Boolean value. Description Function; evaluates and returns if it is a finite number or if it is infinity expression true...
CHAPTER 2 ActionScript Language Reference isNaN() Availability Flash Player 5. Usage isNaN(expression:Object) : Boolean Parameters A Boolean, variable, or other expression to be evaluated. expression Returns A Boolean value. Description Function; evaluates the parameter and returns if the value is (not a number).
CHAPTER 2 ActionScript Language Reference 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.
Page 342
Property Description Key code Key.PGUP The key code value for the Page Up key. The key code value for the Right Arrow key. Key.RIGHT The key code value for the Shift key. Key.SHIFT Key.SPACE The key code value for the Spacebar. Key.TAB The key code value for the Tab key.
Key.addListener() Availability Flash Player 6. Usage Key.addListener (newListener:Object) : Void Parameters An object with methods newListener onKeyDown onKeyUp Returns Nothing. Description Method; registers an object to receive notification. When a key is onKeyDown onKeyUp pressed or released, regardless of the input focus, all listening objects registered with have either their method or method invoked.
Page 344
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() Chapter 2: ActionScript Language Reference...
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 . The onKeyDown last line uses to register the listener with the Key object so that it can receive addListener() notification from the key down event.
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 . The onKeyDown last line uses to register the listener with the Key object so that it can receive addListener() notification from the key down event.
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 and makes information about the shortcut available to screen readers (see my_btn _accProps).
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 API and listener objects. Press the Backspace or Delete key to remove the lines that you draw. this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());...
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 a constant distance (10) when you press car_mc the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example.
Key.END Availability Flash Player 5. Usage Key.END:Number Description Property; constant associated with the key code value for the End key (35). Chapter 2: ActionScript Language Reference...
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 a constant distance (10) when you press car_mc the arrow keys. The instance stops when you press Enter and delete the car_mc onEnterFrame...
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 information that includes how long it took you to press the key. var keyListener:Object = new Object();...
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 returned are English keyboard values.
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 the returned key code value with the key on a standard keyboard, see Appendix C, “Keyboard Keys and Key Code Values”.
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 at the x and y coordinates of car_mc 0,0. When you press the Home key, car_mc returns to 0,0. Create a movie clip that has a linkage , and add the following ActionScript to Frame 1 of the Timeline: car_id this.attachMovie("car_id", "car_mc", this.getNextHighestDepth(), {_x:0,...
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 . The onKeyDown last line uses to register the listener with the Key object so that it can receive addListener() notification from the key down event and display information in the Output panel.
Key.isDown() Availability Flash Player 5. Usage Key.isDown(keycode:Number) : Boolean Parameters The key code value assigned to a specific key or a Key class property associated with a keycode specific key. To match the returned key code value with the key on a standard keyboard, see Appendix C, “Keyboard Keys and Key Code Values”...
Key.isToggled() Availability Flash Player 5. Usage Key.isToggled(keycode:Number) : Boolean Parameters The key code for the Caps Lock key (20) or the Num Lock key (144). keycode Returns A Boolean value. Description Method: returns if the Caps Lock or Num Lock key is activated (toggled to an active state); true otherwise.
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 a constant distance (10) when you press car_mc the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example.
Key.onKeyDown Availability Flash Player 6. Usage keyListener.onKeyDown Description Listener; notified when a key is pressed. To use you must create a listener object. You onKeyDown, can then define a function for and use to register the listener with the onKeyDown addListener() Key object, as shown in the following example: var keyListener:Object = new Object();...
Key.onKeyUp Availability Flash Player 6. Usage keyListener.onKeyUp Description Listener; notified when a key is released. To use you must create a listener object. You onKeyUp, can then define a function for and use to register the listener with the onKeyUp addListener() Key object, as shown in the following example: var keyListener:Object = new Object();...
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 when you press the Page Down and car_mc Page Up keys. var keyListener:Object = new Object();...
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 when you press the Page Down and car_mc Page Up keys. var keyListener:Object = new Object();...
Key.removeListener() Availability Flash Player 6. Usage Key.removeListener (listener:Object) : Boolean Parameters An object. listener Returns If the was successfully removed, the method returns . If the was not listener true listener successfully removed (for example, because the was not on the Key object’s listener list), listener the method returns false...
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 a constant distance (10) when you press car_mc the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example.
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 when you press Shift. car_mc var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.SHIFT)) { car_mc._xscale *= 2;...
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 a constant distance (10) when you press car_mc the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example.
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.
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 a constant distance (10) when you press car_mc the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example.
CHAPTER 2 ActionScript Language Reference _level Availability Flash Player 4. Usage _levelN Description Identifier; a reference to the root Timeline of . You must use to load _levelN loadMovieNum() SWF files into the Flash Player before you use the property to target them. You can also _level to target a loaded SWF file at the level assigned by _levelN...
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 The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0.
Page 373
Example Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called that already exists on the Stage: mySquare loadMovie("circle.swf", mySquare); // equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare); // equivalent statement (Usage 2): loadMovie("circle.swf", “mySquare”); The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the movie clip:...
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 The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0.
Page 375
SWF files or images that were loaded with unloadMovieNum() loadMovieNum() Example The following example loads the JPEG image tim.jpg into level 2 of Flash Player: loadMovieNum("http://www.macromedia.com/devnet/mx/coldfusion/articles/ basic_chart/tim.jpg", 2); See also loadMovie(), unloadMovieNum(), _level loadMovieNum()
(a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
Page 377
If you want to load variables into a specific level, use instead of loadVariablesNum() loadVariables() Example The following example loads information from a text file called params.txt into the target_mc movie clip that is created using . The function is used createEmptyMovieClip() setInterval() to check the loading progress.
(a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version of the player earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
Page 379
If you want to load variables into a target MovieClip, use instead of loadVariables() 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 text fields must match the variable names in the params.txt file.
CHAPTER 2 ActionScript Language Reference LoadVars class Availability Flash Player 6. Description The LoadVars class is an alternative to the function for transferring variables loadVariables() between a Flash application and a server. You can use the LoadVars class to obtain verification of successful data loading and to monitor download progress.
Page 381
Property summary for the LoadVars class Property Description A string that indicates the MIME type of the data. LoadVars.contentType A Boolean value that indicates whether a LoadVars.loaded load sendAndLoad operation has completed. Event handler summary for the LoadVars class Event handler Description Invoked when data has been completely downloaded from the LoadVars.onData...
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 A string that represents an HTTP request header name. headerName A string that represents the value associated with headerValue headerName Returns Nothing. Description Method;...
Page 383
See also XML.addRequestHeader() LoadVars.addRequestHeader()
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() . The default is application/x-www-form-urlencoded. LoadVars.sendAndLoad() Example The following example creates a LoadVars object and displays the default content type of the data that is sent to the server.
LoadVars.decode() Availability Flash Player 7. Usage my_lv.decode(variables:String) : Void Parameters A URL-encoded query string containing name/value pairs. variables Returns Nothing. Description Method; converts the variable string to properties of the specified LoadVars object. This method is used internally by the event handler.
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() . This method returns if no load operation is in progress LoadVars.sendAndLoad() undefined or if a load operation has not yet begun. Example The following example uses a ProgressBar instance and a LoadVars object to download a text file.
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() . This method returns if no load operation is in progress LoadVars.sendAndLoad() undefined or if a load operation has not started. This method also returns if the number of total undefined bytes can’t be determined (for example, if the download was initiated but the server did not...
Page 388
my_lv.load("[place a valid URL pointing to a text file here]"); Chapter 2:...
LoadVars.load() Availability Flash Player 6; behavior changed in Flash Player 7. Usage my_lv.load(url:String) : Boolean Parameters A string; the URL from which to download the variables. If the SWF file issuing this call is running in a web browser, must be in the same domain as the SWF file; for details, see the Description section.
Page 390
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” at www.macromedia.com/ devnet/mx/flash/articles/flashmx_php.html. An example is also in the guestbook.fla file in the HelpExamples folder. The following list gives typical paths to this folder: •...
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() LoadVars.sendAndLoad() operation is started, the property is set to ; when the operation completes, the loaded false property is set to...
LoadVars.onData Availability Flash Player 6. Usage my_lv.onData = function(src:String) { // your statements here Parameters A string or ; the raw (unparsed) data from a undefined LoadVars.load() method call. LoadVars.sendAndLoad() Returns Nothing. Description Event handler; invoked when data has completely downloaded from the server or when an error occurs while data is downloading from a server.
LoadVars.onLoad Availability Flash Player 6. Usage my_lv.onLoad = function(success:Boolean) { // your statements here Parameters A Boolean value that indicates whether the load operation ended in success ( ) or success true failure ( false Returns A Boolean value. Description Event handler;...
Page 394
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/ • LoadVars.loaded, LoadVars.load(), LoadVars.sendAndLoad() Chapter 2:...
LoadVars.send() Availability Flash Player 6. Usage my_lv.send(url:String,target:String method:String]) : Boolean Parameters A string; the URL to which to upload variables. A string; the browser window or frame in which any response will appear. You can enter target the name of a specific window or select from the following reserved target names: •...
Page 396
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 LoadVars();...
LoadVars.sendAndLoad() Availability Flash Player 6; behavior changed in Flash Player 7. Usage my_lv.sendAndLoad(url:String targetObject[, method:String]) : Boolean Parameters A string; the URL to which to upload variables. If the SWF file issuing this call is running in a web browser, must be in the same domain as the SWF file;...
Page 398
"POST"); submit_button.addEventListener("click", submitListener); 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/ • LoadVars.send(), XML.sendAndLoad()
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 , in the MIME content my_lv encoding application/x-www-form-urlencoded. Example The following example instantiates a new object, creates two properties, and uses LoadVars() to return a string containing both properties in URL encoded format: toString()
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 SWF files that are running on the same client computer, but they can be running in different applications—for example, a SWF file running in a browser and a SWF file running in a projector.
Page 401
Event handler summary for the LocalConnection class Event handler Description Invoked whenever the current (receiving) LocalConnection LocalConnection.allowDomain object receives a request to invoke a method from a sending LocalConnection object. Invoked whenever the current (receiving) LocalConnection LocalConnection.allowInsecureDomain object, which is in a SWF file hosted at a domain using a secure protocol (HTTPS), receives a request to invoke a method from a sending LocalConnection object that is in a SWF file hosted at a non-secure protocol.
Page 402
See also LocalConnection.connect(), LocalConnection.send() Chapter 2: ActionScript Language Reference...
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 A string that represents an optional parameter specifying the domain of the sendingDomain SWF file that contains the sending LocalConnection object.
Page 404
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 LocalConnection.allowInsecureDomain event handler instead.
Page 405
+= aString+newline; aLocalConn.allowDomain = function(sendingDomain) { return (sendingDomain == this.domain() || sendingDomain == "www.macromedia.com"); aLocalConn.connect("_mylc"); When published for Flash Player 7 or later, exact domain matching is used. This means that the example will fail if the SWF files are located at www.thatDomain.com but will work if the files are located at thatDomain.com.
SWF files published for Flash Player 7 or later. Example The following example allows connections from the current domain or from www.macromedia.com, or allows insecure connections only from the current domain. this.createTextField("welcome_txt", this.getNextHighestDepth(), 10, 10, 100, 20);...
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 commands—for example, when you want to issue a command using the same parameter in LocalConnection.connect()
LocalConnection.connect() Availability Flash Player 6. Usage receiving_lc.connect(connectionName:String) : Boolean Parameters A string that corresponds to the connection name specified in the connectionName command that wants to communicate with LocalConnection.send() receiving_lc Returns A Boolean value: if no other process running on the same client computer has already issued true this command using the same value for the parameter;...
Page 410
If you are implementing communication between SWF files in different domains, specifying a string for that begins with an underscore (_) will make the SWF with the connectionName receiving LocalConnection object more portable between domains. Here are the two possible cases: •...
Method; returns a string representing the domain of the location of the current SWF file. In SWF files published for Flash Player 6, the returned string is the superdomain of the current SWF file. For example, if the SWF file is located at www.macromedia.com, this command returns "macromedia.com"...
Page 413
= function(sendingDomain):String{ return (sendingDomain==this.domain() || 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.com. The sending SWF file includes its domain name as a parameter to the method it invokes, so the receiving SWF file can return a reply value to a LocalConnection object in the correct domain.
Page 414
return (aDomain == "mydomain.com"); lc.aResult = function(aParam) { trace("The sum is " + aParam); // determine our domain and see if we need to truncate it var channelDomain:String = lc.domain(); if (getVersion() >= 7 && this.getSWFVersion() >= 7) // split domain name into elements var domainArray:Array = channelDomain.split(".");...
LocalConnection.onStatus Availability Flash Player 6. Usage sending_lc.onStatus = function(infoObject:Object) : Void{ // your statements here Parameters A parameter defined according to the status message. For details about this infoObject parameter, see the Description section. Returns Nothing. Description Event handler; invoked after a sending LocalConnection object tries to send a command to a receiving LocalConnection object.
Page 416
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 encountered an error."; break; sending_lc.send("lc_name", "sayHello", name_ti.text); send_button.addEventListener("click", sendListener); See also LocalConnection.send(), System.onStatus Chapter 2: ActionScript Language Reference...
LocalConnection.send() Availability Flash Player 6. Usage sending_lc.send (connectionName:String, method:String [, p1,...,pN]) : Boolean Parameters A string that corresponds to the connection name specified in the connectionName command that wants to communicate with LocalConnection.connect() sending_lc A string specifying the name of the method to be invoked in the receiving method LocalConnection object.
Page 418
• Include the superdomain in in the sending LocalConnection object—for connectionName example, . In the receiving object, use myDomain.com:myConnectionName LocalConnection.allowDomain to specify that connections from the specified superdomain will be accepted (in this case, myDomain.com) or that connections from any domain will be accepted.
CHAPTER 2 ActionScript Language Reference 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.
Page 420
Method Description Math.pow() Computes raised to the power of the Returns a pseudo-random number between 0.0 and 1.0. Math.random() Rounds to the nearest integer. Math.round() Math.sin() Computes a sine. Math.sqrt() Computes a square root. Computes a tangent. Math.tan() Property summary for the Math class All the following properties for the Math class are constants: Property Description...
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 A number.
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:Number) : Number Parameters A number from -1.0 to 1.0.
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 A number from -1.0 to 1.0.
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(tangent:Number) : Number Parameters A number that represents the tangent of an angle.
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 Parameters A number specifying the y coordinate of the point.
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:Number) : Number Parameters A number or expression.
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 A number that represents an angle measured in radians.
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 Description Constant;...
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 The exponent;...
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:Number) : Number Parameters A number or expression.
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 A number or expression with a value greater than 0.
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 Description Constant;...
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;...
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:Number Parameters None.
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;...
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:Number , y:Number) : Number Parameters A number or expression.
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 Parameters A number or expression.
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 Parameters None.
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 Parameters A number to be raised to a power.
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() : Number Parameters None.
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 A number.
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:Number) : Number Parameters A number that represents an angle measured in radians.
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 A number or expression greater than or equal to 0.
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:Number Description Constant;...
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;...
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:Number) Parameters A number that represents an angle measured in radians.
CHAPTER 2 ActionScript Language Reference 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 fashion without the server—for example, to transmit sound from your microphone through the speakers on your local system.
Page 448
Property (read-only) Description Microphone.names Class property; an array of strings reflecting the names of all available sound capture devices, including sound cards and microphones. The sound capture rate, in kHz. Microphone.rate The amount of sound required to activate the microphone. Microphone.silenceLevel The number of milliseconds between the time the Microphone.silenceTimeOut...
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 sound is being detected). The value of this property can help you determine a good value to pass to the method.
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 ProgressBar instance called to display and a gain_pb NumericStepper instance called to set the microphone’s gain value.
Microphone.get() Availability Flash Player 6. Usage Microphone.get([index:Number]) : Microphone Note: The correct syntax is . To assign the Microphone object to a variable, use Microphone.get() syntax like active_mic = Microphone.get() Parameters An optional zero-based integer that specifies which microphone to get, as determined index from the array that Microphone.names...
Page 452
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 ActionScript to set the Allow or Deny value for a user, but you can display the Privacy panel for the user by using .
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 of the sound capturing devices available on your computer system in a ComboBox instance called .
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 ( ) or allowed access ( ). When this value changes, Microphone.onStatus true false invoked. For more information, see Microphone.get(). Example This example gets the default microphone and checks whether it is muted.
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 sound capturing device(s) on your computer system, including an array of names and the default device.
Microphone.names Availability Flash Player 6. Usage Microphone.names:Array Note: The correct syntax is . To assign the return value to a variable, use syntax like Microphone.names . To determine the name of the current microphone, use mic_array = Microphone.names active_mic.name Description Read-only class property;...
Microphone.onActivity Availability Flash Player 6. Usage active_mic.onActivity = function(activity:Boolean) : Void { // your statements here Parameters A Boolean value set to when the microphone starts detecting sound, and activity true false when it stops. Returns Nothing. Description Event handler; invoked when the microphone starts or stops detecting sound. If you want to respond to this event handler, you must create a function to process its value.
Microphone.onStatus Availability Flash Player 6. Usage active_mic.onStatus = function(infoObject:Object) : Void { // your statements here Parameters A parameter defined according to the status message. infoObject Returns Nothing. Description Event handler; invoked when the user allows or denies access to the microphone. If you want to respond to this event handler, you must create a function to process the information object generated by the microphone.
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, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz.
Microphone.setGain() Availability Flash Player 6. Usage active_mic.setGain(gain:Number) : Void Parameters An integer that specifies the amount by which the microphone should boost the signal. gain Valid values are 0 to 100. The default value is 50; however, the user may change this value in the Flash Player Microphone Settings panel.
Microphone.setRate() Availability Flash Player 6. Usage active_mic.setRate(kHz:Number) : Void Parameters 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 sound capture device supports this value. Otherwise, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz.
Page 463
See also Microphone.rate Microphone.setRate()
Microphone.setSilenceLevel() Availability Flash Player 6. Usage active_mic.setSilenceLevel(level:Number [, timeout:Number]) : Void Parameters An integer that specifies the amount of sound required to activate the microphone and level invoke . Acceptable values range from 0 to 100. The default Microphone.onActivity(true) value is 10. An optional integer parameter that specifies how many milliseconds must elapse timeout without activity before Flash considers sound to have stopped and invokes...
Page 465
Example The following example changes the silence level based on the user’s input in a NumericStepper instance called . The ProgressBar instance called silenceLevel_nstep silenceLevel_pb modifies its appearance depending on whether the audio stream is considered silent. Otherwise, it displays the activity level of the audio stream. var silenceLevel_pb:mx.controls.ProgressBar;...
Microphone.setUseEchoSuppression() Availability Flash Player 6. Usage active_mic.setUseEchoSuppression(suppress:Boolean) : Void Parameters A Boolean value indicating whether echo suppression should be used ( ) or suppress true not ( false Returns Nothing. Description Method; specifies whether to use the echo suppression feature of the audio codec. The default value is unless the user has selected Reduce Echo in the Flash Player Microphone false...
Page 467
active_mic.setUseEchoSuppression(evt.target.selected); useEchoSuppression_ch.addEventListener("click", chListener); See also Microphone.setGain(), Microphone.useEchoSuppression Microphone.setUseEchoSuppression()
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 . The default value is 10. Microphone.onActivity(true) Example The following example changes the silence level based on the user’s input in a NumericStepper instance called .
Page 469
See also Microphone.gain, Microphone.setSilenceLevel() Microphone.silenceLevel...
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 Microphone.onActivity(false) invoked. The default value is 2000 (2 seconds). To set this value, use Microphone.setSilenceLevel(). Example The following example enables the user to control the amount of time between when the microphone stops detecting sound and when...
Page 471
silenceLevel_pb.label = "Activity level: (inactive)"; See also Microphone.setSilenceLevel() Microphone.silenceTimeOut...
Microphone.useEchoSuppression Availability Flash Player 6. Usage active_mic.useEchoSuppression:Boolean Description Property (read-only); a Boolean value of if echo suppression is enabled, otherwise. true false The default value is unless the user has selected Reduce Echo in the Flash Player false Microphone Settings panel. Example The following example turns on echo suppression if the user selects a CheckBox instance called .
Frame 1 of your file, the command executes when the SWF file MMExecute() is loaded. For more information on the JSAPI, see www.macromedia.com/go/jsapi_info_en. Example The following command will output the number of items in the library of the current document to the trace window.
Page 474
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 version to get the output. It might be easier to copy the results of fl.trace MMExecute to a text field that is part of your Flash Panel file.
CHAPTER 2 ActionScript Language Reference 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.
Mouse.addListener() Availability Flash Player 6. Usage Mouse.addListener (newListener:Object) Parameters An object. newListener Returns Nothing. Description Method; registers an object to receive notifications of the onMouseDown onMouseMove , and listeners. (The listener is supported only in onMouseUp onMouseWheel onMouseWheel Windows.) parameter should contain an object that has a defined method for at least one newListener of the listeners.
Page 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/Samples/HelpExamples/ Mouse.addListener()
Mouse.hide() Availability Flash Player 5. Usage Mouse.hide() : Boolean Parameters None. Returns A Boolean value: if the pointer is visible; otherwise. true false Description Method; hides the pointer in a SWF file. The pointer is visible by default. Example: The following code hides the standard mouse pointer, and sets the x and y positions of the movie clip instance to the x and y cursor position.
Mouse.onMouseDown Availability Flash Player 6. Usage someListener.onMouseDown Parameters None. Description Listener; notified when the mouse is pressed. To use the listener, you must create a onMouseDown listener object. You can then define a function for and use onMouseDown addListener() register the listener with the Mouse object, as shown in the following code: var someListener:Object = new Object();...
Page 480
See also Mouse.addListener() Chapter 2: ActionScript Language Reference...
Mouse.onMouseMove Availability Flash Player 6. Usage someListener.onMouseMove Parameters None. Returns Nothing. Description Listener; notified when the mouse moves. To use the listener, you must create a onMouseMove listener object. You can then define a function for and use onMouseMove addListener() register the listener with the Mouse object, as shown in the following code: var someListener:Object = new Object();...
Page 482
The following example hides the standard mouse pointer, and sets the x and y positions of the movie clip instance to the x and y pointer position. Create a movie clip and set its pointer_mc Linkage identifier to . Add the following ActionScript to Frame 1 of the Timeline: pointer_id // to use this script you need a symbol // in your library with a Linkage Identifier of "pointer_id".
Mouse.onMouseUp Availability Flash Player 6. Usage someListener.onMouseUp Parameters None. Returns Nothing. Description Listener; notified when the mouse is released. To use the listener, you must create a onMouseUp listener object. You can then define a function for and use to register onMouseUp addListener() the listener with the Mouse object, as shown in the following code:...
Mouse.onMouseWheel Availability Flash Player 6 (Windows only). Usage someListener.onMouseWheel = function ( [ delta [, scrollTarget ] ] ) { // your statements here Parameters An optional number indicating how many lines should be scrolled for each notch the delta user rolls the mouse wheel.
Page 485
mouseListener.onMouseWheel = function(delta:Number) { line_mc._rotation += delta; mouseListener.onMouseDown = function() { trace("Down"); Mouse.addListener(mouseListener); See also Mouse.addListener(), TextField.mouseWheelEnabled Mouse.onMouseWheel...
Mouse.removeListener() Availability Flash Player 6. Usage Mouse.removeListener (listener:Object) : Boolean Parameters An object. listener Returns If the object is successfully removed, the method returns ; if the is not listener true listener successfully removed (for example, if the was not on the Mouse object’s listener list), listener the method returns false...
Page 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 stopDrawingListener:Object = new Object(); stopDrawingListener.click = function(evt:Object) { Mouse.removeListener(mouseListener); evt.target.enabled = false; startDrawing_button.enabled = true; stopDrawing_button.addEventListener("click", stopDrawingListener); var startDrawingListener:Object = new Object(); startDrawingListener.click = function(evt:Object) { Mouse.addListener(mouseListener);...
Mouse.show() Availability Flash Player 5. Usage Mouse.show() : Number Parameters None. Returns An integer; either . If the mouse pointer was hidden before the call to then Mouse.show(), the return value is . If the mouse pointer was visible before the call to , then the Mouse.show() return value is...
CHAPTER 2 ActionScript Language Reference 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.
Page 490
Method Description MovieClip.globalToLocal() Converts Stage coordinates to the local coordinates of the specified movie clip. Sends the playhead to a specific frame in the movie clip and MovieClip.gotoAndPlay() plays the movie clip. Sends the playhead to a specific frame in the movie clip and MovieClip.gotoAndStop() stops the movie clip.
Page 491
Method Description MovieClip.lineStyle() Defines the stroke of lines created with the MovieClip.curveTo() methods. MovieClip.lineTo() Draws a line using the current line style. MovieClip.lineTo() MovieClip.moveTo() Moves the current drawing position to specified coordinates. Property summary for the MovieClip class Property Description MovieClip._alpha The transparency value of a movie clip instance.
Page 492
Property Description MovieClip._target Read-only; the target path of a movie clip instance. Read-only; the total number of frames in a movie clip instance. MovieClip._totalframes A Boolean value that indicates whether other movie clips can MovieClip.trackAsMenu receive mouse release events. Read-only; the URL of the SWF file from which a movie clip MovieClip._url was downloaded.
Page 493
Event handler Description MovieClip.onLoad Invoked when the movie clip is instantiated and appears in the Timeline. Invoked when the left mouse button is pressed. MovieClip.onMouseDown MovieClip.onMouseMove Invoked every time the mouse is moved. Invoked when the left mouse button is released. MovieClip.onMouseUp Invoked when the mouse is pressed while the pointer is over MovieClip.onPress...
50% when the mouse rolls over the movie clip. Add the following ActionScript to holder_mc your FLA or AS file: this.createEmptyMovieClip("holder_mc", this.getNextHighestDepth()); holder_mc.createEmptyMovieClip("image_mc", holder_mc.getNextHighestDepth()); // replace with your own image or use the following holder_mc.image_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/ articles/nielsen/spotlight_jnielsen.jpg"); holder_mc.onRollOver = function() { this._alpha = 50; holder_mc.onRollOut = function() { this._alpha = 100;...
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 The object containing the audio to play. Valid values are a Microphone object, a source NetStream object that is playing an FLV file, and (stops playing the audio).
Page 496
// 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 audio source for a dynamically created movie clip instance called audio_mc var active_mic:Microphone = Microphone.get(); this.createEmptyMovieClip("audio_mc", this.getNextHighestDepth());...
MovieClip.attachMovie() Availability Flash Player 5. Usage my_mc.attachMovie(idName:String, newName:String, depth:Number [, initObject:Object]) : MovieClip Parameters The linkage name of the movie clip symbol in the library to attach to a movie clip idName on the Stage. This is the name entered in the Identifier field in the Linkage Properties dialog box. A unique instance name for the movie clip being attached to the movie clip.
10); square_mc.endFill(); An example is also in the drawingapi.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/HelpExamples/ See also MovieClip.beginGradientFill(), MovieClip.endFill()
MovieClip.beginGradientFill() Availability Flash Player 6. Usage my_mc.beginGradientFill(fillType:String, colors:Array, alphas:Array, ratios:Array, matrix:Object) : Void Parameter Either the string or the string fillType "linear" "radial" An array of RGB hex color values to be used in the gradient (for example, red is colors 0xFF0000, blue is 0x0000FF, and so on).
Page 500
If a property does not exist then the remaining parameters are all required; the matrixType 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). •...
Page 501
Returns Nothing. Description Method; indicates the beginning of a new drawing path. If the first parameter is or if undefined, 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 position specified in a method), and MovieClip.moveTo()
Page 502
endFill(); See also MovieClip.beginFill(), MovieClip.endFill(), MovieClip.lineStyle(), MovieClip.lineTo(), MovieClip.moveTo() Chapter 2: ActionScript Language Reference...
An example is also in the drawingapi.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/HelpExamples/ See also MovieClip.lineStyle() MovieClip.clear()
“Assigning a class to a movie clip symbol” in Using ActionScript in Flash. Example The following ActionScript creates a new movie clip at runtime and loads a JPEG image into the movie clip. this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth()); logo_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/ 80x92/studio_flashpro.jpg"); See also MovieClip.attachMovie() Chapter 2: ActionScript Language Reference...
MovieClip.createTextField() Availability Flash Player 6. Usage my_mc.createTextField(instanceName:String, depth:Number, x:Number, y:Number, width:Number, height:Number) : Void Parameters A string that identifies the instance name of the new text field. instanceName A positive integer that specifies the depth of the new text field. depth An integer that specifies the x coordinate of the new text field.
Page 506
= "This is my first test field object text."; my_txt.setTextFormat(my_fmt); An example is also in the animations.fla file in the HelpExamples folder. The following list gives typical paths to this folder: • Windows: \Program Files\Macromedia\Flash MX 2004\HelpExamples\ • Macintosh: HD/Applications/Macromedia Flash MX 2004/HelpExamples/ See also TextFormat class...
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 property to direct the playhead of the movie clip _currentframe to advance five frames ahead of its current location: actionClip_mc...
MovieClip.curveTo() Availability Flash Player 6. Usage my_mc.curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number) : Void Parameters An integer that specifies the horizontal position of the control point relative to the controlX registration point of the parent movie clip. An integer that specifies the vertical position of the control point relative to the controlY registration point of the parent movie clip.
Page 509
-Math.tan(Math.PI/8)*r+y, r+x, y); An example is also in the drawingapi.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/HelpExamples/ See also MovieClip.beginFill(), MovieClip.createEmptyMovieClip(), MovieClip.endFill(), MovieClip.lineStyle(), MovieClip.lineTo(),...
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 was dropped. The property always returns a path that starts with a my_mc _droptarget slash ( ).
MovieClip.duplicateMovieClip() Availability Flash Player 5. Usage my_mc.duplicateMovieClip(newname:String, depth:Number [,initObject:Object]) : MovieClip Parameters A unique identifier for the duplicate movie clip. newname A unique number specifying the depth at which the SWF file specified is to be placed. depth (Supported for Flash Player 6 and later.) An object containing properties with initObject which to populate the duplicated movie clip.
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 . If is set to , the movie clip’s callback methods and enabled true enabled false on action event handlers are no longer invoked, and the Over, Down, and Up frames are disabled.
10); square_mc.endFill(); An example is also in the drawingapi.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/HelpExamples/ See Also MovieClip.beginFill(), MovieClip.beginGradientFill(), MovieClip.moveTo()
MovieClip.focusEnabled Availability Flash Player 6. Usage my_mc.focusEnabled:Boolean Description Property; if the value is , a movie clip cannot receive input focus unless it is a undefined false button. If the property value is , a movie clip can receive input focus even if it focusEnabled true is not a button.
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 property. The _focusrect default value of the property of a movie clip instance is ;...
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 specific frame, and all the frames before it, have loaded and are available locally in the browser.
MovieClip.getBounds() Availability Flash Player 5. Usage my_mc.getBounds(targetCoordinateSpace:Object) : Object Parameters The target path of the Timeline whose coordinate system you want targetCoordinateSpace to use as a reference point. Returns An object with the properties , and xMin xMax yMin yMax. Description Method;...
Page 518
See also MovieClip.globalToLocal(), MovieClip.localToGlobal() Chapter 2: ActionScript Language Reference...
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 clip specified by . You can compare this value with the value returned by my_mc to determine what percentage of a movie clip has loaded.
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 by . For movie clips that are my_mc external (the root SWF file or a movie clip that is being loaded into a target or a level), the return value is the size of the SWF file.
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 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”...
“Assigning a class to a movie clip symbol” in Using ActionScript in Flash. Example The following example displays the depth occupied by the movie clip instance in the logo_mc Output panel: this.createEmptyMovieClip("logo_mc", 1); logo_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg"); trace(this.getInstanceAtDepth(1)); // output: _level0.logo_mc See also MovieClip.getDepth(), MovieClip.getNextHighestDepth(), MovieClip.swapDepths() 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 was published. my_mc Description Method; returns an integer that indicates the Flash Player version for which was published.
Note: You can’t specify a tab index value for static text in Flash. However, other products may do so (for example, Macromedia FlashPaper). The contents of the TextSnapshot object aren’t dynamic; that is, if the movie clip moves to a different frame, or is altered in some way (for example, objects in the movie clip are added or removed), the TextSnapshot object might not represent the current text in the movie clip.
Page 526
for (var i in textSnap) { text_mc.textSnapshot_txt.htmlText += "<b>"+i+"</b>\t"+textSnap[i]; text_mc.textSnapshot_txt.htmlText += "</textformat>"; The following text appears in text_mc.textSnapshot_txt getTextRunInfo[type Function] setSelectColor[type Function] findText[type Function] hitTestTextNearPos[type Function] getSelectedText[type Function] getText [type Function] getSelected[type Function] setSelected[type Function] getCount[type Function] See also TextSnapshot object Chapter 2: ActionScript Language Reference...
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 ActionScript creates a new movie clip instance and opens the Macromedia website in a new browser window: this.createEmptyMovieClip("loader_mc", this.getNextHighestDepth());...
MovieClip.globalToLocal() Availability Flash Player 5. Usage my_mc.globalToLocal(point:Object) : Void Parameters The name or identifier of an object created with the generic Object class. The object point specifies the x and y coordinates as properties. Returns Nothing. Description Method; converts the object from Stage (global) coordinates to the movie clip’s point (local) coordinates.
Page 529
See also MovieClip.getBounds(), MovieClip.localToGlobal() MovieClip.globalToLocal()
MovieClip.gotoAndPlay() Availability Flash Player 5. Usage my_mc.gotoAndPlay(frame:Object) : Void Parameters A number representing the frame number, or a string representing the label of the frame, frame to which the playhead is sent. Returns Nothing. Description Method; starts playing the SWF file at the specified frame. If you want to specify a scene as well as a frame, use gotoAndPlay() You can extend the methods and event handlers of the MovieClip class by creating a subclass.
MovieClip.gotoAndStop() Availability Flash Player 5. Usage my_mc.gotoAndStop(frame:Object) : Void Parameters The frame number to which the playhead is sent. frame Returns Nothing. Description Method; brings the playhead to the specified frame of the movie clip and stops it there. If you want to specify a scene in addition to a frame, use gotoAndStop() You can extend the methods and event handlers of the MovieClip class by creating a subclass.
The following code example displays the height and width of a movie clip in the Output panel: this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); var image_mcl:MovieClipLoader = new MovieClipLoader(); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+" pixels"); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg", image_mc); See Also MovieClip._width Chapter 2: ActionScript Language Reference...
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 , the movie clip itself is used as the hit area. The null undefined value of the...
MovieClip.hitTest() Availability Flash Player 5. Usage my_mc.hitTest(x:Number, y:Number, shapeFlag:Boolean) : Boolean my_mc.hitTest(target:Object) : Boolean Parameters The x coordinate of the hit area on the Stage. The y coordinate of the hit area on the Stage. The x and y coordinates are defined in the global coordinate space. The target path of the hit area that may intersect or overlap with the instance specified target .
Page 535
See also MovieClip.getBounds(), MovieClip.globalToLocal(), MovieClip.localToGlobal() MovieClip.hitTest()
MovieClip.lineStyle() Availability Flash Player 6. Usage my_mc.lineStyle([thickness:Number[, rgb:Number[, alpha:Number]]]) : Void Parameters An integer that indicates the thickness of the line in points; valid values are 0 to thickness 255. If a number is not specified, or if the parameter is , a line is not drawn.
MovieClip.lineTo() Availability Flash Player 6. Usage my_mc.lineTo(x:Number, y:Number) : Void Parameters An integer indicating the horizontal position relative to the registration point of the parent movie clip. An integer indicating the vertical position relative to the registration point of the parent movie clip.
MovieClip.loadMovie() Availability Flash Player 5. Usage my_mc.loadMovie(url:String [,variables:String]) : Void Parameters 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 level 0. Absolute URLs must include the protocol reference, such as http:// or file:///.
Page 539
// creates a child movie clip inside of "mc_1" // this is the movie clip the image will replace logo_mc.createEmptyMovieClip("container_mc",0); logo_mc.container_mc.loadMovie("http://www.macromedia.com/images/shared/ product_boxes/80x92/studio_flashpro.jpg"); // put event handler on the parent movie clip mc_1 logo_mc.onPress = function() { trace("It works");...
MovieClip.loadVariables() Availability Flash Player 5; behavior changed in Flash Player 7. Usage my_mc.loadVariables(url:String [, variables:String]) : Void Parameters The absolute or relative URL for the external file that contains the variables to be loaded. If the SWF file issuing this call is running in a web browser, must be in the same domain as the SWF file;...
Page 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 params.txt into the target_mc movie clip that is created using .
MovieClip.localToGlobal() Availability Flash Player 5. Usage my_mc.localToGlobal(point:Object) : Void Parameters The name or identifier of an object created with the Object class, specifying the x and y point coordinates as properties. Returns Nothing. Description Method; converts the object from the movie clip’s (local) coordinates to the Stage point (global) coordinates.
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 property is by default. You can set this property within the SWF file that _lockroot undefined is being loaded or in the handler that is loading the movie clip.
Page 544
_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 Timeline: _root.myVar = 1; _root.myOtherVar = 2;...
Page 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 nolockroot.swf myOtherVar -> 2 myVar -> 1 from lockroot.swf myOtherVar -> 2 myVar ->...
MovieClip.menu Availability Flash Player 7. Usage my_mc.menu:ContextMenu = contextMenu Parameters A ContextMenu object. contextMenu Description Property; associates the specified ContextMenu object with the movie clip . The my_mc ContextMenu class lets you modify the context menu that appears when the user right-clicks (Windows) or Control-clicks (Macintosh) in Flash Player.
MovieClip.moveTo() Availability Flash Player 6. Usage my_mc.moveTo(x:Number, y:Number) : Void Parameters An integer indicating the horizontal position relative to the registration point of the parent movie clip. An integer indicating the vertical position relative to the registration point of the parent movie clip.
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 select “Info...” from the context menu to view information about that instance. Add several movie clips with instance names, and then add the following ActionScript to your AS or FLA file: var menu_cm:ContextMenu = new ContextMenu();...
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 subclass. For more information, see “Assigning a class to a movie clip symbol”...
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() call. You must define a function that executes when the event handler MovieClip.loadMovie() is invoked.
Page 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() MovieClip.onData...
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 object. You must define a function that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 associated with event are processed before any frame actions that are attached to the affected enterFrame frames.
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 with no parameters. You can use the Key.getAscii() methods to determine which key was pressed.
Page 556
When you tab to the movie clip and press a key, displays in the Output panel. key was pressed However, this does not occur after you move the mouse, because the movie clip loses focus. Therefore, you should use in most cases. Key.onKeyDown See also MovieClip.onKeyUp...
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 event handler is invoked with no onKeyUp parameters. You can use the methods to determine which Key.getAscii() Key.getCode()
MovieClip.onKillFocus Availability Flash Player 6. Usage my_mc.onKillFocus = function (newFocus:Object) { // your statements here Parameters The object that is receiving the keyboard focus. newFocus Returns Nothing. Description Event handler; invoked when a movie clip loses keyboard focus. The method onKillFocus receives one parameter, , which is an object that represents the new object receiving the...
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 executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
Page 560
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 image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc); See also onClipEvent(), MovieClipLoader class Chapter 2: ActionScript Language Reference...
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 handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 must define a function that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 clip area and then released outside the movie clip area. You must define a function that executes when the event handler is invoked.
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 the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
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 function that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
MovieClip.onSetFocus Availability Flash Player 6. Usage my_mc.onSetFocus = function(oldFocus){ // your statements here Parameters The object to lose focus. oldFocus Returns Nothing. Description Event handler; invoked when a movie clip receives keyboard focus. The parameter is oldFocus the object that loses the focus. For example, if the user presses the Tab key to move the input focus from a movie clip to a text field, contains the movie clip instance.
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. Flash processes the actions associated with the event handler before attaching any actions to onUnload the affected frame.
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 references . Use _parent property to specify a relative path to movie clips or objects that are above the current _parent...
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 creating a subclass. For more information, see “Assigning a class to a movie clip symbol”...
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 subclass. For more information, see “Assigning a class to a movie clip symbol”...
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 property. _quality property can be set to the following values: _quality •...
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(), MovieClip.attachMovie() 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”...
= 450 my_mc._rotation = 90 Example The following example creates a movie clip instance dynamically, rotates, and loads an image into the instance. this.createEmptyMovieClip("image_mc", 1); image_mc._rotation = 15; image_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg"); See also Button._rotation, TextField._rotation Chapter 2: ActionScript Language Reference...
MovieClip.setMask() Availability Flash Player 6. Usage my_mc.setMask(mask_mc:Object) : Void Parameters The instance name of a movie clip to be masked. my_mc The instance name of a movie clip to be a mask. mask_mc Returns Nothing. Description Method; makes the movie clip in the parameter a mask that reveals the movie clip mask_mc specified by the...
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 property for a MovieClip object, it is actually a global property, and you can specify its value simply as _soundbuftime.
MovieClipLoader object is used to load an image into image_mc this.createEmptyMovieClip("image_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { target_mc.onPress = function() { this.startDrag(); target_mc.onRelease = function() { this.stopDrag(); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg", image_mc); See also MovieClip._droptarget, startDrag(), MovieClip.stopDrag() MovieClip.startDrag()
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 subclass. For more information, see “Assigning a class to a movie clip symbol” in Using ActionScript in Flash. Example The following example shows how to stop a movie clip named aMovieClip...
MovieClipLoader object is used to load an image into image_mc this.createEmptyMovieClip("image_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { target_mc.onPress = function() { this.startDrag(); target_mc.onRelease = function() { this.stopDrag(); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg", image_mc); See also MovieClip._droptarget, MovieClip.startDrag(), stopDrag() MovieClip.stopDrag()
MovieClip.swapDepths() Availability Flash Player 5. Usage my_mc.swapDepths(depth:Number) my_mc.swapDepths(target:String) Parameters A number specifying the depth level where is to be placed. depth my_mc A string specifying the movie clip instance whose depth is swapped by the instance target specified by . Both instances must have the same parent movie clip. my_mc Returns Nothing.
MovieClip.tabChildren Availability Flash Player 6. Usage my_mc.tabChildren:Boolean Description Property; by default. If , the children of a movie undefined tabChildren undefined true clip are included in automatic tab ordering. If the value of , the children of tabChildren false a movie clip are not included in automatic tab ordering. Example A list box UI widget built as a movie clip contains several items.
MovieClip.tabEnabled Availability Flash Player 6. Usage my_mc.tabEnabled:Boolean Description Property; specifies whether is included in automatic tab ordering. It is my_mc undefined by default. , the object is included in automatic tab ordering only if it defines at tabEnabled undefined least one movie clip handler, such as .
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 property is tabIndex by default. You can set on a button, movie clip, or text field instance. undefined tabIndex If an object in a SWF file contains a property, automatic tab ordering is disabled, and tabIndex...
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 in slash my_mc notation. Use the function to convert the target path to dot notation. eval() Example The following example displays the target paths of movie clip instances in a SWF file, in both slash and dot notation.
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 parameter. MovieClip Example In the following example, two movie clip buttons control the Timeline. The button prev_mc moves the playhead to the previous frame, and the button moves the playhead to the...
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 can set the property on trackAsMenu any button or movie clip object.
“Assigning a class to a movie clip symbol” in Using ActionScript in Flash. Example The following example unloads a movie clip instance called when a user clicks the image_mc instance. unloadMC_btn this.createEmptyMovieClip("image_mc", 1); image_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg"); unloadMC_btn.onRelease = function() { image_mc.unloadMovie(); See also MovieClip.attachMovie(), MovieClip.loadMovie(), unloadMovie(), unloadMovieNum() MovieClip.unloadMovie()
1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace("_url: "+target_mc._url); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg", image_mc); The following example assigns the ContextMenu object to the movie clip menu_cm image_mc The ContextMenu object contains a custom menu item labeled “View Image in Browser...” that...
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 . If useHandCursor true is set to , the pointing hand used for buttons is displayed when the mouse useHandCursor true...
MovieClip._visible Availability Flash Player 4. Usage my_mc._visible:Boolean Description Property; a Boolean value that indicates whether the movie clip specified by is visible. my_mc Movie clips that are not visible ( property set to ) are disabled. For example, a _visible false button in a movie clip with set to...
The following code example displays the height and width of a movie clip in the Output panel: this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); var image_mcl:MovieClipLoader = new MovieClipLoader(); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+" pixels"); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg", image_mc); See also MovieClip._height MovieClip._width...
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 coordinate system refers to the upper left corner of the Stage as (0, 0).
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 coordinates of the mouse on the Stage ) and in relation to a movie clip on the Stage called _level0 my_mc this.createTextField("mouse_txt", this.getNextHighestDepth, 0, 0, 150, 66);...
MovieClip._xscale Availability Flash Player 4. Usage my_mc._xscale:Number Description Property; determines the horizontal scale ( ) of the movie clip as applied from the percentage registration point of the movie clip. The default registration point is (0,0). Scaling the local coordinate system affects the property settings, which are defined in whole pixels.
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 of the Stage as (0, 0).
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 coordinates of the mouse on the Stage ) and in relation to a movie clip on the Stage called _level0 my_mc this.createTextField("mouse_txt", this.getNextHighestDepth, 0, 0, 150, 66);...
MovieClip._yscale Availability Flash Player 4. Usage my_mc._yscale:Number Description Property; sets the vertical scale ( ) of the movie clip as applied from the registration percentage point of the movie clip. The default registration point is (0,0). Scaling the local coordinate system affects the property settings, which are defined in whole pixels.
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 MovieClipLoader.loadClip() instead of to load...
Page 601
Listener summary for the MovieClipLoader class Listener Description Invoked when a file loaded with MovieClipLoader.onLoadComplete MovieClipLoader.loadClip() has completely downloaded. Invoked when a file loaded with MovieClipLoader.onLoadError MovieClipLoader.loadClip() has failed to load. MovieClipLoader.onLoadInit Invoked when the actions on the first frame of the loaded clip have been executed.
MovieClipLoader.loadClip() Availability Flash Player 7. Usage my_mcl.loadClip(url:String, target:Object ) : Boolean Parameters 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 level 0. Absolute URLs must include the protocol reference, such as http:// or file:///.
Page 605
do not MovieClipLoader.getProgress() MovieClipLoaderListener.onLoadProgress report the actual values in the Authoring player when the files are bytesLoaded bytesTotal local. When you use the Bandwidth Profiler feature in the authoring environment, report MovieClipLoader.getProgress() MovieClipLoaderListener.onLoadProgress the download at the actual download rate, not at the reduced bandwidth rate that the Bandwidth Profiler provides.
Page 606
= 200; // loads into _level1 my_mcl.loadClip("http://www.macromedia.com/devnet/images/160x160/ mike_chambers.jpg", 1); // Second set of listeners var another_mcl:MovieClipLoader = new MovieClipLoader(); var myListener2:Object = new Object(); myListener2.onLoadStart = function(target_mc:MovieClip) { trace("*********Second my_mcl instance*********"); trace("Your load has begun on movie = "+target_mc);...
MovieClipLoader.onLoadComplete Availability Flash Player 7. Usage listenerObject.onLoadComplete = function([target_mc:Object]) { // your statements here Parameters A listener object that was added using MovieClipLoader.addListener(). listenerObject A movie clip loaded by a MovieClipLoader.loadClip() method. This parameter is target_mc optional. Returns Nothing. Description Listener;...
Page 608
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(mclListener); image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg", image_mc); See also MovieClipLoader.addListener(), MovieClipLoader.onLoadStart, MovieClipLoader.onLoadError Chapter 2: ActionScript Language Reference...
MovieClipLoader.onLoadError Availability Flash Player 7. Usage listenerObject.onLoadError = function(target_mc:Object, errorCode:String) { // your statements here Parameters A listener object that was added using MovieClipLoader.addListener(). listenerObject A movie clip loaded by a MovieClipLoader.loadClip() method. target_mc A string that explains the reason for the failure. errorCode Returns One of two strings:...
Page 610
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.loadClip("http://www.fakedomain.com/images/bad_hair_day.jpg", image_mc); Chapter 2: ActionScript Language Reference...
MovieClipLoader.onLoadProgress Availability Flash Player 7. Usage listenerObject.onLoadProgress = function([target_mc:Object [, loadedBytes:Number [, totalBytes:Number ] ] ] // your statements here Parameters A listener object that was added using MovieClipLoader.addListener(). listenerObject A movie clip loaded by a MovieClipLoader.loadClip() method. This parameter is target_mc optional.
= getTimer(); mclListener.onLoadComplete = function(target_mc:MovieClip) { target_mc.completeTimer = getTimer(); mclListener.onLoadInit = function(target_mc:MovieClip) { var timerMS:Number = target_mc.completeTimer-target_mc.startTimer; target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, target_mc._width, 22); target_mc.timer_txt.text = "loaded in "+timerMS+" ms."; var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg", image_mc); MovieClipLoader.onLoadStart...
Page 616
See also MovieClipLoader.onLoadError, MovieClipLoader.onLoadInit, MovieClipLoader.onLoadComplete Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference Availability Flash Player 5. Usage Description Variable; a predefined variable with the IEEE-754 value for (not a number). To determine if a number is , use isNaN() See also isNaN(), Number.NaN Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference -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 -Infinity...
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 provides the means to play back streaming FLV files from a local drive or HTTP address.
Page 623
See also NetStream class, Video.attachVideo() NetConnection class...
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) : Void Parameters None (you must pass null Returns Nothing.
CHAPTER 2 ActionScript Language Reference 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 playing Flash Video (FLV) files from the local file system or an HTTP address.
Page 626
Event handler summary for the NetStream class Event handler Description Invoked every time a status change or error is posted for the NetStream.onStatus NetStream object. 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 Communication Server documentation.
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-only property; the number of seconds of data currently in the buffer. You can use this property in conjunction with NetStream.bufferTime to estimate how close the buffer is to being...
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 Description Read-only property; the number of seconds assigned to the buffer by NetStream.setBufferTime(). The default value is .1(one-tenth of a second).
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 buffer is to being full—for example, to display feedback to a user who is waiting for data to be loaded into the buffer.
Page 630
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns); function checkBytesLoaded(my_ns:NetStream) { var pctLoaded:Number = Math.round(my_ns.bytesLoaded/my_ns.bytesTotal*100); loaded_txt.text = Math.round(my_ns.bytesLoaded/1000)+" of "+Math.round(my_ns.bytesTotal/1000)+" KB loaded ("+pctLoaded+"%)"; progressBar_mc.bar_mc._xscale = pctLoaded; if (pctLoaded>=100) { clearInterval(loaded_interval); See also NetStream.bufferLength Chapter 2: ActionScript Language Reference...
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 properties that displays the loading progress of video1.flv into the video object bytesTotal instance called .
Page 632
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.bytesLoaded, NetStream.bufferTime Chapter 2: ActionScript Language Reference...
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. Description Method; stops playing all data on the stream, sets the NetStream.time property to 0, and makes the stream available for another use.
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 Description Read-only property; the number of frames per second being displayed. If you are exporting FLV files to be played back on a number of systems, you can check this value during testing to help you determine how much compression to apply when exporting the file.
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{ // Your code here Parameters A parameter defined according to the status or error message.
Page 636
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); stream_ns.play("video1.flv"); stream_ns.onStatus = function(infoObject:Object) { trace("NetStream.onStatus called: ("+getTimer()+" ms)"); for (var prop in infoObject) { trace("\t"+prop+":\t"+infoObject[prop]);...
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 A Boolean value specifying whether to pause play ( ) or resume play ( pauseResume true...
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); Parameters The name of an FLV file to play, in quotation marks. Both http:// and file:// formats fileName are supported;...
Page 639
See also MovieClip.attachAudio(), NetStream.close(), NetStream.pause(), Video.attachVideo() NetStream.play()
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:Number) : Void Parameters The approximate time value, in seconds, to move to in an FLV file. The numberOfSeconds playhead moves to the keyframe of the video that’s closest to numberOfSeconds...
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:Number) : Void Parameters The number of seconds of data to be buffered before Flash begins displaying numberOfSeconds data.
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 Read-only property; the position of the playhead, in seconds. Example The following example displays the current position of the playhead in a dynamically created text field called...
CHAPTER 2 ActionScript Language Reference Availability Flash Player 5. Usage new constructor() Parameters A function followed by any optional parameters in parentheses. The function is constructor usually the name of the object type (for example, Array, Number, or Object) to be constructed. Returns Nothing.
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 to make space for information that is retrieved by a newline function or statement in your code.
CHAPTER 2 ActionScript Language Reference 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.
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 runtime, the playhead is sent to Frame 1 of the next scene.
CHAPTER 2 ActionScript Language Reference 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 to represent values that are missing or that do not have a defined null data type.
CHAPTER 2 ActionScript Language Reference Number() Availability Flash Player 4; behavior changed in Flash Player 7. Usage Number(expression) : Number Parameters An expression to convert to a number. expression Returns A number or (not a number). Description Function; converts the parameter to a number and returns a value as described in the expression following list:...
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 by using the methods and properties associated with the Number class.
Page 651
Constructor for the Number class Availability Flash Player 5. Usage new Number(value:Number) : Number Parameters The numeric value of the Number object being created or a value to be converted to value a number. The default value is 0 if is not provided.
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 largest and smallest representable numbers to the Output panel. trace("Number.MIN_VALUE = "+Number.MIN_VALUE); trace("Number.MAX_VALUE = "+Number.MAX_VALUE); This code displays the following values: Number.MIN_VALUE = 4.94065645841247e-324 Number.MAX_VALUE = 1.79769313486232e+308...
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 numbers to the Output panel. trace("Number.MIN_VALUE = "+Number.MIN_VALUE); trace("Number.MAX_VALUE = "+Number.MAX_VALUE); This code displays the following values: Number.MIN_VALUE = 4.94065645841247e-324 Number.MAX_VALUE = 1.79769313486232e+308...
Number.NaN Availability Flash Player 5. Usage Number.NaN Description Property; the IEEE-754 value representing Not A Number ( See also isNaN(), Chapter 2: ActionScript Language Reference...
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 special numeric value that is returned when a mathematical operation or function returns a negative value larger than can be represented.
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 infinity is a special numeric value that is returned when a mathematical operation or function returns a value larger than can be represented.
Number.toString() Availability Flash Player 5; behavior changed in Flash Player 7. Usage myNumber.toString(radix:Number) : String Parameters Specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If radix you do not specify the parameter, the default value is 10. radix Returns A string.
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 value of the object. numSocks var numSocks = new Number(2); trace(numSocks.valueOf());...
Example In the following example, a new empty object is created, and then the object is populated with values: var company:Object = new Object(); company.name = "Macromedia, Inc."; company.address = "600 Townsend Street"; company.city = "San Francisco"; company.state = "CA";...
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 features provided by the JavaScript Object class.
Page 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 property. constructor Example The following example creates a generic object named myObject: var myObject:Object = new Object(); Object class...
Object.addProperty() Availability Flash Player 6. In ActionScript 2.0 classes, you can use instead of this method. Usage myObject.addProperty(prop:String, getFunc:Function, setFunc:Function) : Boolean Parameters A string; the name of the object property to create. prop The function that is invoked to retrieve the value of the property; this parameter is a getFunc Function object.
Page 663
Error condition What happens is not a valid function object. Returns and the property is not added. getFunc false is not a valid function object. Returns and the property is not added. setFunc false Example In the following example, an object has two internal methods, setQuantity() .
Page 664
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+" copies of "+myBook.bookname); The following example shows how to use the implicit getter and setter functions available in ActionScript 2.0. For more information, see “Implicit getter/setter methods” in Using ActionScript in Flash.Rather than defining the function and editing , you define the...
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 the Object class. Example The following example is a reference to the constructor function for the object.
Object.__proto__ Availability Flash Player 5. Usage myObject.__proto__ Description Property; refers to the property of the constructor function that created prototype myObject property is automatically assigned to all objects when they are created. The __proto__ ActionScript interpreter uses the property to access the property of __proto__ prototype...
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 information, see “Assigning a class to a movie clip symbol”.
Object.__resolve Availability Flash Player 6. Usage myObject.__resolve = function (name:String) { // your statements here Parameters A string representing the name of the undefined property. name Returns Nothing Description Property; a reference to a user-defined function that is invoked if ActionScript code refers to an undefined property or method.
Page 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); }; // test __resolve using undefined method names myObject.someMethod();...
Page 670
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 __resolve is called // Not only call the function, but also save a reference to it var f:Function = function () { this.myFunction(name);...
Page 671
myObject.someOtherMethod("hello","world"); // output: Method someOtherMethod was called with arguments: hello,world Object.__resolve...
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() on a generic object: var myObject:Object = new Object(); trace(myObject.toString());...
Page 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");...
Object.unwatch() Availability Flash Player 6. Usage myObject.unwatch (prop:String) : Boolean Parameters A string; the name of the object property that should no longer be watched. prop Returns A Boolean value: if the watchpoint is successfully removed, otherwise. true false Description Method;...
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 primitive value, the object is returned.
Object.watch() Availability Flash Player 6. Usage myObject.watch( prop:String, callback:Function [, userData:Object] ) : Boolean Parameters A string; the name of the object property to watch. prop The function to invoke when the watched property changes. This parameter is a callback function object, not a function name as a string.
Page 677
method behaves similarly to the function in JavaScript Object.watch() Object.watch() 1.2 and later. The primary difference is the parameter, which is a Flash addition to userData that Netscape Navigator does not support. You can pass the Object.watch() userData parameter to the event handler and use it in the event handler. method cannot watch getter/setter properties.
CHAPTER 2 ActionScript Language Reference on() Availability Flash 2. Not all events are supported in Flash 2. Usage on(mouseEvent) { // your statements here Parameters The instructions to execute when the occurs. statement(s) mouseEvent is a trigger called an event. When the event occurs, the statements following it mouseEvent within curly braces ({ }) execute.
Page 679
on (release) { trace("X:"+this._x); trace("Y:"+this._y); stopDrag(); See also onClipEvent() on()
CHAPTER 2 ActionScript Language Reference onClipEvent() Availability Flash Player 5. Usage onClipEvent(movieEvent){ // your statements here Parameters is a trigger called an event. When the event occurs, the statements following it movieEvent within curly braces ({}) are executed. Any of the following values can be specified for the parameter: movieEvent •...
Page 681
Example The following example uses with the movie event and is designed to be onClipEvent() keyDown attached to a movie clip or button. The movie event is usually used with one or more keyDown methods and properties of the Key object. The following script uses to find out Key.getCode() which key the user has pressed;...
CHAPTER 2 ActionScript Language Reference onUpdate Availability Flash Player 6. Usage function onUpdate() { ...statements...; Parameters None. Returns Nothing. Description Event handler; is defined for a Live Preview used with a component. When an instance onUpdate of a component on the Stage has a Live Preview, the authoring tool invokes the Live Preview’s function whenever the component parameters of the component instance change.
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 containing the ActionScript code that references .
CHAPTER 2 ActionScript Language Reference parseFloat() Availability Flash Player 5. Usage parseFloat(string:String) : Number Parameters The string to read and convert to a floating-point number. string Returns A number or (not a number). Description Function; converts a string to a floating-point number. The function reads, or parses, and returns the numbers in a string until it reaches a character that is not a part of the initial number.
CHAPTER 2 ActionScript Language Reference parseInt() Availability Flash Player 5. Usage parseInt(expression:String [, radix:Number]) : Number Parameters A string to convert to an integer. expression An integer representing the radix (base) of the number to parse. Legal values are from 2 radix to 36.
Page 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() parseInt()
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 names .
CHAPTER 2 ActionScript Language Reference 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 and the following ActionScript is placed on a myBtn_btn frame in the Timeline for that button, the playhead is sent to the previous frame:...
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...
CHAPTER 2 ActionScript Language Reference 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.
Page 692
The following example prints all the printable frames in with a print area defined by holder_mc the bounding box of each frame: this.createEmptyMovieClip("holder_mc", 999); holder_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg"); this.myBtn_btn.onRelease = function() { print(this._parent.holder_mc, "bframe"); In the previous ActionScript, you could replace with...
If your movie clip does not contain alpha transparencies or color effects, Macromedia recommends that you use print() for better quality results.
Page 694
PostScript printers convert vectors to bitmaps. Example The following example prints all the printable frames in with a print area defined by holder_mc the bounding box of the frame: this.createEmptyMovieClip("holder_mc", 999); holder_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ back_button/sp_mchambers.jpg"); this.myBtn_btn.onRelease = function() { printAsBitmap(this._parent.holder_mc, "bframe"); See also print(), printAsBitmapNum(), PrintJob...
CHAPTER 2 ActionScript Language Reference 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.
Page 696
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 . The area to print is defined by the bounding box of the frame. myBtn_btn myBtn_btn.onRelease = function(){ printAsBitmapNum(0, "bframe")
CHAPTER 2 ActionScript Language Reference 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 method, lets you render print() dynamic content offscreen, prompt users with a single Print dialog box, and print an unscaled...
Page 698
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 to the method calls with your custom [params] my_pj.addPage() parameters.
PrintJob.addPage() Availability Flash Player 7. Usage my_pj.addPage(target:Object [, printArea:Object] [, options:Object ] [, frameNumber:Number]) : Boolean Parameters A number or string; the level or instance name of the movie clip to print. Pass a number target to specify a level (for example, 0 is the movie), or a string (in quotation marks [""]) to _root specify the instance name of a movie clip.
Page 700
• If the content that you’re printing includes a bitmap image, use {printAsBitmap:true} include any transparency and color effects. • If the content does not include bitmap images, omit this parameter or use to print the content in higher quality vector format. {printAsBitmap:false} is omitted or is passed incorrectly, vector printing is used.
Page 701
Example The following example shows several ways to issue the command: addPage() 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.addPage(0)){ pageCount++;...
Page 702
// 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() Chapter 2: ActionScript Language Reference...
PrintJob.send() Availability Flash Player 7. Usage my_pj.send() : Void Parameters None. Returns Nothing. Description Method; used following PrintJob.start() PrintJob.addPage() to send spooled pages to the printer. Because calls to will not be successful if related calls to PrintJob.send() failed, you should check that calls to PrintJob.start() PrintJob.addpage() were successful before calling...
PrintJob.start() Availability Flash Player 7. Usage my_pj.start() : Boolean Parameters None. Returns A Boolean value: if the user clicks OK when the print dialog boxes appear; if the user true false clicks Cancel or if an error occurs. Description Method; displays the operating system’s print dialog boxes and starts spooling. The print dialog boxes let the user change print settings.
Page 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 PrintJob(); // display print dialog box if (my_pj.start()) { // boolean to track whether addPage succeeded, change this to a counter...
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.
CHAPTER 2 ActionScript Language Reference 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
import Login: var gus:Login = new Login("Gus", "Smith"); trace(gus.username); // output: Gus trace(gus.password); // output: undefined trace(gus.loginPassword); // error Because is a private variable, you cannot access it from outside the Login.as class loginPassword file. Attempts to access the private variable generate an error message. See also public, static...
CHAPTER 2 ActionScript Language Reference 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.
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 property. _quality property can be set to the following values: _quality •...
. Images are loaded into both movie clips. When a newClip_mc button, , is clicked, the duplicated movie clip is removed from the Stage. button_mc this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth()); myClip_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ server_side/jeremy_gray.jpg"); duplicateMovieClip(this.myClip_mc, "newClip_mc", this.getNextHighestDepth()); newClip_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ performance/spotlight_speterson.jpg"); newClip_mc._x = 200; this.button_mc.onRelease = function() { removeMovieClip(this._parent.newClip_mc);...
CHAPTER 2 ActionScript Language Reference return Availability Flash Player 5. Usage return[expression] Parameters A string, number, Boolean, array, or object to evaluate and return as a value of the expression function. This parameter is optional. Returns The evaluated parameter, if provided. expression Description Statement;...
CHAPTER 2 ActionScript Language Reference _root Availability Flash Player 5. Usage _root.movieClip _root.action _root.property Parameters The instance name of a movie clip. movieClip An action or method. action A property of the MovieClip object. property Description Identifier; specifies or returns a reference to the root movie clip Timeline. If a movie clip has multiple levels, the root movie clip Timeline is on the level containing the currently executing script.
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 first position is 0, the second position is 1, and so on).
Selection.addListener() Availability Flash Player 6. Usage Selection.addListener(newListener:Object) : Void Parameters An object with an method. newListener onSetFocus Returns None. Description Method; registers an object to receive keyboard focus change notifications. When the focus changes (for example, whenever Selection.setFocus() is invoked), all listening objects registered with have their method invoked.
= my_cm; An example can also be found in the Strings.fla file in the HelpExamples Folder. Typical paths to this folder are: Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\ Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/ See Also Selection.getEndIndex() Chapter 2: ActionScript Language Reference...
Mouse.addListener(mouseListener); function getCaretPos() { pos_txt.text = Selection.getCaretIndex(); An example can also be found in the Strings.fla file in the HelpExamples Folder. Typical paths to this folder are: • Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\ • Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/ Selection.getCaretIndex()
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 currently focused selection span, the method returns -1. Selection span indexes are zero-based (for example, the first position is 0, the second position is 1, and so on).
Page 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.getBeginIndex() Selection.getEndIndex()
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 specifying the target path of the object that has focus. •...
Selection.onSetFocus Availability Flash Player 6. Usage someListener.onSetFocus = function( [ oldFocus:Object [, newFocus:Object ] ]){ // statements; Parameters The object losing focus. This parameter is optional. oldfocus The object receiving focus. This parameter is optional. newfocus Description Listener; notified when the input focus changes. To use this listener, you must create a listener object.
Selection.removeListener() Availability Flash Player 6. Usage Selection.removeListener(listener:Object) Parameters The object that will no longer receive focus notifications. listener Returns was successfully removed, the method returns a value. If was not listener true listener successfully removed—for example, if was not on the Selection object’s listener list— listener the method returns a value of false...
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 A string specifying the path to a button, movie clip, or text field instance. instanceName Returns A Boolean value; if the focus attempt is successful, if it fails.
Page 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); return true; See also Selection.getFocus(), Selection.onSetFocus Selection.setFocus()
Selection.setSelection() Availability Flash Player 5. Usage Selection.setSelection(start:Number, end:Number) : Void Parameters The beginning index of the selection span. start The ending index of the selection span. Returns Nothing. Description Method; sets the selection span of the currently focused text field. The new selection span will begin at the index specified in the parameter, and end at the index specified in the start...
CHAPTER 2 ActionScript Language Reference 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 in external script files, not in scripts written in the Actions panel.
Page 728
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); // output: Rupert In the following example, the function executes when the value is traced.
CHAPTER 2 ActionScript Language Reference set variable Availability Flash Player 4. Usage set("variableString", expression) Parameters A string that names a variable to hold the value of the parameter. variableString expression A value assigned to the variable. expression Returns Nothing. Description Statement;...
Page 730
set("name", "Jakob"); trace(name); The following code loops three times and creates three new variables, called caption0 caption1 caption2 for (var i = 0; i<3; i++) { set("caption"+i, "this is caption "+i); trace(caption0); trace(caption1); trace(caption2); See also var, call() Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference setInterval() Availability Flash Player 6. Usage setInterval(functionName:Function, interval:Number [, param1:Object, param2, ..., paramN]) : Number Parameters A function name or a reference to an anonymous function. functionName The time in milliseconds between calls to the parameter.
Page 732
*/ target_mc.onRelease = function() { trace("clear interval"); // clearInterval(this.myInterval); // delete the target movie clip removeMovieClip(this); var jpeg_mcl:MovieClipLoader = new MovieClipLoader(); jpeg_mcl.addListener(listenerObject); jpeg_mcl.loadClip("http://www.macromedia.com/software/central/images/ klynch_breezo.jpg", this.createEmptyMovieClip("jpeg_mc", this.getNextHighestDepth())); Chapter 2: ActionScript Language Reference...
Page 733
If you work with within classes, you need to be sure to use the keyword setInterval() this when you call the function. The function does not have access to class members setInterval() if you do not use the keyword. This is illustrated in the following example. For a FLA file with a button called add the following ActionScript to Frame 1: deleteUser_btn,...
. When you click the button called setProperty() , the coordinate of a movie clip named is incremented by 20 pixels. right_btn params_mc this.createEmptyMovieClip("params_mc", 999); params_mc.loadMovie("http://www.macromedia.com/devnet/mx/blueprint/articles/ nielsen/spotlight_jnielsen.jpg"); setProperty(this.params_mc, _y, 20); setProperty(this.params_mc, _x, 20); this.right_btn.onRelease = function() { setProperty(params_mc, _x, getProperty(params_mc, _x)+20); See also getProperty()
CHAPTER 2 ActionScript Language Reference 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 local persistence. For example, you can call to create a shared object, such as a calculator with memory, in the SharedObject.getLocal() player.
Page 736
• If the user selects None (moves the slider all the way to the left), all SharedObject.flush() commands issued for the object return and the player asks the user if additional "pending", disk space can be allotted to make room for the object. •...
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 is still active, and is now empty. my_so my_so Example...
SharedObject.data Availability Flash Player 6. Usage myLocalSharedObject.data:Object Description Property; the collection of attributes assigned to the property of the object; these attributes data can be shared and/or stored. Each attribute can be an object of any basic ActionScript or JavaScript type—Array, Number, Boolean, and so on. For example, the following lines assign values to various aspects of a shared object: var items_array:Array = new Array(101, 346, 483);...
Page 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 (for the complete example, see SharedObject.getLocal()): my_so // create listener object and function for <enter>...
SharedObject.flush() Availability Flash Player 6. Usage myLocalSharedObject.flush([minimumDiskSpace:Number]) : Boolean Parameters An optional integer specifying the number of bytes that must be allotted minimumDiskSpace for this object. The default value is 0. Returns A Boolean value: , or a string value of , as described in the following list: true false...
Page 741
Example The following function gets a shared object, and fills writable properties with user- my_so, provided settings. Finally, is called to save the settings and allot a minimum flush() of 1000 bytes of disk space. this.syncSettingsCore = function(soName:String, override:Boolean, settings:Object) { var my_so:SharedObject = SharedObject.getLocal(soName, "http:// www.mydomain.com/app/sys");...
SharedObject.getLocal() Availability Flash Player 6. Usage SharedObject.getLocal(objectName:String [, localPath:String]) : SharedObject Note: The correct syntax is . To assign the object to a variable, use syntax like SharedObject.getLocal myLocal_so = SharedObject.getLocal Parameters A string that represents the name of the object. The name can include forward objectName slashes ( );...
Page 743
Although the parameter is optional, developers should give some thought to its use, localPath 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, then use of the default value makes sense.
Page 744
// 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 frame, call the rememberme function to save the frame number. function rememberme() { my_so.data.frame=this._currentframe;...
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 calculates the size of a shared object by stepping through each of its data properties; the more data properties the object has, the longer it takes to estimate its size.
SharedObject.onStatus Availability Flash Player 6. Usage myLocalSharedObject.onStatus = function(infoObject:Object) { // your statements here Parameters A parameter defined according to the status message. infoObject Returns Nothing. Description Event handler; invoked every time an error, warning, or informational note is posted for a shared object.
Page 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:SharedObject = SharedObject.getLocal("superfoo"); my_so.data.itemNumbers = items_array; my_so.data.adminPrivileges = currentUserIsAdmin; my_so.data.userName = currentUserName; my_so.onStatus = function(infoObject:Object) { status_txt.htmlText = "<textformat tabStops='[50]'>";...
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 create a new Sound object, you can use the methods to control sound for the whole movie.
Page 749
Event handler summary for the Sound class Event handler Description Invoked each time new ID3 data is available. Sound.onID3 Invoked when a sound loads. Sound.onLoad Invoked when a sound stops playing. Sound.onSoundComplete Constructor for the Sound class Availability Flash Player 5. Usage new Sound([target:Object]) : Sound Parameters...
Sound.attachSound() Availability Flash Player 5. Usage my_sound.attachSound("idName":String) : Void Parameters The identifier of an exported sound in the library. The identifier is located in the idName Linkage Properties dialog box. Returns Nothing. Description Method; attaches the sound specified in the parameter to the specified Sound object.
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 ActionScript to your FLA or AS file. var my_sound:Sound = new Sound();...
Page 752
_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_interval:Number; var my_sound:Sound = new Sound(); my_sound.onLoad = function(success:Boolean) { if (success) { trace("sound loaded");...
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 compare the value of with the value of to determine what getBytesLoaded()
Page 754
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() Chapter 2: ActionScript Language Reference...
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. Example Sound.getBytesLoaded() for a sample usage of this method. See also Sound.getBytesLoaded() Sound.getBytesTotal()
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 call as an integer from -100 (left) to 100 setPan() (right). (0 sets the left and right channels equally.) The pan setting controls the left-right balance of the current and future sounds in a SWF file.
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 transform information for the specified Sound object set with the last call.
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 setting is 100. Example The following example creates a slider using the Drawing API and a movie clip that is created at runtime.
Page 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() Sound.getVolume()
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 metadata about the file. If an MP3 sound that you load using Sound.attachSound() Sound.loadSound()
Page 763
Property Description TMED Media type TOAL Original album/movie/show title TOFN Original filename TOLY Original lyricists/text writers TOPE Original artists/performers Original release year TORY File owner/licensee TOWN Lead performers/soloists TPE1 Band/orchestra/accompaniment TPE2 Conductor/performer refinement TPE3 Interpreted, remixed, or otherwise modified by TPE4 Part of a set TPOS...
Page 764
ID3 2.0 tag Corresponding ID3 1.0 property TRCK Sound.id3.track TYER Sound.id3.year Example The following example traces the ID3 properties of song.mp3 to the Output panel: var my_sound:Sound = new Sound(); my_sound.onID3 = function(){ for( var prop in my_sound.id3 ){ trace( prop + " : "+ my_sound.id3[prop] ); my_sound.loadSound("song.mp3", false);...
Sound.loadSound() Availability Flash Player 6. Usage my_sound.loadSound(url:String, isStreaming:Boolean) : Void Parameters The location on a server of an MP3 sound file. A Boolean value that indicates whether the sound is a streaming sound ( ) or isStreaming true an event sound ( false Returns Nothing.
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.attachSound() or Sound.loadSound(). This handler provides access to ID3 data without polling.
Sound.onLoad Availability Flash Player 6. Usage my_sound.onLoad = function(success:Boolean){ // your statements here Parameters A Boolean value of has been loaded successfully, false otherwise. success true my_sound Returns Nothing. Description Event handler; invoked automatically when a sound loads. You must create a function that executes when the this handler is invoked.
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 handler to trigger events in a SWF file when a sound finishes playing. You must create a function that executes when this handler is invoked.
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 Sound.duration for a sample usage of this property. See Also Sound.duration Sound.position...
Sound.setPan() Availability Flash Player 5. Usage my_sound.setPan(pan:Number) : Number Parameters 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 only the right channel, and 0 balances the sound evenly between the two channels.
Sound.setTransform() Availability Flash Player 5. Usage my_sound.setTransform(soundTransformObject:Object) : Void Parameters An object created with the constructor for the generic Object class. soundTransformObject Returns Nothing. Description Method; sets the sound transform (or balance) information, for a Sound object. parameter is an object that you create using the constructor soundTransformObject method of the generic Object class with parameters specifying how the sound is distributed to the left and right channels (speakers).
Page 772
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 , but setTransform() cannot be achieved by using...
Sound.setVolume() Availability Flash Player 5. Usage my_sound.setVolume(volume:Number) : Void Parameters A number from 0 to 100 representing a volume level. 100 is full volume and 0 is no volume volume. The default setting is 100. Returns Nothing. Description Method; sets the volume for the Sound object. Example Sound.getVolume() for a sample usage of this method.
Sound.start() Availability Flash Player 5. Usage my_sound.start([secondOffset:Number, loop:Number]) : Void Parameters An optional parameter that lets you start playing the sound at a specific point. secondOffset For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the parameter.
Sound.stop() Availability Flash Player 5. Usage my_sound.stop(["idName":String]) : Void Parameters An optional parameter specifying a specific sound to stop playing. The idName idName parameter must be enclosed in quotation marks (" "). Returns Nothing. Description Method; stops all sounds currently playing if no parameter is specified, or just the sound specified in the parameter.
CHAPTER 2 ActionScript Language Reference _soundbuftime Availability Flash Player 4. Usage _soundbuftime:Number = integer Parameters The number of seconds before the SWF file starts to stream. integer Description Property (global); establishes the number of seconds of streaming sound to buffer. The default value is 5 seconds.
CHAPTER 2 ActionScript Language Reference 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 SWF file.
Stage.addListener() Availability Flash Player 6. Usage Stage.addListener(myListener:Object) : Void Parameters An object that listens for a callback notification from the event. myListener Stage.onResize Returns Nothing. Description Method; detects when a SWF file is resized (but only if ). The Stage.scaleMode = "noScale" method doesn’t work with the default movie clip scaling setting ( ) or addListener()
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 property. Any value not listed here centers the align SWF file in Flash player or browser area, which is the default setting. Value Vertical Horizontal...
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 , the property represents the height of Flash Player. When Stage.scaleMode noScale height the value of is not represents the height of the SWF file.
Stage.onResize Availability Flash Player 6. Usage myListener.onResize = function(){ // your statements here Parameters None. Returns Nothing. Description Listener; invoked when is set to and the SWF file is resized. You can Stage.scaleMode noScale use this event handler to write a function that lays out the objects on the Stage when a SWF file is resized.
Stage.removeListener() Availability Flash Player 6. Usage Stage.removeListener(myListener:Object) : Boolean Parameters An object added to an object’s callback list with myListener addListener() Returns A Boolean value. Description Method; removes a listener object created with addListener() Example The following example displays the Stage dimensions in a dynamically created text field. When you resize the Stage, the values in the text field update.
Stage.scaleMode = scaleMode_str; scaleMode_cb.addEventListener("change", cbListener); To view another example, see the stagesize.fla file in the HelpExamples Folder. The following list provides typical paths to the HelpExamples Folder: • Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\ • Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/ • Stage.scaleMode...
Settings and About Macromedia Flash Player items appear. Example The following example creates a clickable text link that lets the user enable and disable the Flash Player context menu. this.createTextField("showMenu_txt", this.getNextHighestDepth(), 10, 10, 100, 22);...
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 , the property represents the width of Flash Player. This Stage.scaleMode "noScale" width means that will vary as you resize the player window. When the value of Stage.width is not represents the width of the SWF file as set at author-...
An image is startDrag() stopDrag() loaded into using the MovieClipLoader class. pic_mc var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ qa_petmarket/spotlight_thale.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth())); var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc) { target_mc.onPress = function() { startDrag(this);...
CHAPTER 2 ActionScript Language Reference 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.
Page 788
See also private, public Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference 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() stop()
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 the playhead moves over the frames in which they are located. Example The following code creates a text field, in which the song’s ID3 information appears.
CHAPTER 2 ActionScript Language Reference 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 when the user releases the mouse button: my_mc my_mc.onPress = function () {...
CHAPTER 2 ActionScript Language Reference String() Availability Flash Player 4; behavior changed in Flash Player 7. Usage String(expression) Parameters An expression to convert to a string. expression Returns A string. Description Function; returns a string representation of the specified parameter, as described in the following list: •...
CHAPTER 2 ActionScript Language Reference 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 value types.
Page 794
Method Description String.substring() Returns the characters between two indexes in a string. Converts the string to lowercase and returns the result; does not change String.toLowerCase() the contents of the original object. String.toUpperCase() Converts the string to uppercase and returns the result; does not change the contents of the original object.
String.charAt() Availability Flash Player 5. Usage my_str.charAt(index:Number) : String Parameters A number; an integer specifying the position of a character in the string. The first index character is indicated by , and the last character is indicated by my_str.length-1 Returns A character.
String.charCodeAt() Availability Flash Player 5. Usage my_str.charCodeAt(index:Number) : Number Parameters A number; an integer that specifies the position of a character in the string. The first index character is indicated by and the last character is indicated by - 1. my_str.length Returns A number;...
String.concat() Availability Flash Player 5. Usage my_str.concat(value1,...valueN) : String Parameters Zero or more values to be concatenated. value1,...valueN Returns A string. Description Method; combines the value of the String object with the parameters and returns the newly formed string; the original value, , is unchanged.
String.fromCharCode() Availability Flash Player 5. Usage String.fromCharCode(c1:Number,c2,...cN) : String Parameters A number; decimal integers that represent ASCII values. c1,c2,...cN Returns A string. Description Method; returns a string comprising the characters represented by the ASCII values in the parameters. Example The following example uses to insert an character in the e-mail address: fromCharCode()
String.indexOf() Availability Flash Player 5. Usage my_str.indexOf(substring:String, [startIndex:Number]) Parameters A string; the substring to be searched for within substring my_str A number; an optional integer specifying the starting point in to search for startIndex my_str the substring. Returns A number; the position of the first occurrence of the specified substring or -1. Description Method;...
String.lastIndexOf() Availability Flash Player 5. Usage my_str.lastIndexOf(substring:String, [startIndex:Number]) : Number Parameters String; the string for which to search. substring Number; an optional integer specifying the starting point from which to search for startIndex substring Returns A number; the position of the last occurrence of the specified substring or -1. Description Method;...
// output: true trace(checkAtSymbol("Chris")); // output: false 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/HelpExamples/ • String.length...
String.slice() Availability Flash Player 5. Usage my_str.slice(start:Number, [end:Number]) : String Parameters A number; the zero-based index of the starting point for the slice. If is a negative start start number, the starting point is determined from the end of the string, where -1 is the last character. A number;...
Page 803
"+my_str.slice(3)); // slice(3): em 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/HelpExamples/ • See also String.substr(),...
String.split() Availability Flash Player 5. Usage my_str.split("delimiter":String, [limit:Number]) : Number Parameters A string; the character or string at which splits. delimiter my_str A number; the number of items to place into the array. This parameter is optional. limit Returns An array; an array containing the substrings of my_str Description Method;...
Page 805
/* output: 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/HelpExamples/ • See Also Array.join() String.split()
// output: world 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/HelpExamples/ • Chapter 2:...
= my_str.substring(-5,5); trace(mySubstring); // output: Hello An example is also in the Strings.fla file in the Examples 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/HelpExamples/ • String.substring()
" + lowerCase); // output: lowerCase: lorem ipsum dolor 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/HelpExamples/ •...
" + upperCase); // output: upperCase: LOREM IPSUM DOLOR An example is also found 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/HelpExamples/ •...
CHAPTER 2 ActionScript Language Reference " " (string delimiter) Availability Flash Player 4. Usage "text" Parameters A sequence of zero or more characters. text Returns Nothing. Description String delimiter; when used before and after characters, quotation marks ("") indicate that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
CHAPTER 2 ActionScript Language Reference super Availability Flash Player 6. Usage super.method([arg1, ..., argN]) super([arg1, ..., argN]) Parameters The method to invoke in the superclass. method Optional parameters that are passed to the superclass version of the method (syntax 1) or arg1 to the constructor function of the superclass (syntax 2).
Page 812
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 constructor"); function getColor():String { trace("[Socks] I am getColor");...
CHAPTER 2 ActionScript Language Reference switch Availability Flash Player 4. Usage switch (expression){ caseClause: [defaultClause:] Parameters Any expression. expression keyword followed by an expression, a colon, and a group of statements to caseClause case execute if the expression matches the switch parameter using strict equality ( expression keyword followed by statements to execute if none of the case...
Page 814
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, Chapter 2: ActionScript Language Reference...
MP3 support, 1600 x 1200 pixel resolution, is running Windows XP, and Flash Player 7 (7.0.19.0): "A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t&SB=f&DEB=t&V=WIN%207%2C0%2 C19%2C0&M=Macromedia%20Windows&R=1600x1200&DP=72&COL=color&AR=1.0&OS=Window s%20XP&L=en&PT=External&AVD=f&LFD=f&WD=f" Property summary for the System.capabilities object All properties of the System.capabilities object are read-only.
Page 816
Property Description Server string Indicates whether the player supports the System.capabilities.hasScreenBroadcast development of screen broadcast applications to be run through the Flash Communication Server. System.capabilities.hasScreenPlayback Indicates whether the player supports the playback of screen broadcast applications that are being run through the Flash Communication Server.
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 prohibited ( ) or allowed ( ). The server string is true false Example The following example traces the value of this read-only property: trace(System.capabilities.avHardwareDisable);...
System.capabilities.hasAccessibility Availability Flash Player 6. Usage System.capabilities.hasAccessibility:Boolean Description Read-only property: a Boolean value that is if the player is running in an environment that true supports communication between Flash Player and accessibility aids; otherwise. The server false string is Example The following example traces the value of this read-only property: trace(System.capabilities.hasAccessibility);...
System.capabilities.hasAudio Availability Flash Player 6. Usage System.capabilities.hasAudio:Boolean Description Read-only property: a Boolean value that is if the player is running on a system that has true audio capabilities; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasAudio);...
System.capabilities.hasAudioEncoder Availability Flash Player 6. Usage System.capabilities.hasAudioEncoder:Boolean Description Read-only property: a Boolean value that is if the player can encode an audio stream, such as true that coming from a microphone; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasAudioEncoder);...
System.capabilities.hasEmbeddedVideo Availability Flash Player 6 r65. Usage System.capabilities.hasEmbeddedVideo:Boolean Description Read-only property: a Boolean value that is if the player is running on a system that true supports embedded video; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasEmbeddedVideo);...
System.capabilities.hasMP3 Availability Flash Player 6. Usage System.capabilities.hasMP3:Boolean Description Read-only property: a Boolean value that is if the player is running on a system that has an true MP3 decoder; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasMP3);...
System.capabilities.hasPrinting Availability Flash Player 6 r65. Usage System.capabilities.hasPrinting:Boolean Description Read-only property: a Boolean value that is if the player is running on a system that true supports printing; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasPrinting);...
System.capabilities.hasScreenBroadcast Availability Flash Player 6 r79. Usage System.capabilities.hasScreenBroadcast:Boolean Description Read-only property: a Boolean value that is if the player supports the development of screen true broadcast applications to be run through the Flash Communication Server; otherwise. The false server string is Example The following example traces the value of this read-only property: trace(System.capabilities.hasScreenBroadcast);...
System.capabilities.hasScreenPlayback Availability Flash Player 6 r79. Usage System.capabilities.hasScreenPlayback:Boolean Description Read-only property: a Boolean value that is if the player supports the playback of screen true broadcast applications that are being run through the Flash Communication Server; false otherwise. The server string is Example The following example traces the value of this read-only property: trace(System.capabilities.hasScreenPlayback);...
System.capabilities.hasStreamingAudio Availability Flash Player 6 r65. Usage System.capabilities.hasStreamingAudio:Boolean Description Read-only property: a Boolean value that is if the player can play streaming audio; true false otherwise. The server string is Example The following example traces the value of this read-only property: trace(System.capabilities.hasStreamingAudio);...
System.capabilities.hasStreamingVideo Availability Flash Player 6 r65. Usage System.capabilities.hasStreamingVideo:Boolean Description Read-only property: a Boolean value that is if the player can play streaming video; true false otherwise. The server string is Example The following example traces the value of this read-only property: trace(System.capabilities.hasStreamingVideo);...
System.capabilities.hasVideoEncoder Availability Flash Player 6. Usage System.capabilities.hasVideoEncoder:Boolean Description Read-only property: a Boolean value that is if the player can encode a video stream, such as true that coming from a web camera; otherwise. The server string is false Example The following example traces the value of this read-only property: trace(System.capabilities.hasVideoEncoder);...
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 ( ) or a special debugging version ( ). The server string is false true Example The following example traces the value of this read-only property: trace(System.capabilities.isDebugger);...
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 specified as a lowercase two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code subtag from ISO 3166 distinguishes between Simplified and Traditional Chinese.
Page 831
Language Russian Simplified Chinese zh-CN Spanish Swedish Traditional Chinese zh-TW Turkish Example The following example traces the value of this read-only property: trace(System.capabilities.language); System.capabilities.language...
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 administratively prohibited ( ) or allowed ( ). If set to Flash Player will be true false true,...
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 could be , or "Macromedia OSName" OSName "Linux" "Other OS "Windows" "Macintosh" ). The server string is Name" Example The following example traces the value of this read-only property: trace(System.capabilities.manufacturer);...
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 property can return the following strings: "Windows XP" "Windows 2000" "Windows NT" "Windows 98/ME" (available only in Flash Player SDK, not in the desktop version), "Windows 95"...
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 Example The following example traces the value of this read-only property: trace(System.capabilities.pixelAspectRatio); System.capabilities.pixelAspectRatio...
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: • for the Flash StandAlone Player "StandAlone" • for the Flash Player version used by test movie mode, "External"...
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 ", " " or ", which represents color, grayscale, and black and white, respectively. "color gray "bw The server string is Example The following example traces the value of this read-only property:...
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 Example The following example traces the value of this read-only property: trace(System.capabilities.screenDPI); Chapter 2: ActionScript Language Reference...
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 (which returns both the width and height of the screen). Example The following example traces the value of this read-only property: trace(System.capabilities.screenResolutionX);...
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 (which returns both the width and height of the screen). Example The following example traces the value of this read-only property: trace(System.capabilities.screenResolutionY);...
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=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t&SB=f&DEB=t&V=WIN%207%2C0%2C 19%2C0&M=Macromedia%20Windows&R=1600x1200&DP=72&COL=color&AR=1.0&OS=Windows%20 XP&L=en&PT=External&AVD=f&LFD=f&WD=f Example The following example traces the value of this read-only property: trace(System.capabilities.serverString); System.capabilities.serverString...
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, ). The server string is "WIN 7,0,19,0" Example The following example traces the value of this read-only property: trace(System.capabilities.version);...
CHAPTER 2 ActionScript Language Reference 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 SWF files in the identified domains access objects and variables in the calling SWF file or in any other SWF file from the same domain as the calling SWF file.
System.security.allowDomain() Availability Flash Player 6; behavior changed in Flash Player 7. Usage System.security.allowDomain("domain1":String, "domain2", ... "domainN") : Void Parameters Strings that specify domains that can access objects and domain1, domain2, ... domainN variables in the file containing the call. The domains can be System.Security.allowDomain() formatted in the following ways: •...
Page 845
SWF file to load; the parent will already be loaded by the time the child loads. Example The SWF file located at www.macromedia.com/MovieA.swf contains the following lines: System.security.allowDomain("www.shockwave.com"); loadMovie("http://www.shockwave.com/MovieB.swf", my_mc); Because MovieA contains the...
HTTPS protocol. This implementation maintains the integrity provided by the HTTPS protocol. Macromedia does not recommend using this method to override the default behavior because it compromises HTTPS security. However, you might need to do so, for example, if you must permit access to HTTPS files published for Flash Player 7 or later from HTTP files published for Flash Player 6.
Page 847
See also System.security.allowDomain(), System.exactSettings System.security.allowInsecureDomain()
System.security.loadPolicyFile() Availability Flash Player 7 (7.0.19.0) Usage System.security.loadPolicyFile(url:String) : Void Parameters A string; the URL where the cross-domain policy file to be loaded is located. Returns Nothing. Description Method; loads a cross-domain policy file from a location specified by the parameter.
Page 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 byte.
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 listed in the following table. Method summary for the System class Method Description...
System.exactSettings Availability Flash Player 7 or later. Usage System.exactSettings:Boolean Description Property; a Boolean value that specifies whether to use superdomain ( ) or exact domain false ) matching rules when accessing local settings (such as camera or microphone access true permissions) or locally persistent data (shared objects).
Page 852
Usually you should find that the default value of is fine. Often your System.exactSettings only requirement is that when a SWF file saves a shared object in one session, the same SWF file can retrieve the same shared object in a later session. This situation will always be true, regardless of the value of .
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 event handler onStatus that uses an information object for providing information, status, or error messages. To respond to this event handler, you must create a function to process the information object, and you must know the format and contents of the returned information object.
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 A plain-text string of characters to place on the system Clipboard, replacing its current string contents (if any). Returns A Boolean value: if the text is successfully placed on the Clipboard;...
System.showSettings() Availability Flash Player 6. Usage System.showSettings([panel:Number]) : Void Parameters A number; an optional number that specifies which Flash Player Settings panel to panel display, as shown in the following table: Value passed for Settings panel displayed panel None (parameter is omitted) The panel that was open the last time the user closed the Player or an unsupported value Settings panel.
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 external text files. The default value System.useCodepage false •...
CHAPTER 2 ActionScript Language Reference targetPath() Availability Flash Player 5. Usage targetpath(movieClipObject:MovieClip) : String Parameters Reference (for example, ) to the movie clip for which the movieClipObject _root _parent target path is being retrieved. Returns A string containing the target path of the specified movie clip. Description Function;...
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 defined by a style sheet to a TextField object that contains HTML- or XML-formatted text.
Page 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 following example loads in a style sheet and outputs the styles that load into the document. Add the following ActionScript to your AS or FLA file: var my_styleSheet:TextField.StyleSheet = new TextField.StyleSheet();...
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 called styles.css into a SWF file, and displays the styles that are loaded in the Output panel.
TextField.StyleSheet.getStyle() Availability Flash Player 7. Usage styleSheet.getStyle(styleName:String) : Object Parameters A string that specifies the name of the style to retrieve. styleName Returns An object. Description Method; returns a copy of the style object associated with the style named . If there is styleName no style object associated with is returned.
Page 862
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 styles called heading mainBody that define properties for . Enter the following code: font-family font-size font-weight...
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 style sheet. Example This example creates a style sheet object named that contains two styles, styleSheet heading...
TextField.StyleSheet.load() Availability Flash Player 7. Usage styleSheet.load(url:String) : Void Parameters 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. Description Method; starts loading the CSS file into .
TextField.StyleSheet.onLoad Availability Flash Player 7. Usage styleSheet.onLoad = function (success:Boolean) {} Parameters A Boolean value indicating whether the CSS file was successfully loaded. success Returns Nothing. Description Callback handler; invoked when a TextField.StyleSheet.load() operation has completed. If the style sheet loaded successfully, the parameter is .
TextField.StyleSheet.parseCSS() Availability Flash Player 7. Usage styleSheet.parseCSS(cssText:String) : Boolean Parameters The CSS text to parse (a string). cssText Returns A Boolean value indicating if the text was parsed successfully ( ) or not ( true false Description Method; parses the CSS in and loads the style sheet with it.
TextField.StyleSheet.setStyle() Availability Flash Player 7. Usage styleSheet.setStyle(name:String, style:Object) : Void Parameters A string that specifies the name of the style to add to the style sheet. name An object that describes the style, or style null Returns Nothing. Description Method; adds a new style with the specified name to the style sheet object. If the named style does not already exist in the style sheet, it is added.
Page 868
This displays the following information in the Output panel: emphasized fontWeight: bold color: #000000 Note: The line of code deletes the original style object passed to . While delete styleObj setStyle() not necessary, this step reduces memory usage, because Flash Player creates a copy of the style object you pass to setStyle() See also...
TextField.StyleSheet.transform() Availability Flash Player 7. Usage styleSheet.transform(style:Object) : TextFormat Parameters An object that describes the style, containing style rules as properties of the object, or style null Returns A TextFormat object containing the result of the mapping of CSS rules to text format properties. Description Method;...
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 TextField class to manipulate it with ActionScript.
Page 871
Property Description 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 device fonts. TextField._height The height of a text field instance in pixels.
Page 872
Property Description TextField.textHeight The height of the text field’s bounding box. The width of the text field’s bounding box. TextField.textWidth Indicates whether a text field is an input text field or dynamic TextField.type text field. Read-only; the URL of the SWF file that created the text field TextField._url instance.
TextField.addListener() Availability Flash Player 6. Usage my_txt.addListener(listener:Object) : Void Parameters An object with an event handler. listener onChanged onScroller Returns Nothing. Description Method; registers an object to receive notification when the event onChanged onScroller handlers have been invoked. When a text field changes or is scrolled, the TextField.onChanged event handlers are invoked, followed by the TextField.onScroller...
Page 874
my_txt.addListener(txtListener); See also TextField.onChanged, TextField.onScroller, TextField.removeListener() Chapter 2: ActionScript Language Reference...
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 . Valid my_txt values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Transparency values are not supported for text files that use device fonts.
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 (the default), , and . When you set the property, "none" "left" "right" "center" autoSize is a synonym for is a synonym for true "left"...
Page 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 clicks var myMouseListener:Object = new Object(); // define a function that executes when a user clicks the mouse myMouseListener.onMouseDown = function() { left_txt.autoSize = "left";...
TextField.background Availability Flash Player 6. Usage my_txt.background:Boolean Description Property; if , the text field has a background fill. If , the text field has no true false background fill. Example The following example creates a text field with a button that toggles the background color of the field.
TextField.backgroundColor Availability Flash Player 6. Usage my_txt.backgroundColor:Number Description Property; the color of the text field background. Default is (white). This property may 0xFFFFFF be retrieved or set, even if there currently is no background, but the color is only visible if the text field has a border.
TextField.border Availability Flash Player 6. Usage my_txt.border:Boolean Description Property; if , the text field has a border. If , the text field has no border. true false Example The following example creates a text field called , sets the border property to , and my_txt true...
TextField.borderColor Availability Flash Player 6. Usage my_txt.borderColor:Number Description Property; the color of the text field border, the Default is (black). This property may be 0x000000 retrieved or set, even if there is currently no border. Example The following example creates a text field called , sets the border property to , and my_txt...
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 . Think of the text field as a “window” onto a block of text. The my_txt property TextField.scroll is the one-based index of the topmost visible line in the window.
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 browser. The default value is false If you set this value to...
TextField.embedFonts Availability Flash Player 6. Usage my_txt.embedFonts:Boolean Description Property; a Boolean value that, when , renders the text field using embedded font outlines. If true , it renders the text field using device fonts. false Example In this example, you need to create a dynamic text field called , and then use the following my_txt ActionScript to embed fonts and rotate the text field.
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 dynamic text field on the Stage. Add the following ActionScript to your FLA or AS file, which dynamically creates two text fields at runtime and outputs their depths.
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 ) when you call this method. This method returns names of fonts on the player’s host my_txt system as an array.
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 format object is the format that newly inserted text, such as text inserted with the method or text entered by a user, receives.
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 An integer that specifies a character in a string. index Integers that specify the starting and ending locations of a span of text beginIndex, endIndex within my_txt...
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; TextField._height...
TextField.hscroll Availability Flash Player 6. Usage my_txt.hscroll:Number Returns An integer. Description Property; indicates the current horizontal scrolling position. If the property is 0, the text hscroll is not horizontally scrolled. For more information on scrolling text, see “Creating scrolling text” in Using ActionScript in Flash. The units of horizontal scrolling are pixels, while the units of vertical scrolling are lines.
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 property is , the text field is an HTML text field. If , the text field is a html true html...
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 text field, it behaves identically to the property.
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 , but is faster. A character such as tab ( ) counts as one character. text.length Example The following example outputs the number of characters in the...
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 allows; the property indicates only how much text maxChars maxChars a user can enter. If the value of this property is , there is no limit on the amount of text a user null can enter.
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 TextField.maxhscroll...
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 ActionScript in Flash. Example The following example sets the maximum value for the scrolling text field .
TextField.menu Availability Flash Player 7. Usage my_txt.menu = contextMenu Parameters A ContextMenu object. contextMenu Description Property; associates the ContextMenu object with the text field . The contextMenu my_txt ContextMenu class lets you modify the context menu that appears when the user right-clicks (Windows) or Control-clicks (Macintosh) in Flash Player.
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 text field and the user rolls the mouse wheel. By default, this value is .
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 , the text field true is multiline; if the value is , the text field is a single-line text field. false Example The following example creates a multiline text field called...
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 dynamic text field on the Stage. Add the following ActionScript to your FLA or AS file, which dynamically creates two text fields at runtime and displays their depths in the Output panel.
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; invoked when the content of a text field changes. By default, it is undefined;...
TextField.onKillFocus Availability Flash Player 6. Usage my_txt.onKillFocus = function(newFocus:Object){ // your statements here Parameters The object that is receiving the focus. newFocus Returns Nothing. Description Event handler; invoked when a text field loses keyboard focus. The method receives onKillFocus one parameter, , which is an object representing the new object receiving the focus.
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 A reference to the TextField object whose scroll position was changed. textFieldInstance Returns Nothing. Description Event handler/listener; invoked when one of the text field scroll properties changes. A reference to the text field instance is passed as a parameter to the handler.
Page 904
Example The following example creates a text field called , and uses two buttons called my_txt to scroll the contents of the text field. When the scrollUp_btn scrollDown_btn event handler is called, a trace statement is used to display information in the onScroller Output panel.
TextField.onSetFocus Availability Flash Player 6. Usage my_txt.onSetFocus = function(oldFocus:Object){ // your statements here Parameters The object to lose focus. oldFocus Returns Nothing. Description Event handler; invoked when a text field receives keyboard focus. The parameter is the oldFocus object that loses the focus. For example, if the user presses the Tab key to move the input focus from a button to a text field, contains the text field instance.
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 ActionScript code that references _parent to specify a relative path to movie clips or objects that are above the current text _parent field.
TextField.password Availability Flash Player 6. Usage my_txt.password:Boolean Description Property; if the value of , the text field is a password text field and hides the password true input characters using asterisks instead of the actual characters. If , the text field is not a false password text field.
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 property. _quality Note: Although you can specify this property for a TextField object, it is actually a global property, and you can specify its value simply as .
TextField.removeListener() Availability Flash Player 6. Usage my_txt.removeListener(listener:Object) Parameters The object that will no longer receive notifications from TextField.onChanged listener TextField.onScroller. Returns was successfully removed, the method returns a value. If was not listener true listener successfully removed (for example, if was not on the TextField object’s listener list), the listener method returns a value of...
TextField.removeTextField() Availability Flash Player 6. Usage my_txt.removeTextField() : Void Description Method; removes the text field specified by . This operation can only be performed on a my_txt text field that was created with MovieClip.createTextField(). When you call this method, the text field is removed.
TextField.replaceSel() Availability Flash Player 6. Usage my_txt.replaceSel(text:String) : Void Parameters A string. text Returns Nothing. Description Method; replaces the current selection with the contents of the parameter. The text is text inserted at the position of the current selection, using the current default character format and default paragraph format.
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 parameters, in beginIndex endIndex the specified text field with the contents of the parameter. text Example The following example creates a text field called and assigns the text dog@house.net to my_txt the field.
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 property is , you can enter any character. If the value of the property is restrict null...
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 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement is the same as my_txt._rotation = 450...
TextField.scroll Availability Flash Player 6. Usage my_txt.scroll Description Property; defines the vertical position of text in a text field. The property is useful for scroll directing users to a specific paragraph in a long passage, or creating scrolling text fields. This property can be retrieved and modified.
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 property controls whether a text field is selectable selectable, and not whether a text field is editable. A dynamic text field can be selectable even if it's not editable.
TextField.setNewTextFormat() Availability Flash Player 6. Usage my_txt.setNewTextFormat(textFormat:TextFormat) : Void Parameters A TextFormat object. textFormat Returns Nothing. Description Method; sets the default new text format of a text field; that is, the text format to be used for newly inserted text, such as text inserted with the method or text entered by a replaceSel() user.
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:TextFormat) : Void Parameters A TextFormat object, which contains character and paragraph formatting textFormat information. An integer that specifies a character within index my_txt An integer.
Page 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 new text, use TextField.setNewTextFormat().
TextField.styleSheet Availability Flash Player 7. Usage my_txt.styleSheet = TextField StyleSheet Description Property; attaches a style sheet to the text field specified by . For information on creating my_txt style sheets, see the TextField.StyleSheet class entry and “Formatting text with Cascading Style Sheets”...
Page 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 the following two CSS files in the same directory as the FLA or AS file you created previously: /* in styles.css */ .important { color: #FF0000;...
TextField.tabEnabled Availability Flash Player 6. Usage my_txt.tabEnabled:Boolean Description Property; specifies whether is included in automatic tab ordering. It is my_txt undefined by default. If the property is , the object is included in automatic tab tabEnabled undefined true ordering. If the property is also set to a value, the object is included in custom tab tabIndex ordering as well.
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; it is by default.
Page 924
one_txt.tabIndex = 3; two_txt.tabIndex = 1; three_txt.tabIndex = 2; four_txt.tabIndex = 4; See also Button.tabIndex, MovieClip.tabIndex Chapter 2: ActionScript Language Reference...
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. _self target specifies the current frame in the current window, specifies a new window, _blank _parent specifies the parent of the current frame, and specifies the top-level frame in the current _top window.
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, unformatted text in the text field, without HTML tags, even if the text field is HTML. Example The following example creates an HTML text field called , and assigns an HTML-...
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. The characters range from 0 to 9 and then A to F.
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 used to display the text height and width in the Output panel. The autoSize property is then used to resize the text field, and the new height and width will also be displayed in the Output panel.
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 TextField.textWidth...
TextField.type Availability Flash Player 6. Usage my_txt.type:String Description Property; Specifies the type of text field. There are two values: , which specifies a "dynamic" dynamic text field that cannot be edited by the user, and , which specifies an input "input"...
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 loads into it.
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 called and associates the variable my_txt today_date with the text field.
TextField._visible Availability Flash Player 6. Usage my_txt._visible:Boolean Description Property; a Boolean value that indicates whether the text field is visible. Text fields that my_txt are not visible ( property set to ) are disabled. _visible false Example The following example creates a text field called .
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 field on the Stage. Add the following ActionScript to a FLA or AS file. this.createTextField("my_txt", this.getNextHighestDepth(), 10, 40, 160, 120);...
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 , the text field has word wrap; if the value is , the text field does not have word wrap. true false Example...
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 coordinate system refers to the upper left corner of the Stage as (0, 0).
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 instance displays the mouse_txt current position of the mouse in relation to the Stage. The instance displays the textfield_txt current position of the mouse pointer in relation to the...
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 registration point is (0,0). Example The following example scales the instance when you click the my_txt scaleUp_btn...
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 the Stage as (0, 0).
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._xmouse Chapter 2: ActionScript Language Reference...
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 example for TextField._xscale. See also TextField._x, TextField._xscale, TextField._y...
CHAPTER 2 ActionScript Language Reference TextFormat class Availability Flash Player 6. Description The TextFormat class represents character formatting information. You must use the constructor to create a TextFormat object before calling new TextFormat() its methods. You can set TextFormat parameters to to indicate that they are undefined.
Page 943
Property Description TextFormat.indent Indicates the indentation from the left margin to the first character in the paragraph. TextFormat.italic Indicates whether text is italicized. TextFormat.leading Indicates the amount of vertical space (called leading) between lines. TextFormat.leftMargin Indicates the left margin of the paragraph, in points. TextFormat.rightMargin Indicates the right margin of the paragraph, in points.
Page 944
= "Lorem ipsum dolor sit amet..."; To view another example, see the animations.fla file in the HelpExamples Folder. The following list provides typical paths to the HelpExamples Folder: • Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\ • Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/ Chapter 2: ActionScript Language Reference...
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 , the paragraph is left-aligned. If , the "left" "center" paragraph is centered. If , the paragraph is right-aligned.
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. In contrast, normal indentation ) affects only the first line of each paragraph.
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 , then the text is boldface. true Example The following example creates a text field that includes characters in boldface.
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 line of each paragraph, a bullet symbol is displayed.
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 sets the text color to red. var my_fmt:TextFormat = new TextFormat();...
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 example creates a text field and sets the font to Courier. this.createTextField("mytext",1,100,100,100,100);...
TextFormat.getTextExtent() Availability Flash Player 6. The optional parameter is supported in Flash Player 7. width Usage my_fmt.getTextExtent(text:String, [width:Number]) : Object Parameters A string. text An optional number that represents the width, in pixels, at which the specified text width should wrap. Returns An object with the properties width...
Page 952
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 leading is 2.
Page 953
= "Arial"; my_fmt.bold = true; my_fmt.leading = 4; // The string of text to be displayed var textToDisplay:String = "Macromedia Flash Player 7, now with improved text metrics."; // Obtain text measurement information for the string, // wrapped at 100 pixels.
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 , which indicates that the property is undefined. null Example The following example creates a text field and sets the indentation to 10.
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 , which indicates that the property is undefined. null Example The following example creates a text field and sets the text style to italic. this.createTextField("mytext",1,100,100,100,100);...
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 following example creates a text field and sets the leading to 10. var my_fmt:TextFormat = new TextFormat();...
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 , which indicates null that the property is undefined. Example The following example creates a text field and sets the left margin to 20 points. this.createTextField("mytext",1,100,100,100,100);...
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 , which indicates null that the property is undefined. Example The following example creates a text field and sets the right margin to 20 points. this.createTextField("mytext",1,100,100,100,100);...
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 , which indicates that null the property is undefined. Example The following example creates a text field and sets the text size to 20 points. this.createTextField("mytext",1,100,100,100,100);...
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 ( ), the default tab stop is 4 null (average character width).
, you can get or set this property, but the property will have no effect. null Example The following example creates a text field with a hyperlink to the Macromedia website. The example uses to display the Macromedia website in a new browser window.
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 ) or not ( ). This underlining is similar to that produced by the tag, but the latter true false <U>...
The default value is , which indicates that null the property is undefined. Example This example creates a text field that is a hyperlink to the Macromedia website. var myformat:TextFormat = new TextFormat(); myformat.url = "http://www.macromedia.com"; this.createTextField("mytext",1,100,100,200,100); mytext.multiline = true;...
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, for example, to lay out text with greater precision than that allowed by dynamic text, but still access the text in a read-only way.
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 An integer specifying the starting point in to search for the specified text. startIndex my_snap A string specifying the text to search for.
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 of characters in the specified TextSnapshot object. Description Method;...
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 An integer that indicates the position of the first character of to be examined.
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 An optional Boolean value that specifies whether newline characters are includeLineEndings inserted into the returned string where appropriate.
Page 969
When you test the SWF file, you see a colored rectangle around the specified characters. See also TextSnapshot.getSelected() TextSnapshot.getSelectedText()
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 Parameters An integer that indicates the position of the first character of to be included in from my_snap...
Page 971
trace(count); // output: 20 trace(theText); // output: TextSnapshot Example See also TextSnapshot.getSelectedText() TextSnapshot.getText()
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 Parameters A number that represents the coordinate of the movie clip containing the text in my_snap A number that represents the coordinate of the movie clip containing the text in...
Page 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 my_ts.setSelected(0, my_ts.getCount(), false); if (hitIndex>=0) { // select the single character the mouse pointer is over my_ts.setSelected(hitIndex, hitIndex+1, true);...
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 The color used for the border placed around characters that have been selected by the hexColor corresponding TextSnapshot.setSelected()
Page 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. TextSnapshot.setSelectColor()
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 An integer that indicates the position of the first character of to select.
Page 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:TextSnapshot = this.getTextSnapshot();...
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, references the this movie clip instance that contains the script. When a method is called, contains a reference this to the object that contains the called method.
Page 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 keyword references the Circle object:...
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 code block. catch{} If an exception is not caught by a block, the string representation of the thrown value is catch sent to the Output panel.
Page 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..finally throw...
CHAPTER 2 ActionScript Language Reference trace() Availability Flash Player 4. Usage trace(expression) Parameters An expression to evaluate. When a SWF file is opened in the Flash authoring expression tool (using the Test Movie command), the value of the parameter is displayed in the expression Output panel.
CHAPTER 2 ActionScript Language Reference true Availability Flash Player 5. Usage true Description Constant; a unique Boolean value that represents the opposite of . When automatic data false typing converts to a number, it becomes 1; when it converts to a string, it becomes true true "true"...
Page 985
If an error is thrown within a function, and the function does not include a handler, then catch the ActionScript interpreter exits that function, as well as any caller functions, until a block catch is found. During this process, handlers are called at all levels. finally Example The following example shows how to create a...
Page 986
The following example demonstrates a statement. The code within the block is try..catch executed. If an exception is thrown by any code within the block, control passes to the catch block, which shows the error message in a text field using the method.
Page 987
Finally, in another AS file or FLA script, the following code invokes the method on sortRows() an instance of the RecordSet class. It defines blocks for each type of error that is thrown by catch sortRows() import RecordSet; var myRecordSet:RecordSet = new RecordSet(); try { myRecordSet.sortRows();...
CHAPTER 2 ActionScript Language Reference typeof Availability Flash Player 5. Usage typeof(expression) : String Parameters A string, movie clip, button, object, or function. expression Description Operator; a unary operator placed before a single parameter. The operator causes the typeof Flash interpreter to evaluate ;...
CHAPTER 2 ActionScript Language Reference 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 .
Page 990
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 Chapter 2: ActionScript Language Reference...
CHAPTER 2 ActionScript Language Reference unescape() Availability Flash Player 5. Usage unescape(x:String) : String Parameters A string with hexadecimal sequences to escape. Returns A string decoded from a URL-encoded parameter. Description Function; evaluates the parameter as a string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string.
It is loaded using the MovieClipLoader class. When you click the image, the movie clip unloads from the SWF file: var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.macromedia.com/devnet/mx/blueprint/articles/ performance/spotlight_speterson.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth())); var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc) { target_mc.onRelease = function() {...
CHAPTER 2 ActionScript Language Reference unloadMovieNum() Availability Flash Player 3. Usage unloadMovieNum(level:Number) : Void Parameters The level ( ) of a loaded movie. level _levelN Returns Nothing. Description Function; removes a SWF or image that was loaded by means of loadMovieNum() from Flash Player.
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 handler or as part of a function or method that you pass to onClipEvent() setInterval().
CHAPTER 2 ActionScript Language Reference Availability Flash Player 5. Usage var variableName [= value1] [...,variableNameN [=valueN]] Parameters An identifier. variableName The value assigned to the variable. value Returns Nothing. Description Statement; used to declare local or Timeline variables. If you declare variables inside a function, the variables are local. They are defined for the function and expire at the end of the function call.
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.
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 A Camera object that is capturing video data or a NetStream object. To drop the source connection to the Video object, pass null...
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 information without having to hide the Video object. Example The following example pauses and clears video1.flv that is playing in a Video object (called ) when the user clicks the...
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 default): Let the video compressor apply the deblocking filter as needed. •...
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 property of the Camera object that is Camera.height capturing the video stream. For FLV files, this value is the height of the file that was exported as FLV.
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers