Part 2 of data binding tutorial.

Hello again,

In part one, we saw an easy way to use the XML connector and dataBinding component to assign the contentPath propery of the media player component to one entry of an XML playlist.

In this tutorial, we go one step further and add a dataGrid then bind the selected index of that grid to the contentPath of the media Player component.

Before going further in this explanation, have a look here :

Custom MP3 Player-Glassy look

So how we do that?

First, the dataProvider property of the dataGrid has to be linked to the result of the XML parameter and more precisely to the array object in the results.

This ensures automatic parsing of the XML data into a bidimensional array which the dataGrid can use as a dataProvider.

Then, we use this code to listen to cell press event and to respond accordingly :

myListener = new Object();
myListener.change = function(evtObj) {
mp.contentPath = dg.selectedItem.location;

Where dg is the instance name of the dataGrid component and mp is that of the mediaPlayer component.

I’ve uploaded 4 songs I found on my HD, they do not correspond to the entries in the XML playlist yet that what I have for now so :)…

Till the next tutorial, stay safe and don’t do stupid things !


Leave a Reply