Dupliquer un clip avec un champ texte

Imotep26 Messages postés 5 Date d'inscription lundi 12 mars 2007 Statut Membre Dernière intervention 6 septembre 2009 - 4 sept. 2009 à 15:49
natif_de_la_salad Messages postés 2 Date d'inscription jeudi 14 décembre 2006 Statut Membre Derniè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;



Merci d'avance !

4 réponses

natif_de_la_salad Messages postés 2 Date d'inscription jeudi 14 décembre 2006 Statut Membre Dernière intervention 7 septembre 2009
6 sept. 2009 à 02:15
http://guy.desmet.free.fr/sources_flash/menu_xml.rar

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!
0
Imotep26 Messages postés 5 Date d'inscription lundi 12 mars 2007 Statut Membre Dernière intervention 6 septembre 2009
6 sept. 2009 à 13:42
Merci pour réponse ;)

Mais le lien ne marche pas :s
0
cs_Ali Bibi Messages postés 20 Date d'inscription jeudi 27 juillet 2006 Statut Membre Derniè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++){


_root.attachMovie("NomDuClip", "Idem"+i, i+1, table[i]);


_root["Idem"+i].onRollOver = function(){
this.depth = this.getDepth();
this.swapDepths(99999);
this.gotoAndPlay(2);
}

_root["Idem"+i].onRollOut = function(){
this.swapDepths(this.depth);
this.gotoAndPlay(1);
}



}
}
stop();
copierClips();


Ali
0
natif_de_la_salad Messages postés 2 Date d'inscription jeudi 14 décembre 2006 Statut Membre Dernière intervention 7 septembre 2009
7 sept. 2009 à 20:37
oui c'est un peu le meme style que j'ai fait...
http://guy.desmet.free.fr/sources_flash/ et tu prend le fichier menu_xml.rar
0
Rejoignez-nous