Populate new MovieClip() with JSON object properties
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).
精彩评论