ActionScript use an array Summary
Related Tags:
Where more wrong or improper, please correct me, thank you.
Array:
AS2, there are two types of array of local cattle comparison:
1) Object array own any data type can be stored, instead of the C int a [2], [3] char a, someClass a [3].
Of course, the downside is also immediately sudden out of no direct Create Object array.
2) fully dynamic arrays, the use of very simple, somewhat like Vector, but also more vulnerable to mistakes. The dynamic here is that the size of an array boundary (of course, the dimension or to declare good).
Below are some on the array type personally think that the more important point in the summary, some of the often sprawling NEE are omitted,
Where or speak less about what's wrong so you must help me to point out that, we enhance common:
A
Following is a statement mistakes:
Function test (arr []: Array): Void
2 statement Mode 1 (Note here the use of all manner of the statement-type statement method)
A [0] = 0;
A [1] = 1;
Trace (a);
/ / Output
0,1
3 statement method 2
A [4] = 1;
Trace (a);
/ / Output
Undefined, undefined, undefined, undefined, 1
Explained: dynamic arrays with a length [4] automatically after five.
4 statement Mode 3
4.1
Trace (b);
0,1,2,3
4.2 does not support this form of two-dimensional array of nested definition
Trace (b);
Trace (b [0] "," b [1] "" b [2] "" b [3]);
Trace (b [0] [0]);
2,4,6
2 4 6 undefined undefined
5 [] replaced by the C ();
Statement Mode 4
Trace (b);
Trace (b [0] "," b [1] "" b [2] "" b [3]);
Trace (b [0] [0]);
1,2,3,4,5,6
1,2 3,4 5,6 undefined / / b [0] with an array output trip.
A
6 2D dimension is the same dynamic settings:
B [2] [3] = 12;
Trace (b [2] [3]);
/ / Output
12
7 other two-dimensional array statement:
7.1 through the first set corresponding parameters listed.
/ /
Var gRowIndex: Number = 2;
Var gColIndex: Number = 3;
Var a: Array = new Array (gRowIndex);
For (var i = 0; i <gRowIndex; i)
(A [i] = new Array (gColIndex);
For (var j = 0; j <gColIndex; j)
(
A [i] [j] = String (i) String (j);
)
)
Trace (a);
/ / Output
00,01,02,10,11,12
8 for an array of function parameters for the transfer.
8.1
Function test (arr: Array): Void
(
Trace (arr [0] "," arr [1] "" arr [2] "" arr [3] "");
)
Test (b);
0 1 2 3
8.2
Two-dimensional array:
Function test (arr: Array): Void
(
Trace (arr);
Trace (arr [0] "," arr [1] "" arr [2] "" arr [3] "");
)
Test (b);
1,2,3,4,5,6
1,2 3,4 5,6 undefined
8.3
The first transmission line parameters:
Function test (arr: Array): Void
(
Trace (arr);
Trace (arr [0] "," arr [1] "");
)
Test (b [0]);
Test (b [1]);
Test (b [2]);
1,2
1 2
3,4
3 4
5,6
5 6
9 More:
9.1
Var gColIndex: Number = 3;
Var a: Array = [[0,1], [3,4,5 ]];// a certain Element of a vacant Position here [0] [2]
Trace (a);
For (var i = 0; i <gRowIndex; i)
(
For (var j = 0; j <gColIndex; j)
(
Trace (a [i] [j]);
)
)
0,1,3,4,5
0
A
Undefined
3
4
5
9.2 does not support dynamic dimension
B [0] [0] = 3;
Trace (b [0] [0]);
/ / Output
Undefined.
9.3 an indirect object array to achieve example.
/ / ENEMY connected to the array ------ ----------- / /
For (var j = 0; j <3; j) (
AttachMovie (the "baddie", "baddie" j, j 200);
EnArray _root [j] = [ "baddie" j];
EnArray [j]. _x = 50 * j;
EnArray [j]. _y = 100;
)
9.4
There are many practical examples are used, say, to preserve Color with array data, loading picture variable name, and so on.
10 deleted array elements:
10.1 One-dimensional:
P.splice (1);
Trace (p);
Var t = new Array (1,2,3,4,5);
T.splice (2,1);
Trace (t);
/ / Output
A
1,2,4,5
10.2 2D:
B [0]. Splice (0) / / delete c [0] [0] c [0] [1]
Trace (b);
Var c: Array = [[1,2] [3,4] [5,6]];
C [1]. Splice (1); / / c [1] [1]
Trace (c);
, 3-6
1,2,3,5,6
11 length test:
Trace (b.length);
Trace (b [0]. Length);
Trace (b [2]. Length);
/ / Output
3
3
4
================================================== =======
After a month of added:
11 dynamic dimension: with JAVA in the same.
Arr [0] = new Array (3);
Arr [0] [0] = 1;
Arr [0] [1] = 2;
Arr [0] [2] = 3;
Trace (arr);
Trace (arr [0] [0]);
Trace (arr [0] [1]);
Trace (arr [0] [2]);
1,2,3
A
2
12 new ways to load data (multiple attributes):
MData.addItem ((label: "The ball momentum conservation (one-dimensional)," data: 0));
MData.addItem ((label: the "three-momentum conservation (one-dimensional)," data: 1));
MData.addItem ((label: "multi-plane collisions (2D)," data: 2));
MData.addItem ((label: "mother balls" data: 3));
V2Component for the ComboBox with the use of:
- Ajax coding issue summary
- Landscape painting on some summary
- ActionScript use an array Summary
- Javascript summary - div
- CSS Summary
- Javascript trigger events summary
- CSS syntax summary MultiManager
- Some css personal summary
- Css Gudongmen technology to a number of summary and summary
- DHTML use in a summary of the incident
- Flash ActionScript 3.0 Summary
- Summary: Google tips
- AJAX framework Summary
- CSS rookie Summary
- Css style Xi summary
- JavaScript knowledge Summary Review
- Summary page document contains
- Examples of events interception Summary
- Abbreviations used CSS syntax summary
- Summary of experience doing ajax




