1. As Operator
To convert OBJ to an array, use the as operator, which returns array reference when obj is a valid array; otherwise, return NULL:
VaR OBJ: Object = ["A", "B", "C"];
VaR newarray: array = OBJ as array;
Trace (newarray = OBJ); // true
Trace (newarray [0]); //
Trace (newarray [1]); // B
Trace (newarray [2]); // C
2. Value Type and reference type
Value Type: directly store the value. The value of each variable does not change because of the value of other variables.
Exp1.
VaR A: Int = 3;
VaR B: Int =;
B = 9; // The value of B to be changed to 9
Trace (a); // the output value of A is 3, and a does not change because of the value of B.
Trace (B); // output B to 9
Reference Type: storage reference, pointing to the object to be operated
Exp2.a1 and B1 both point to the array [1, 2, 3].
VaR A1: array = new array (1, 2, 3 );
Trace (A1); // The output A1 is 1, 2, 3
VaR B1: array = A1;
B1 [0] = 5;
Trace (A1); // The output A1 is 5, 2, 3, and the value has been modified by B1.
Trace (B1); // The output B1 is 5, 2, 3
The basic data types in as3 are Boolean, Int, number, String, uint, and value types.
Java data types include basic and reference types.
The basic data types include byte, Char, short, long, Int, float, double, and Boolean.
There are three reference types: Class, interface, and array.
The as value type is also a reference value.
The basic Java type is to directly hold values.
3. Ternary Operators
Test? Expression1: expression2
Test
Any Boolean expression.
Expression expression1 returned when test is true. It may be a funny expression.
The expression expression2 returned when test is false. It may be a funny expression.
Exp1
VaR A: Int = 3;
VaR B: Int =;
B = 9; // change the value of B to 9
Trace (a); // 3
Trace (B); // 9
(A = 5 )? Trace (a): trace (B) // 9
4. typeof, is,
VaR my: String = "I Love You ";
Trace (typeof my); // string. Typeof: Data Type returned
Trace (My is string); // true. Is: determines the Data Type
Trace (My is number); // false. Not a number data type
Trace (my as string); // I love you. As: determines the data type and returns the value of my.
Trace (my as number); // null. The data type is not number, and null is returned.
5. In
Determines whether an object is used as the key or index of another object.
VaR A: array = [1, 2, 3, 4, 5];
Trace (2 in A); // true
6. Delete
Deletes attributes of any instance of an object.
Exp
VaR A: array = [1, 2, 3, 4, 5];
Trace (a); // 1, 2, 3, 4, 5
Delete A [2];
Trace (a); // 1, 2, 4, 5
7. as3 allows the expression to be automatically converted to the corresponding Boolean value if its value is not a Boolean value.
8.... In & for each... In enumeration set Elements
VaR books: Object = {
A: "Love is everything",
B: "Fuck your baby",
C: "I hit you"
}
For (var k in books ){
Trace ("key name:" + K + "\ t value:" + books [k]);
}
/* \ T matches a tab in the Regular Expression and is accessed by key value
Output:
Key name: A value: Love is everything
Key name: B value: Fuck your baby
Key name: C value: I hit you
*/
For each (var k in books ){
Race (k );
}
/* Access members directly
Love is everything
Fuck your baby
I hit you
*/
8. Arguments. callee
9. Difference Between = and =
10. as3 does not support abstract classes (abstract classes can be implemented using some techniques), nor can it directly implement the singleton mode (external classes can be used)
11. as3 does not support method overloading. You can use... Rest implementation