Some explorations of AS data types (1)
When you are bored, please take a look at the mm flash document. I saw the int this keyword in ActionScript_ref. I used to be used to C and Java's writing. When I wrote AS, I would write Int, I know it is the key to AS. Word, but I have never known its role, this time I look at it carefully.
int
Availability
Flash Player 4. this function WAS DepRecated in Flash
5 in
Favor of math.Round ().
USAGE
Int (Value)
Parameters
Value a number to be rounded to an integer.
Returns
Nothing.
Description
Function; Converts a decimal number to an integer value by truncating the decimal value. This
Function is equivalent to math.floor () if the value parameter is posient and math.ceil () ing
The Value Parameter Is Negative.
See Also
Math.floor (), Math.ceil ()
It is righteous, INT has appeared when Flash Player 4, Flash 5 is a function used to surround the round, and is closely related to Math.Floor (), Math.ceil (). So, I think, I need to go deep into the Flash data type and the knowledge of type conversion.
Anyway, int this thing is still trying to know what it is specific:
A = 2.9;
B = 3.1;
C = -2.9;
D = -3.1;
TRACE ("INT (A) =" INT (A) "; int (b) =" int (b));
TRACE ("int (c) =" int (c); int (d) = " INT (D));
Output
INT (a) = 2; int (b) = 3
INT (C) = - 2; int (d) = - 3
It seems not to be a four-bedroom, strange. There is a line in Jinshan 糍粑 explained the word Round: round, make round, bypass, completed, surrounded, rounded. It seems that it is not good here to explain the Rove as a round, it should be "round" to introduce it is to get complete, and then it is to be satisfied, so I have concluded here:
The INT function is used to decorate.
Flash's basic data type:
Flash includes the following most basic data types: String, Number, Boolean, Object, MovieClip, null, undefined. String is a string. Number is a numeric type. Boolean is the logical type Object is the object type (white said), it is a set of properties. MovieClip is the only data type containing graphic elements in AS. NULL data type has only one value null. Indicates that the variable has not been data, and the variable has not been assigned. The undefined data type also has only one undefined value, which is not assigned to a variable, which seems to be similar to NULL. But wait for some tests to see what is different. But first, let's take a look at a more useful function TypeOf, which can be used to determine what type of variable is. Take a look at the test code:
VAR A: String;
VAR B: Number;
VAR C: Boolean;
VAR D: movieclip;
Var E: Object;
TRACE ("type_a =" typeof (a));
Trace ("Type_B =" TypeOf (b));
TRACE ("type_c =" typeof (c));
TRACE ("type_d =" typeof (d));
TRACE ("Type_e =" TypeOf (e));
a = "leefj";
B = 22;
C = true;
D = _root.attachmovie ("Leaf", "F", 4);
E = {Name: "leefj"};
Trace ( );
TRACE ("type_a =" typeof (a));
Trace ("Type_B =" TypeOf (b));
TRACE ("type_c =" typeof (c));
TRACE ("type_d =" typeof (d));
TRACE ("Type_e =" TypeOf (e));
Output results:
TYPE_A = Undefined
TYPE_B = Undefined
TYPE_C = Undefined
TYPE_D = undefined
TYPE_E = Undefined
TYPE_A = String
TYPE_B = Number
TYPE_C = Boolean
TYPE_D = MovieClip
TYPE_E = Object
It seems but strange
VAR A: String;
VAR B: Number;
VAR C: Boolean;
VAR D: movieclip;
Var E: Object;
It seems to be only a statement for variables, and does not determine the type of variable. It is not correct. After determining the variables, it is determined that the variable is undefined type. Only after the variable is assigned, the variable has the data type corresponding to the declaration. This is not difficult to think about the automatic data type and strict data type in AS2. I think the strict data type is also based on the automatic data type, otherwise why the variable has just declared the undefined type. In summary, the conclusion that the variable is the undefined type when the variable is just declared, regardless of the definition of the strict data type or the definition of the automatic data type, but after the variable is assigned, the variable is allocated memory After the space, the variable obtains the type of data specified in the statement statement.
This conclusion is also the same in the application:
Function Test (A: String, B: Number, C: Boolean, D: MovieClip, E: OBJECT) {
TRACE ("type_a =" typeof (a));
Trace ("Type_B =" TypeOf (b));
TRACE ("type_c =" typeof (c));
TRACE ("type_d =" typeof (d));
TRACE ("Type_e =" TypeOf (e));
}
Test ();
TRACE ( );
TEST ("", 123, true, _root.attachmovie ("Leaf", "F", 4), {Name: "leefj"});
Output:
TYPE_A = Undefined
TYPE_B = Undefined
TYPE_C = Undefined
TYPE_D = undefined
TYPE_E = Undefined
TYPE_A = String
TYPE_B = Number
TYPE_C = Boolean
TYPE_D = MovieClip
TYPE_E = Object
However, the problem is, when will there be a null value? Haha briefly look at it.
Click to browse this file