Ing between each data type in flex and each data type in Java

Source: Internet
Author: User

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]);
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.