| 12
 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
 
 |  
_root.attachMovie('tableau-bas','tab_benef',_root.clip_tab.getNextHighestDepth() );
_root.clip_tab.contentPath = "empty";
_root.clip_tab.setSize(200, 300);
 
//parcours de l'arbo xml
Fichier_XML = new XML(); 
Fichier_XML.ignoreWhite = true; 
Fichier_XML.load("benefits.xml"); 
Fichier_XML.onLoad = function(Reussite) 
{ 
	if (Reussite) 
	{ 
		var couleur1:Number = 0x003466;
		var couleur2:Number = 0x008011;
		var couleur3:Number = 0xFE9900;
		var couleur4:Number = 0x800080;
		var couleur5:Number = 0x808080;
		var couleur6:Number = 0x820000;
		var couleut:Number;
		//créer un format de texte
		var format1_fmt:TextFormat = new TextFormat();
		format1_fmt.font = "Arial";
		format1_fmt.size= 11;
		format1_fmt.color = couleur1;
		format1_fmt.bold = true;
 
		var format2_fmt:TextFormat = new TextFormat();
		format2_fmt.font = "Arial";
		format2_fmt.size= 10;
 
		x = Fichier_XML.firstChild; 
		var Voir_xml:String = "";
		var Y:Number = 359;
		var X:Number = 430;
		var prof:Number = 0;
		var MyLine:String = "";
		var Multi:Boolean = false;
		for(i = 0; x.childNodes[i] != undefined; i++) 
		{ //parcours les benefices
			switch (i)
			{
				case 0:
				couleur = couleur1;
				break;
				case 1:
				couleur = couleur2;
				break;
				case 2:
				couleur = couleur3;
				break;
				case 3:
				couleur = couleur4;
				break;
				case 4:
				couleur = couleur5;
				break;
				case 5:
				couleur = couleur6;
				break;
			}
			format1_fmt.color = couleur;
			//tracer une ligne
			MyLine = "ligne"+i;
			_root.tab_benef.createEmptyMovieClip(MyLine,prof); //nom,profondeur
			_root.tab_benef[MyLine].lineStyle (2, couleur, 100); //taille, couleur, transparence
			_root.tab_benef[MyLine].moveTo( 0,Y); //x_origine, y_origine
			_root.tab_benef[MyLine].lineTo( 883.9, Y); //x_desti,y_desti
 
			Y = Y + 5;
			prof++;
			trace(_root.clip_tab.contentPath);
			//générer un champs texte
			var myTF="CT" + i; //CT pour "ChampTexte", un chiffre pour différencier.
			_root.tab_benef.createTextField(myTF,prof,0,Y,70,16); //nom,profondeur,x,y,L,H
 
			_root.tab_benef[myTF].border=false;
			_root.tab_benef[myTF].text = x.childNodes[i].attributes.nom;
			_root.tab_benef[myTF].setTextFormat(0, _root.tab_benef[myTF].text.length, format1_fmt);//debut, fin, nom du format
 
			prof++;
 
			for(j=0;x.childNodes[i].childNodes[j] != undefined; j++) 
			{ //parcours les champs
				//générer un champs texte
				var myTF="CT" + i + j; //CT pour "ChampTexte", un chiffre pour différencier.
 
				if(x.childNodes[i].childNodes[j].attributes.nom.length > 60)
				{
					_root.tab_benef.createTextField(myTF,prof,92,Y,308,32); //nom,profondeur,x,y,L,H
					_root.tab_benef[myTF].border=false;
					_root.tab_benef[myTF].text = x.childNodes[i].childNodes[j].attributes.nom;
 
					_root.tab_benef[myTF].multiline = true;
					_root.tab_benef[myTF].wordWrap = true;
					Multi = true;
				}
				else
				{
					_root.tab_benef.createTextField(myTF,prof,92,Y,308,16); //nom,profondeur,x,y,L,H
					_root.tab_benef[myTF].border=false;
					_root.tab_benef[myTF].text = x.childNodes[i].childNodes[j].attributes.nom;
					Multi = false;
				}
				_root.tab_benef[myTF].setTextFormat(0, _root.tab_benef[myTF].text.length, format2_fmt);//debut, fin, nom du format
				prof++;
 
				for(k=0;x.childNodes[i].childNodes[j].childNodes[k].firstChild.nodeValue != undefined; k++) 
				{ //parcours les valeurs
 
					var myTF="CT" + i + j + k; //CT pour "ChampTexte", un chiffre pour différencier.
					if(x.childNodes[i].childNodes[j].childNodes[k].firstChild.nodeValue.length > 13)
					{
						_root.tab_benef.createTextField(myTF,prof,X,Y,80,32); //nom,profondeur,x,y,L,H
						_root.tab_benef[myTF].border=false;
						_root.tab_benef[myTF].text = x.childNodes[i].childNodes[j].childNodes[k].firstChild.nodeValue;
						_root.tab_benef[myTF].multiline = true;
						_root.tab_benef[myTF].wordWrap = true;
						Multi = true;
					}
					else
					{
						_root.tab_benef.createTextField(myTF,prof,X,Y,90,16); //nom,profondeur,x,y,L,H
						_root.tab_benef[myTF].border=false;
						_root.tab_benef[myTF].text = x.childNodes[i].childNodes[j].childNodes[k].firstChild.nodeValue;
						if(Multi)
						{
							Multi = true;
						}
						else
						{
							Multi = false;
						}
					}
 
						_root.tab_benef[myTF].setTextFormat(0, _root.tab_benef[myTF].text.length, format2_fmt);//debut, fin, nom du format
						prof++;
						X = X + 97;
 
				}
 
				if(Multi)
				{
					Y = Y + 37;
				}
				else
				{
					Y = Y + 21;
				}
				Multi = false;
				X = 430;
			}
		} 
 
	_root.clip_tab.attachMovie("tab_benef","benefits",prof++);
 
	_root.clip_tab.invalidate();
	trace(_root.clip_tab);
	} 
	else 
	{
		Voir_xml = "Erreur lors du chargement du fichier XML"; 
	}
}; | 
Partager