Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.93 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I use a JSON API in Flash ActionScript 3.0
  2. -----------XML Example:
  3.         //create a new XML object with the XML
  4.         xml = new XML(e.target.data);
  5.  
  6.         //This gives us an XMLList (an array) of <item> tags
  7.         var all_items:XMLList = xml.channel.item;
  8.  
  9.         //loop through the <item> tags
  10.         for (var i:uint = 0; i < all_items.length(); i++)
  11.         {
  12.             //get contents of title tag
  13.             var titleText:String = all_items[i].title.text();
  14.  
  15.             //get contents of description tag
  16.             var descriptionText:String = all_items[i].description.text();
  17.  
  18.             //get contents of link tag
  19.             var linkText:String = all_items[i].link.text();
  20.  
  21.             //get contents of pubDate tag
  22.             var dateText:String = all_items[i].pubDate.text();
  23.         }
  24.        
  25. json = JSON.decode(e.target.data);
  26.  
  27.         trace("json=" + json);
  28.     }
  29.        
  30. var response:Object = JSON.decode(e.target.data);