On Feb 17, 2016 10:38 PM, "Alex Harui" <aha...@adobe.com> wrote: > > Hi Lizhi, > > Your email did not format well, but IMO, you are seeing expected behavior > in the Google Closure Compiler optimization. Unless you specify > otherwise, the GCC will rename variables, properties, etc. Using straight > up JSON can be tricky in such situations. You may have to specify and > even use a class definition for the JSON data structure.
This is interesting. Is there an example of this kind of pattern somewhere in the FlexJS examples? Thanks, Om > > -Alex > > On 2/16/16, 6:59 PM, "lizhi" <s...@qq.com> wrote: > > >package { import flash.display.Bitmap; import flash.display.Loader; import > >flash.display.LoaderInfo; import flash.display.Sprite; import > >flash.display.StageAlign; import flash.display.StageScaleMode; import > >flash.events.Event; import flash.geom.Matrix; import flash.net.URLLoader; > >import flash.net.URLRequest; import flash.text.TextField; import > >spriteflexjs.Stats; /** * ... * @author lizhi */ public class TestTMX > >extends Sprite { private var tmxloader:URLLoader; private var > >pngs:Array = > >[]; private var tmxobj:Object; public function TestTMX() > > { tmxloader = > >new URLLoader(new URLRequest("../../assets/tmx/sewers.json")); > >tmxloader.addEventListener(Event.COMPLETE, tmxloader_complete); > >stage.align = StageAlign.TOP_LEFT; stage.scaleMode = > >StageScaleMode.NO_SCALE; addChild(new Stats); } private function > >tmxloader_complete(e:Event):void { tmxobj = JSON.parse(tmxloader.data > >+ > >""); loadNextTile(); } private function loadNextTile():void { if > >(pngs.length<tmxobj.tilesets.length) { var loader:Loader = new > >Loader; > >loader.contentLoaderInfo.addEventListener(Event.COMPLETE, > >loader_complete); > >var tset:Object = tmxobj.tilesets[pngs.length]; var url:String = > >tset.image; url = url.slice(url.lastIndexOf("\/")+1); > >loader.load(new URLRequest("../../assets/tmx/"+url)); }else > >{ > >init(); } } private function loader_complete(e:Event):void { > >pngs.push(((e.currentTarget as LoaderInfo).content as > >Bitmap).bitmapData); > >loadNextTile(); } private function init():void { var tw:Number = > >tmxobj.tilewidth; var th:Number = tmxobj.tileheight; for each(var > >layer:Object in tmxobj.layers) { for (var i:int = 0; i < > >layer.data.length; i++ ) { var id:int = > >layer.data[i]; if(id>0){ > >var tset:Object = tmxobj.tilesets[0]; var fg:int = > >tset.firstgid; > >var x:int = int(i % layer.width); var y:int = int(i / > >layer.width); > >var ttw:int = tset.tilewidth; var tth:int = tset.tileheight; var > >numCols:int = tset.imagewidth/ttw; var tx:int = int((id-fg) % > >numCols); > >var ty:int = int((id - fg) / numCols); > >graphics.beginBitmapFill(pngs[0],new > >Matrix(1,0,0,1,x*tw-tx*ttw,y*th-ty*tth)); graphics.drawRect(x * tw, > >y * > >th, tw, th); } } } } }} > >and i can not find "tilesets" in the js-release/ > > > > > > > >-- > >View this message in context: > > http://apache-flex-development.2333347.n4.nabble.com/flexjs-eat-json-tiles > >ets-tp51581.html > >Sent from the Apache Flex Development mailing list archive at Nabble.com. >