Home > News > itunesXMLParser Flex component

itunesXMLParser Flex component

August 14th, 2007

I took a bit of time to convert the itunesXMLParser class into a full fledge Flex component.

You can download the SWC here

Heres a bit of usage:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="absolute"
	xmlns:im="org.im.*"
	>
 
<im:itunesXMLParser 
	id="ixml" 
	sourceXML="testlibrary.xml" 
	complete="dg_mx.dataProvider=ixml.data"/>
 
 
<mx:DataGrid id="dg_mx" 
	width="80%" 
	height="40%"  
	rowCount="10" 
	verticalCenter="4" 
	horizontalCenter="0">
<mx:columns>
    <mx:DataGridColumn dataField="Track_ID" headerText="Track_ID"/>
    <mx:DataGridColumn dataField="Name" headerText="Name"/>
    <mx:DataGridColumn dataField="Artist" headerText="Artist"/>
    <mx:DataGridColumn dataField="Genre" headerText="Genre"/>
    <mx:DataGridColumn dataField="Kind" headerText="Kind"/>
    <mx:DataGridColumn dataField="Size" headerText="Size"/>
    <mx:DataGridColumn dataField="Total_Time" headerText="Total Time"/>
    <mx:DataGridColumn dataField="Date_Modified" headerText="Date Modified"/>
    <mx:DataGridColumn dataField="Date_Added" headerText="Date Added"/>
    <mx:DataGridColumn dataField="Bit_Rate" headerText="Bit Rate"/>
    <mx:DataGridColumn dataField="Sample_Rate" headerText="Sample Rate"/>
    <mx:DataGridColumn dataField="Release_Date" headerText="Release Date"/>
    <mx:DataGridColumn dataField="Sort_Album" headerText="Sort Album"/>
    <mx:DataGridColumn dataField="Sort_Name" headerText="Sort Name"/>
    <mx:DataGridColumn dataField="Persistent_ID" headerText="Persistent ID"/>
    <mx:DataGridColumn dataField="Track_Type" headerText="Track Type"/>
    <mx:DataGridColumn dataField="Podcast" headerText="Podcast"/>
    <mx:DataGridColumn dataField="Unplayed" headerText="Unplayed"/>
    <mx:DataGridColumn dataField="Location" headerText="Location"/>
    <mx:DataGridColumn dataField="File_Folder_Count" headerText="File Folder Count"/>
    <mx:DataGridColumn dataField="Library_Folder_Count" headerText="Library Folder Count"/>
</mx:columns>
 
</mx:DataGrid>

This line shows the usage of the component

<im:itunesXMLParser 
	id="ixml" 
	sourceXML="testlibrary.xml" 
	complete="dg_mx.dataProvider=ixml.data"/>

This allows you to easily specify an itunes library file as a source for the component and then use the complete listener to perform some action once the data has been loaded. In this case I’m binding it to the dataProvider property of my DataGrid component.

xmlns:im="org.im.*"

This shows you how to set up the xml namespace so you can use the im:itunesXMLParser tag to instantiate the component. Also, don’t forget to include the .swc file into your library path in the project settings.

ian News

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.