Imotep26
Messages postés5Date d'inscriptionlundi 12 mars 2007StatutMembreDernière intervention 6 septembre 2009
-
4 sept. 2009 à 15:49
natif_de_la_salad
Messages postés2Date d'inscriptionjeudi 14 décembre 2006StatutMembreDernière intervention 7 septembre 2009
-
7 sept. 2009 à 20:37
Bonjour,
Je duplique un clip qui contient un champ texte, je voudrai ensuite renseigner ce champ texte dynamiquement à partir d'un xml. Cela est-il possible ?
Je bloque sur ça depuis un bon moment déjà ! :S
Voici mon bout de code :
var tab_e:Array = new Array();
doc = new XML(); //créé l'objet XML
doc.ignoreWhite = true
doc.onload=analyser; //cette fonction est appelle lorsque le load est terminé
doc.load("entremets.xml");
/////////////////////////////////// XML ////////////////////////////////////
function analyser(success)
{
//Si le chargement a été réalisé avec succès...
if (success)
{
main();
}
}
function main()
{
i = 0;
e = doc.firstChild;
trace(_global.rubrique)
for(i=0; i< e.childNodes.length; i++)
{
//if (e.childNodes[i].attributes.type == _global.rubrique)
//{
this.choco.duplicateMovieClip('choco'+i,i+1)
this.choco.txt_desc.duplicateMovieClip('desc'+i,i+1)
//modifier l'espace entre les images
id = i;
img = e.childNodes[i].attributes.img;
nom = e.childNodes[i].attributes.nom;
desc = e.childNodes[i].attributes.desc;
eval(this+'.choco'+i)._x = (i*168);
eval(this+'.choco'+i).conteneur.loadMovie('image/entremets/'+img);
eval(this+'.choco'+i+".desc"+i).descriptif.text = desc;
//trace(desc);
tab_e.push({id:id, img:img, nom:nom, desc:desc})
//}
}
}
choco._visible = false;
tiens c'est un menu xml simple que j'ai fait:
il détecte le nombre de "childNodes" , en duplique un clip, et y insert le titre...
j'espère que ça pourra t'aider... bon courage!
p.s: ma source est en foutoir mais si ta besoin que je t'explique n'ésite pas!
cs_Ali Bibi
Messages postés20Date d'inscriptionjeudi 27 juillet 2006StatutMembreDernière intervention 5 avril 2018 7 sept. 2009 à 16:35
En ActionScript2, j'avais fait un truc comme ça :
//// FRAME 1 ////
stop();
var table = new Array();
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("XXX.xml"); // c'est l'adresse du fichier XML
myXML.onLoad = function(flag) {
if (flag) {
i=0;
x = myXML.firstChild;
while (x.childNodes[i] != undefined) {
var tableau = new Object();
tableau.id = x.childNodes[i].attributes.id;
tableau.VariableA = x.childNodes[i].childNodes[0].attributes.VariableA;
tableau.VariableB = x.childNodes[i].childNodes[0].attributes.VariableB;
table.push(tableau);
i++;
}
play();
}
}
//// FRAME 2 ////
function copierClips(){
for(var i=0; i<table.length; i++){