Pongo un List y un FLVPlayback y cuando selecciono un item de la lista teoricamente me lo reproduce este es el código:
Código HTML:
import mx.controls.List;
import mx.controls.MediaPlayback;
//Cargamos el XML
archivos = new XML();
archivos.ignoreWhite = true;
archivos.onLoad = function(success) {
if (success) {
//Shortcuts
archivo = archivos.firstChild;
num_total = archivos.firstChild.childNodes.length;
//Creamos y llenamos la lista
crearLista();
//Creamos el reproductor
crearPlayer();
} else {
trace("No se pudo cargar la lista de archivos");
}
};
archivos.load("xml/mp3.xml");
///////////////////////////////////////////////////////////////////
/////////////////////////// LISTENERS ///////////////////////////
///////////////////////////////////////////////////////////////////
lista.addEventListener("change", alCambiar);
///////////////////////////////////////////////////////////////////
/////////////////////////// FUNCIONES ///////////////////////////
///////////////////////////////////////////////////////////////////
function crearLista() {
//Posicionamos la lista de las archivos
//lista.setSize(180,200);
//lista._x = 220;
//lista._y = 0;
//Llenamos la lista con las archivos
misDatos = new Array();
lista.dataProvider = misDatos;
//var n=0
for (var n = 0; n<num_total; ) {
misDatos.addItem({label:archivo.childNodes[n].firstChild, data:archivo.childNodes[n+1].firstChild});
n = n+2;
}
}
function crearPlayer() {
//Posicionamos el reproductor
//player.setSize(200,200);
//player._x = 0;
//player._y = 0;
//Propiedades del reproductor
player.controllerPolicy = "on";
player.mediaType = "MP3";
}
//Cuando cambiamos la canción seleccionada en la lista... cargamos la nueva canción, y ejecutamos
function alCambiar(evento) {
if (evento.type == "change") {
//player.setMedia(lista.selectedItem.data);
//player.play();
import mx.video.*;
my_FLVPlybk.autoPlay = true;
my_FLVPlybk.contentPath = lista.selectedItem.data;
my_FLVPlybk.play();
}
}

