开发者

Populate new MovieClip() with JSON object properties

开发者 https://www.devze.com 2023-03-17 13:52 出处:网络
I have saved out an object using JSON.encode to a text file, is it possible to then create a new MovieClip and p开发者_C百科opulate it with all of the properties from the saved file? If so how would i

I have saved out an object using JSON.encode to a text file, is it possible to then create a new MovieClip and p开发者_C百科opulate it with all of the properties from the saved file? If so how would it be done, or is there a better way, thanks.


Very possible.

Check out as3corelib. It has some very nice JSON utilities. Then you can do something like:

var loader:URLLoader = URLLoader('pathToText/json.js');

//load
var things:Array = JSON.decode( loader.data );
for(var i:int = 0; i < things.length; i++) {
  for(var j:int = 0; j < things[i].length; j++) {
    trace(things[i][j].property);
  }
}

That being said, I think XML is really easy to use in AS3, and I generally prefer it when working with flash (for modest data sets, anyhow).

0

精彩评论

暂无评论...
验证码 换一张
取 消