Tambi�n puedes usar un Array como un dataProvider. Cuando metes un compo en
la biblioteca te a�ade autom�ticamente el API del DataProvider al prototype
del Array. Es decir es factible esto:
var a:Array = new Array();
a.addItem({nombre:"pele",edad:25});
compo.labelField = "nombre";
compo.dataProvider = a;
Un saludo,
Joseba Alonso
www.5dms.com
www.sidedev.net
> -----Mensaje original-----
> De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En
> nombre de Manu Alvarez
> Enviado el: mi�rcoles, 27 de abril de 2005 21:27
> Para: [email protected]
> Asunto: Re: [ASNativos] DataProvider en AS2
>
> Pasa del dataProvider ;)
>
> Crea un array normal y corriente, y en cada posici�n metes un objeto con
> las
> propiedades label y data, y al final haces:
> componente.dataProvider = arrayEse
>
> suele chutar bastante bien :P
>
> ----- Original Message -----
> From: "Jos� Vivar" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, April 27, 2005 4:04 PM
> Subject: [ASNativos] DataProvider en AS2
>
>
> Me estoy volviendo mico con esto del DataProvider en Flash 2004. Quiero
> sacar los datos de un XML y luego crear un din�micamente tantos
> componentes
> como secciones tenga.
>
> La cosa por ahora va as�:
>
>
> AS:
>
>
>
> 1
>
>
> 2
>
>
> 3
>
>
> 4
>
>
> 5
>
>
> 6
>
>
> 7
>
>
> 8
>
>
> 9
>
>
> 10
>
>
> 11
>
>
> 12
>
>
> 13
>
>
> 14
>
>
> 15
>
>
> 16
>
>
> 17
>
>
> 18
>
>
> 19
>
>
> 20
>
>
> 21
>
>
> 22
>
>
> 23
>
>
> 24
>
>
> 25
>
>
> 26
>
>
> 27
>
>
> 28
>
>
> 29
>
>
> 30
>
>
> 31
>
>
> 32
>
>
> 33
>
>
> 34
>
>
> 35
>
>
> 36
>
>
> 37
>
>
> 38
>
>
> 39
>
>
> 40
>
>
> 41
>
>
> 42
>
>
> 43
>
>
> 44
> import mx.controls.listclasses.DataProvider
>
> var datosSecciones_dp:DataProvider = new DataProvider();
> var Datos_obj:Object = new Object();
>
> var miXml:XML = new XML();
> miXml.ignoreWhite = true;
> miXml.onLoad = function(ok) {
> if (ok) {
> trace("Ha cargado el XML");
> var nodoPrincipal = miXml.firstChild;
> var longSecciones:Number = nodoPrincipal.childNodes.length;
> trace("Longitud de Secciones: "+longSecciones);
>
> for (i=0; i<longSecciones; i++) {
> Datos_obj.nombreSeccion =
> nodoPrincipal.childNodes[i].attributes.nombre;
> trace("Nombre: " + Datos_obj.nombreSeccion)
> Datos_obj.imagenSeccion =
> nodoPrincipal.childNodes[i].attributes.imagen;
> trace("Imagen: " + Datos_obj.imagenSeccion)
> Datos_obj.seccion = i+1;
> trace("Seccion: " + Datos_obj.seccion)
> // Insertamos la informacion en el DataProvider
>
> datosSecciones_dp.addItem({NOMBRESECCION:Datos_obj.nombreSeccion,
> IMAGENSECCION:Datos_obj.imagenSeccion,
> SECCION:Datos_obj.seccion});
> }
> // Parametros
> var posicionX:Number = 4;
> var posicionY:Number = 31;
> var separacion:Number = 15;
> // Pintamos los botones de las secciones
> for (a=1; a<longSecciones; a++){
> seccion_mc.attachMovie("botoMenu", "botonSecciones"+a+"_mc",
> a);
> // Cargamos Nombre del Boton y sombra
> seccion_mc["botonSecciones" + a + "_mc"].textoseccion =
> datosSecciones_dp.getItemAt(a).NOMBRESECCION;
> trace("Entra " + a + " Muestra " +
> datosSecciones_dp.getItemAt(a).NOMBRESECCION)
> seccion_mc["botonSecciones" + a + "_mc"].imagen =
> datosSecciones_dp.getItemAt(a).IMAGENSECCION;
> seccion_mc["botonSecciones" + a + "_mc"].seccion =
> datosSecciones_dp.getItemAt(a).SECCION;
> }
> } else {
> trace("Error en la carga del XML");
> }
> };
> miXml.load("xml/instalaciones.xml");
>
>
>
> Carga el XML, carga y traza la informaci�n, pero no llena el dataprovider.
> He mirado en varios sitios (b�squeda en el foro, blogs, google, etc..) y
> cada uno lo hace de una forma diferente (addEventListener, inicializando
> Arrays, etc...)
>
> No se que estoy haciendo mal.
>
> ----------------------------------
> Lista ASNativos:[email protected]
> http://www.5dms.com/listas
> ----------------------------------
>
>
> --------------------------------------------------------------------------
> --
> -----------------------
> Texto a�adido por Panda Client Shield:
>
> Este mensaje NO ha sido clasificado como SPAM. Si se trata de un mensaje
> de
> correo no solicitado (SPAM), haz clic en el siguiente v�nculo para
> reclasificarlo: http://127.0.0.1:6083/Panda?ID=pav_782&SPAM=true
> --------------------------------------------------------------------------
> --
> -----------------------
>
>
> ----------------------------------
> Lista ASNativos:[email protected]
> http://www.5dms.com/listas
> ----------------------------------
----------------------------------
Lista ASNativos:[email protected]
http://www.5dms.com/listas
----------------------------------