| Refresh | Home EGTry.com

actionscript data types mapping to java objects



dense array

write actionscript array

				
				var f:File=new File("C:\\tmp\\amf\\test.dat");
				var out:FileStream=new FileStream();
				out.open(f,FileMode.WRITE);
				
				var a:Array=[10,20,30,40,50,60];
				out.writeObject(a);
				
				out.close();


object[] in java

import java.io.FileInputStream;
import java.io.InputStream;



import com.exadel.flamingo.flex.messaging.amf.io.AMF3Deserializer;
public class AMFReaderExample {


	public static void main(String[] args) throws Exception {
		
	
		String inputfile="/tmp/amf/test.dat";
		InputStream in=new FileInputStream(inputfile);
		AMF3Deserializer des=new AMF3Deserializer(in);
		
		Object obj=des.readObject();
		if (obj instanceof Object[]) {
			Object[] a=(Object[])obj;
			for(int i=0; i<a.length; i++) {
				System.out.println(i+" "+a[i].getClass()+", "+a[i]);
			}
			
		}

	}

}



Output

0 class java.lang.Integer, 10
1 class java.lang.Integer, 20
2 class java.lang.Integer, 30
3 class java.lang.Integer, 40
4 class java.lang.Integer, 50
5 class java.lang.Integer, 60



a simple map-like object to java HashMap

actionsctipt object

				var xml:XML=<address>
				  <street>1111 Kirkwood blvd</street>
				  <city>Dallas</city>
				</address>
				
				var obj:Object={
					"version":3.14, 
					"msg":"Hello World", 
					"today": new Date(),
					 "children":["one","two"],
					 "valid":false,
					 "parent":null,
					 "name":undefined,
					 "document":xml
					 };


java HashMap

key value type
version 3.14 Double
msg Hello World String
today Wed Dec 21 00:28:21 CST 2011 Date
children [Ljava.lang.Object;@89ae9e Object[]
valid false Boolean
parent null null
name null null
document ... String