The basic syntax is the same as JavaScript, because the AS2.0 is based on the ECMA-262 specification, and this specification is JavaScript international standards, so it is conceivable that there is much similarity between them. However, AS2.0 begins to require mandatory types. It is of course also supported non-mandatory types, but compiling errors will occur in some cases. Such as var A = "lolo"; A = 12; will report an error. You can use A = STING (12) to express. Correct mandatory type definition As follows: Variable var A: string = "lol"; incoming parameter function welcome (firstname: string, age: number) {} Return parameter function square (x: number): Number {var squared = x * x; return squard; } Object Type Specify VAR Student: Student = New Student (); Determines the type of object with TypeOf (variablename) 1. Case sensitivity 2. Separation of statements to the statement, of course, no 3. Using large unscrupulous Code blocks are split, such as class definition, method definition, and IF, etc. 4.4. Note Units adopted "//", multi-line adoption "/*..........5. Data type has strings (String ), Number, floating-point value), Boolean, True & False, object (Object), movie clip (MovieClip), NULL (value NULL, no value), undefined (value undefined, uncertain Type) Where the movie clip is the only data type that can graphically graphically in AS. The MovieClip data type allows you to control the movie clip components using the MOVIECLIP class. These methods can be called using the point (.) Operator, as shown below: Var my_mc: moviClip = new movieclip (); var parent_mc: movieclip = new movieclip (); my_mc.startdrag (true); parent_mc.geturl ("http: //www.macromedia.com/support/ " Product); Type Conversion Array (), Boolean (), Object (), String (), MovieClip () In addition, there is an original data type (for example, Boolean, Date and Number 6. Assignment "=", compare "==", logic and "&&", logic or "||", "<=" less than or equal to, "> =" greater than or equal, "! =" Is equal to 7. There are three variables, local variables, time axis variables, global variables
Global variable (_global. Variable name) var _global.myname = "gerge"; // syntax error, can't use VAR in defining global variables, etc. Operator and array access operator object Rocket in the same variable Velocity: Rocket.Velocity; Rocket ["velocity"]; array var name: array = new array () Name [0] = "DFDS" var A: string = Name [0] is also an array of arrays by building a component, and a multi-dimensional array can be created in the action script. To access the elements of multi-dimensional array, you can self-nested an array access operator, as shown in the following example: var plessboard = new array (); for (var i = 0; i <8; i ) {CHESSBOARD.PUSH ( NEW ARRAY (8));} Function getContentSofsquare (Row, Column) {Chessboard [ROW] [Column];} 9 Logic Control> IF (Password == Null || Email == Null) {gotoistStop ("reject") } Else if (password == userid) {gotoandplay ("startmovie");}> while i = 4; while (var i> 0) {my_mc.duplicatemovieClip ("newmc" i, i); i-; }> Do ... while i = 4; do {my_mc.duplicatemovieClip ("newmc" i, i); i--;} while (var i> 0);> for for (var i = 4; i> 0; I -) {Mymc.duplicateMovieClip ("newMC" i, i 10);}> for..in child includes other movie clips, functions, objects, and variables. The following example uses the Trace statement to display the result in the "Output" panel: myObject = {name: 'Joe', AGE: 25, City: 'san francisco'}; for ("MyObject HAS) {trace (" MyObject HAS The property: " PropertyName ", with the value: " myObject");} This example will output the following results: MyObject Has The Property: Name, with the value: Joe MyObject Has The Property: age, with the Value: 25 MyObject Has The Property: City, with the value: San Francisco You may want the script to repeat a specific child type, such as only the movie clip child. This can be implemented in conjunction with the TypeOf operator.