Created
March 7, 2013 07:18
-
-
Save sonygod/5106164 to your computer and use it in GitHub Desktop.
amf read and write example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
//import js.Lib; | |
//import js.Node; | |
import Date; | |
import haxe.io.Input; | |
import HttpServer; | |
import format.amf.Reader; | |
import format.amf.Writer; | |
import haxe.io.BytesInput; | |
import haxe.io.BytesOutput; | |
import format.amf.Tools; | |
import format.amf.Value; | |
using Reflect; | |
/** | |
* ... AMF READ OR WRITE EXAMPE | |
* @author sonygod | |
*/ | |
class Main { | |
static function main() { | |
var obj2 = { key:"123456",name:'Bob', age:22, pages:['ABC-123'] }; | |
/* using Reflect; | |
for(f in obj.fields()) | |
{ | |
trace(obj.field(f)); | |
} | |
*/ | |
var obj = new Map<String, Dynamic>(); // { name:'Bob' , age:22, pages:['ABC-123'] }; | |
obj.set("key", "value"); | |
obj.set("key2", 1); | |
var o:BytesOutput = new BytesOutput(); | |
var b:Bool = true; | |
var w:Writer = new Writer(o); | |
w.write(Tools.encode(b)); | |
w.write(Tools.encode(obj2)); | |
//w.write(Tools.encode(obj2)); | |
var i:Input = new BytesInput(o.getBytes()); | |
var r:Reader = new Reader(i); | |
var cc = r.read(); | |
trace(Tools.abool(cc)); | |
var objj = r.read(); | |
trace(Tools.string(Tools.object(objj).get("key"))); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment