mike chambers | about

Simple Atom Example

Thursday, February 5, 2004

I have put together a very simple example that uses the Atom ActionScript API Alpha that I am working on.

This lists the all of the entries contained within my Atom.xml feed.

Here is the code:

import com.macromedia.data.Atom;

var a:Atom = new Atom();

a.addEventListener("onAtomLoad", this);

//event broadcast once the Atom feed has been loaded
function onAtomLoad(eventObj:Object):Void
{	
	var  entries:Array = a.entries;
	var len:Number = entries.length;
	
	//build the XML nodes for the Tree component
	var treeXML:String = "<node label=\"Entries\">";
	for(var i:Number = 0; i < len; i++)
	{
		treeXML += "<node label=\""+entries[i].title.value+"\" isBranch=\"\"/>";
	}
	treeXML += "</node>";
	
	entryTree.dataProvider = treeXML;
	entryTree.setIsOpen(entryTree.getTreeNodeAt(0), true);
}

a.load("http://www.markme.com/mesh/atom.xml");
twitter github flickr behance