
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.93 KB | hits: 21 | expires: Never
How do I use a JSON API in Flash ActionScript 3.0
-----------XML Example:
//create a new XML object with the XML
xml = new XML(e.target.data);
//This gives us an XMLList (an array) of <item> tags
var all_items:XMLList = xml.channel.item;
//loop through the <item> tags
for (var i:uint = 0; i < all_items.length(); i++)
{
//get contents of title tag
var titleText:String = all_items[i].title.text();
//get contents of description tag
var descriptionText:String = all_items[i].description.text();
//get contents of link tag
var linkText:String = all_items[i].link.text();
//get contents of pubDate tag
var dateText:String = all_items[i].pubDate.text();
}
json = JSON.decode(e.target.data);
trace("json=" + json);
}
var response:Object = JSON.decode(e.target.data);