Faster JSON Decoder - NOT :-(
I'm looking for a fast JSON decoder in AS3, and I'm really hoping that the next Flash player will have native JSON functions like IE8. The as3 core library has a decoder. Tested it on a one megabyte JSON String and it took almost 4 seconds to decode on my MacBook Pro. Wow ! There has to be a better way. Couple of former life ago, was really into lex/yacc and flex/bison. BTW - I laughed so hard when I read the name of the first link when I googled 'lex yacc' - The generated "C" code was very fast. So one of the "modern" way to write a lexical analyzer/parser is to use ANTLR. ANTLR has an option to target ActionScript. I Found a JSON grammar reference and made simple adjustments for AS3. Ran the ANTLR Tool on the 'g' files and compiled the generated AS files into a test harness. BTW - Had to adjust by hand the generated AS3 code, as it did not compile out-of-the-box :-( I passed a set of test cases for the exception of escaped string content. Now, back to the one megabyte JSON String. It took almost 29 seconds !!!! Wow ! Thinking about it some more. It kinda make sense, as I'm evaluating the string from a generated AST. Anyway, I believe you should "publish" your successes and failures. Like usual, here is the source code.
Comments
var extent:Extent = GraphicUtil.getGraphicsExtent(this.graphics);
var yDiff:Number = 0;
if(this.shapeType == 1 || this.shapeType == 2){
yDiff = (extent.ymax - extent.ymin)/8;
}else {
yDiff = (extent.ymax - extent.ymin)/4;
}
this.map.extent.update(extent.xmin-yDiff,extent.ymin-yDiff, extent.xmax+yDiff, extent.ymax+yDiff);
this.map.zoomOut();
But still the shape doesn't come to viewable area. Any ideas u can suggest plz?