November 25, 2007

Your iTunes playlist with Flex

Follow up to a tutorial I wrote a long time ago, here's how to display the XML file with Flex. Mike, no need for AS3 ;-)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" verticalAlign="top" backgroundColor="white"
creationComplete="itunesXML.send();">

<mx:HTTPService id="itunesXML" url="iTunes.xml" resultFormat="e4x" />
<mx:XMLListCollection id="songs" source="{itunesXML.lastResult.song}" />

<mx:DataGrid id="dataGrid" dataProvider="{songs}" width="100%">
 <mx:columns>
  <mx:DataGridColumn id="artist" dataField="Artist" headerText="Artist" />
  <mx:DataGridColumn id="album" dataField="Album" headerText="Album" />
  <mx:DataGridColumn id="bandname" dataField="Name" headerText="Name:" />
 </mx:columns>
</mx:DataGrid>
</mx:Application>

See the Itunes playlist with Flex SWF example or take a look at the source file here.

Have your say: