Probleme avec action script 2.0

blackitou Messages postés 8 Date d'inscription dimanche 2 août 2009 Statut Membre Dernière intervention 21 mars 2013 - 21 mars 2013 à 16:32
aerolyte Messages postés 465 Date d'inscription mardi 17 avril 2007 Statut Membre Dernière intervention 4 mai 2013 - 18 avril 2013 à 22:31
salutation a tous, c'est la 1 ère fois que je poste sur cet forum et j'ai vraiment besoin de votre aide j'ai créer un document flash qui importe des données d'un plan depuis un fichier xml mais mon problème que si je met la fonction trace i qui est dans un boucle ca me donne le dernier i (la derniere valeur du compteur) :/ bon voila mon code espérant que vous pouvez m'aider a trouver une solution




var myXML:XML = new XML(); var x=10; m=0 ; b=15; l=0;s=20; z=15; l2=0;
myXML.ignoreWhite=true;
myXML.onLoad = function(sucess){
if (sucess) {test1._visible = false;
Create_Rect = function (nom, posx, posy, h, l, col) {
this.createEmptyMovieClip("new_rect", this.getNextHighestDepth());
new_rect.beginFill("0xEEEEEE"+col);
new_rect.moveTo(posx, posy);
new_rect.lineTo(posx+l, posy);
new_rect.lineTo(posx+l, posy+h);
new_rect.lineTo(posx, posy+h);
new_rect.lineTo(posx, posy);
new_rect.endFill();
new_rect._name = nom;

};



logo._visible =false;logo2._visible =false;jdid._visible =false;

/////////////////Numero table////////////
for (i=1; i<=161 ; i++){a1=this.firstChild.childNodes[i-1].childNodes[0].firstChild.nodeValue;
if(i<26){_root.createTextField("periode"+(i+1), i+200, x+8, b, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(i%5==0){b=b+40;x=10;}}
if(i==26){b=b+50;}
if((i>=26)&&(i<51)){_root.createTextField("periode"+(i+1), i+200, x+8, b, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(i%5==0){b=b+40;x=10;}}
if(i==51){x=240; b=10;}
if((i>=51)&&(i<81)){s=i-50; _root.createTextField("periode"+(i+1), i+200, x+8, b+5, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(s%6==0){b=b+40;x=240;}}
if(i==81){x=240; b=260;}
if((i>=81)&&(i<111)){s=i-50; _root.createTextField("periode"+(i+1), i+200, x+4, b+5, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(s%6==0){b=b+40;x=240;}}
if(i==111){x=510; b=10;}
if((i>=111)&&(i<136)){s=i-50; _root.createTextField("periode"+(i+1), i+200, x+4, b+5, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(s%5==0){b=b+40;x=510;}}
if(i==136){x=510; b=260;}
if((i>=136)&&(i<161)){s=i-50; _root.createTextField("periode"+(i+1), i+200, x+4, b+5, 30, 50); z=z+40; with (_root["periode"+(i+1)]) {text =a1 ;} x=x+40; if(s%5==0){b=b+40;x=510;}}
if (i%5==0) {z=z+60;} if (i%15==0) {s=s+40; l2=l2+1; if (i<99){z=20;}else{z=13;}} if (i%75==0) {s=s+60;} }







/////////////////Cadre////////////
x=10; u=40; b=10;






for (i=1; i<=161 ; i++){
etat1.text=etat= this.firstChild.childNodes[i-1].childNodes[1].firstChild.nodeValue;
if(i<26){ Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(i%5==0){b=b+40;x=10;}}
if(i==26){b=b+50;}
if((i>=26)&&(i<51)){ Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(i%5==0){b=b+40;x=10;}}
if(i==51){x=240; b=10;}
if((i>=51)&&(i<81)){s=i-50; Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(s%6==0){b=b+40;x=240;}}
if(i==81){x=240; b=260;}
if((i>=81)&&(i<111)){s=i-50; Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(s%6==0){b=b+40;x=240;}}
if(i==111){x=510; b=10;}
if((i>=111)&&(i<136)){s=i-50; Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(s%5==0){b=b+40;x=510;}}
if(i==136){x=510; b=260;}
if((i>=136)&&(i<161)){s=i-50; Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40; if(s%5==0){b=b+40;x=510;}}


if (etat=="0"){newcolor = new Color("monclip"+i);newcolor.setRGB(0x55be47);}else {newcolor = new Color("monclip"+i);newcolor.setRGB(0xff9081);}
_root["monclip"+i]._alpha=50;
_root["monclip"+i].indice = i;

_root["monclip"+i].onPress = function () { trace(i);
}}




}}
myXML.load("sample.xml");





et voila mon fichier xml http://www.made-in-tunisia.net/b2b/industrie2013/_medias_docs/sample.XML

2 réponses

piere2 Messages postés 235 Date d'inscription lundi 26 février 2007 Statut Membre Dernière intervention 26 mai 2013
22 mars 2013 à 18:08
Bonjour,
Il faut que ton trace soit dans la boucle for.

Pi'ère2
0
aerolyte Messages postés 465 Date d'inscription mardi 17 avril 2007 Statut Membre Dernière intervention 4 mai 2013 1
18 avril 2013 à 22:31
Bonsoir,

Quelques suggestions:

grouper les variables:
var myXML:XML=new XML(),x=10,m=0,b=15,l=0,s=20,z=15,l2=0;


simplifier ceci:
logo._visible =false;logo2._visible =false;jdid._visible =false; 

en cela:
logo._visible=logo2._visible=jdid._visible =false; 


enlever les espaces inutiles,du genre:
if((i>=26)&&(i<51)){ Create_Rect("monclip"+i, x, b, 30, 30, 000000); x=x+40;

comme ca:
if((i>=26)&&(i<51)){Create_Rect("monclip"+i,x,b,30,30,000000);x=x+40;



sinon est-ce normal que certaine valeur reponde a 2 conditions du genre 26,51,...
0
Rejoignez-nous