Bonjour,

Je suis sous AS2, depuis quelques jours et je me retrouve confronter à un problème de MovieClip que je n'arrive pas à atteindre pour l'effacer.
L'idée c'est de créer un organigramme dynamique avec un fichier xml.
L'importation se fait sans problème et j'arrive à récupérer mes valeurs xml.
Je créée ainsi autant de bouton que de "balises" Direction, Service et Personne que j'en ai dans mon XML.

[Direction 1] [Direction2] [Direction3]
|=|
[Directeur Toto] -> [Service 1] -> [Personne 1] /[Personne 2] /[Personne 3]

Je construis donc un MovieClip pour les boutons 'Direction', ceux ci vont contenir la fiche Directeur et les boutons 'Services' qui construiront enfin, un MovieClip avec les 'Personnes'...
Mon soucis est que je souhaiterais à chaque clic sur un bouton 'Direction' effacer tout les boutons 'Services' crées précédemment. Idem pour un clic 'Service', effacer tout les boutons 'Personnes'.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
_root.document=new XML(); //création de l'objet XML 
_root.document.ignoreWhite=true;// les espaces vides sont supprimés 
_root.document.load("organigramme.xml");//chargement du document XML 
_root.stop(); 
_root.document.onLoad=function(){ //quand le chargement du document est terminé , lancement de l'animation 
 
	 _global.id_direction=0;
	 _global.nb_service=0; 
	var Voir_xml=""; 
	var num_serv = 0;  
	x = document.childNodes[0]; 
	//Les positions
	var pos_x =20; 
	var pos_y = 10; 
	var larg =150; 
	var haut = 50; 
	   // DIRECTION 
	  for(y = 0; x.childNodes[y] != undefined; y++) {  //Boucle DIRECTION 
		   var id_resp = x.childNodes[y].attributes.directeur; 
		   Voir_xml += " Nom Direction: " + x.childNodes[y].attributes.nomd;  + "\n"; 
		   Voir_xml += " Directeur: " + x.childNodes[y].childNodes[0].childNodes[0].firstChild + "\n";   
 
		   fillRectDirection(pos_x, pos_y, larg, haut,x.childNodes[y].attributes.nomd, y) ; 
		   pos_x = pos_x+larg+10;
		   Voir_xml +=  "\n"; 
	  } 
 
	trace(Voir_xml); 
	gotoAndStop(2);
} 
 
function fillRectDirection(x1:Number, y1:Number,  
		width:Number, height:Number, txt_direction:String, id_direction:Number) { 
	    var dpos_x =x1; 
		var dpos_y = y1; 
		var mc:MovieClip = this.createEmptyMovieClip("mBouton", this.getNextHighestDepth());  
        this.attachMovie("mBouton", mc, this.getNextHighestDepth());  
		// On dessine le bouton  
		mc.lineStyle(1, 0x91A8DD, 50); 
		mc.beginFill(0x91A8DD, 100); 
		mc.moveTo(dpos_x, dpos_y);  
		mc.lineTo(dpos_x+width, dpos_y); 
		mc.lineTo(dpos_x+width, dpos_y+height); 
		mc.lineTo(dpos_x, dpos_y+height); 
		mc.lineTo(dpos_x, dpos_y); 
		mc.endFill(); 
 
		mc.createTextField("montxt" , this.getNextHighestDepth() , dpos_x+5 , dpos_y+5 , width , height);   
		mc.montxt.multiline = true; 
		mc.montxt.wordWrap = true;		  
		var my_fmt:TextFormat = new TextFormat(); 
		my_fmt.color = 0x336699; 
		my_fmt.size = 14; 
		my_fmt.font = "Arial";  
	    mc.montxt.text= txt_direction; 
		mc.montxt.setTextFormat(my_fmt); 
		mc.onPress = function() {  
 
 
			removeMovieClip(mc2);
 
			/*if (_root.directeur!= undefined){
				trace(" objet directeur= "+_root.directeur);
				trace(" objet Service= "+ _root.mBoutonS);
				trace(" objet Personnel= "+ _root.mBoutonP);
				removeThisMovieClip ( _root.directeur);
				removeThisMovieClip ( _root.mBoutonS);
				removeThisMovieClip ( _root.mBoutonP);
 
			}*/
 
		    for(z = 0;  z<_global.nb_service ; z++) { //Boucle nbre de SERVICE 
                            EFFACER LES BOUTONS SERVICES "mBoutonS"+z
			}
			 _global.nb_service=0; 
 
			 var y =id_direction; 
			 var spos_x=20;
			 fillRectDirecteur(spos_x,y1+100,width, height, y);		
			 spos_x=spos_x+width+10; 
			  for(z = 1; x.childNodes[y].childNodes[z] != undefined; z++) { 
			  	 trace("création service "+z);				 
			     fillRectService(spos_x,y1+100,width, height, y,z); 
				 spos_x=spos_x+width+10; 
			  }
		}  
	} 
 
 function fillRectDirecteur(x1:Number, y1:Number, width:Number, height:Number,  y:Number) { 
 
				var z:String ="directeur";
				var pos_x=x1;
				var pos_y=y1;
			    var mcDirecteur:MovieClip = this.createEmptyMovieClip("directeur", 3); 
				mcDirecteur.lineStyle(1, 0x006B6B, 50); 
				mcDirecteur.beginFill(0x006B6B, 100); 
				mcDirecteur.moveTo(pos_x, pos_y);  
				mcDirecteur.lineTo(pos_x+width, pos_y); 
				mcDirecteur.lineTo(pos_x+width, pos_y+height); 
				mcDirecteur.lineTo(pos_x, pos_y+height); 
				mcDirecteur.lineTo(pos_x, pos_y); 
				mcDirecteur.endFill(); 
 
				mcDirecteur.createTextField("montxt" , 3 , pos_x+5 , pos_y+5 , width , height); 
 
				mcDirecteur.montxt.multiline = true; 
				mcDirecteur.montxt.wordWrap = true;		  
 
				mcDirecteur.montxt.text=  x.childNodes[y].childNodes[0].childNodes[0].firstChild ; 
				mcDirecteur.montxt.setTextFormat(my_fmt);   
				var directeur  =this.attachMovie("directeur", mcDirecteur, 3);
 
 }
 
 function fillRectService(x1:Number, y1:Number, width:Number, height:Number,  y:Number, z:Number ) { 
	    var pos_x =x1; 
		var pos_y = y1; 
		var my_fmt:TextFormat = new TextFormat(); 
			my_fmt.color = 0x336699; 
			my_fmt.size = 14; 
			my_fmt.font = "Arial"; 
 
			_global.nb_service = _global.nb_service+1; 
 
		        var mc2:MovieClip = this.createEmptyMovieClip("mBoutonS"+z, 4+z); 
				var mBoutonService = this._parent.attachMovie("mc"+z,"mBoutonS"+z,  4+z); 				
 
				// On dessine le bouton 
				mc2.lineStyle(1, 0x91A8DD, 50); 
				mc2.beginFill(0x91A8DD, 100); 
				mc2.moveTo(pos_x, pos_y);  
				mc2.lineTo(pos_x+width, pos_y); 
				mc2.lineTo(pos_x+width, pos_y+height); 
				mc2.lineTo(pos_x, pos_y+height); 
				mc2.lineTo(pos_x, pos_y); 
				mc2.endFill(); 
 
				mc2.createTextField("montxt"+z , 4+z , pos_x+5 , pos_y+5 , width , height); 
 
				mc2["montxt"+z].multiline = true; 
				mc2["montxt"+z].wordWrap = true;		  
 
				mc2["montxt"+z].text=  x.childNodes[y].childNodes[z].attributes.noms +" x="+pos_x; 
				mc2["montxt"+z].setTextFormat(my_fmt); 
 
		        mc2.onPress = function() {  				 
				   fillRectPersonnel(20, pos_y+100, width, height,y,z, mc2._name);
		 		}
 
}		
 
function fillRectPersonnel(x1:Number, y1:Number, width:Number, height:Number,  y:Number, z:Number, num_s:String) { 
		var dpos_x =x1; 
		var dpos_y = y1; 
 
		 trace("direction= "+y+" Service= "+num_s);
		 var mcPersonnel:MovieClip = this.createEmptyMovieClip("mBoutonP", 5);  
         for(a = 0; x.childNodes[y].childNodes[z].childNodes[a] != undefined; a++) { //Boucle PERSONNE 
 
			    // On dessine le bouton  
				mcPersonnel.lineStyle(1, 0x91A8DD, 50); 
				mcPersonnel.beginFill(0x91A8DD, 100); 
				mcPersonnel.moveTo(dpos_x, dpos_y);  
				mcPersonnel.lineTo(dpos_x+width, dpos_y); 
				mcPersonnel.lineTo(dpos_x+width, dpos_y+height); 
				mcPersonnel.lineTo(dpos_x, dpos_y+height); 
				mcPersonnel.lineTo(dpos_x, dpos_y); 
				mcPersonnel.endFill(); 
			  Voir_xml += " Nom : " + x.childNodes[y].childNodes[z].childNodes[a].childNodes[0].firstChild + "\n"; 
			  Voir_xml += " Tel. : " +y+z+a+"2"; 
			  Voir_xml += " Tel. : " + x.childNodes[y].childNodes[z].childNodes[a].childNodes[2].childNodes[0]+ "\n"; 
 
 
		   }  
		 trace(Voir_xml);
		var mBoutonP = this.attachMovie("mBoutonP", mcPersonnel,5); 
 
}
Actuellement, il m'affiche mes services correspondant à la Direction demandée, sauf que, lorsque je clique sur une autre direction qui a moins de services que la précédente, il me les laisse les anciens affichés.
J'espère arriver à me faire comprendre :/
Donc mon idée serait de lui dire que sur un clic d'un bouton de Direction, il m'efface tout les boutons Services affichés, soit removeMovieClip (clip); clip étant "mBoutonS"+z;

Merci de votre aide.
Un cactus à sec