Data Type ing when actionscript3.0 is converted to Java:
| ActionScript data type |
Java Data Type |
| Null |
Null |
| Number |
Java. Lang. Number |
| Boolean |
Java. Lang. Number, Boolean, java. Lang. String |
| String |
Java. Lang. String, java. Lang. Boolean, Boolean, java. Lang. character, Char, java. Lang. Number |
| Date |
Java. util. Date |
| XML Object |
Org. W3C. Dom. Document |
Certificate ------------------------------------------------------------------------------------------------------------------------------------
When Java converts data types to ActionScript 3.0:
| Java Data Type |
Actionscript3.0 Data Type |
| Null |
Null |
| Java. Lang. Number |
Number |
| Java. Lang. Number, Boolean |
Boolean |
| Java. Lang. String, java. Lang. Character char [] |
String |
| Java. util. Collection, java. Lang. Reflect. Array |
Arraycollection, array |
| Java. util. Map, java. util. Dictionary |
Object |
| Org. W3C. Dom. Document |
XML Object |
| Other claess |
Object |
Note:
(1) List and arraylist in Java correspond to arraycollection in flex.
(2) eg: Write a method to connect to Oracle through Java and return an arraylist. The arraylist contains hashmaps. If you call this method using remoteobject (or other methods), the flex side must receive an object, which can be forcibly converted to arraycollection. Then, the arraycollection is traversed to obtain the object storing each data (hashmap in Java ).
(3) There is no map class in flex, but as long as you know the map key in Java, flex can be accessed as an attribute of the object.
Test: (key code)
(1) If the server transmits the list set type (including the list subclass ):
[Bindable]
Public Static Var list: arraycollection;
Private function loaddata (Event: resultevent): void {
List = arraycollection (event. Result );
}
<Mx: DataGrid dataprovider = "{list}" id = "studentdata">
<Mx: columns>
<Mx: datagridcolumn datafield = "studentid" headertext = "student ID"/> <! -- Background attribute field -->
<Mx: datagridcolumn datafield = "studentage" headertext = "Age"/> <! -- Background attribute field -->
<Mx: datagridcolumn datafield = "studentbirthday" headertext = "Birthday"/> <! -- Background attribute field -->
</MX: columns>
</MX: DataGrid>
(2) If the server transmits the map set type (including the map subclass ):
[Bindable]
Public var HM: object;
Public Function hashmap (Event: resultevent): void {
Hm = event. result as object;
}
<Mx: textinput x = "10" Y = "244" text = "{hm. name}"/> <! -- Name, age, ID is the key in hashmap -->
<Mx: textinput x = "10" Y = "306" text = "{hm. Age}"/>
<Mx: textinput x = "10" Y = "361" text = "{hm. ID}"/>
(3) If the server transmits an array of the stirng [] type:
[Bindable]
Public var arr: array;
Public Function Array (Event: resultevent): void {
Arr = event. result as array;
For (var I: Int = 0; I <arr. length; I ++ ){
// The Order of the obtained values is reversed.
Alert. Show (ARR [I]);
}
}