Salut a tous voila j ai quelque petit probleme avec flash et l'xml
En faite j'essaye de faire une animation ou tous et gerer par xml
mon anim comporte 3 image clé
la premiere a comme code
Code PHP:
xmlPreload.xml
<fields>
<textField nom="charge" contenu="Chargé a :" x="170" y="175" largeur="60" hauteur="20" couleur="0xffffff" taille="12"/>
<textField nom="kocharge" contenu="Ko charger :" x="170" y="190" largeur="60" hauteur="20" couleur="0xffffff" taille="12"/>
<textField nom="ptotal" contenu="Poid total :" x="170" y="205" largeur="60" hauteur="20" couleur="0xffffff" taille="12"/>
</fields>
Code PHP:
preload.as
_root.onEnterFrame = function()
{
// on crée une boucle infinie ciblée sur la scène principale (_root)
Total = _root.getBytesTotal() ; // Total correspond à la taille de votre animation en Bytes
Lu = _root.getBytesLoaded() ; // Lu correspond à l'état courant de chargemement de votre animation en Bytes.
rapport = Math.round((Lu)/(Total)*100) ; // rapport permet de calculer le pourcentage d'avancement du préchargement.
_root.barre.gotoAndStop(rapport) ; // Progression de l'animation dans le clip "barre"
// Debut du pourcentage
// On crée un champ texte vide
// Avec comme instance "pourcentage"
// Profondeur = 10
// Position x = 140
// Position y = 30
// Largeur = 40
// Hauteur = 20
_root.createTextField("pourcent",20,230,175,40,20);
pourcentFormat = new TextFormat();
pourcentFormat.color = 0xffffff;
pourcentFormat.size = 12;
// Affichage du pourcentage dans un champ texte dynamique pourcentage
pourcent.text = Math.round(rapport) + "%";
pourcent.setTextFormat(pourcentFormat);
// Fin du pourcentage
//Debut du Ko charger
_root.createTextField("chargeko",30,230,190,40,20);
chargekoFormat = new TextFormat();
chargekoFormat.color = 0xffffff;
chargekoFormat.size = 12;
// Affichage du pourcentage dans un champ texte dynamique pourcentage
Kolu = Math.round((Lu)/1024);
chargeko.text = Math.round(Kolu) + "Ko";
chargeko.setTextFormat(chargekoFormat);
// Fin du Ko charger
// Debut de Poid total
ko = Math.round((Total)/1024); // On divise par 1024 le nombre octet afin d'avoir les ko
_root.createTextField("poidtotal",45,230,205,40,20);
poidtotalFormat = new TextFormat();
poidtotalFormat.color = 0xffffff;
poidtotalFormat.size = 12;
poidtotal.text = Math.round(ko) + "Ko"; // On affiche le nombre total de kb de la scene
poidtotal.setTextFormat(poidtotalFormat);
// Fin de Poid total
if (rapport == 100) { // si le rapport atteind son maximum alors le préchargement est fini
delete this.onEnterFrame ; // on détruit la boucle infinie pour libérer la mémoire et le CPU.
this.gotoAndStop("debut2") ; // on cible le début de l'animation dans cet exemple on stoppe l'animation sur la frame "début"
}
}
MyTextField = new XML();
MyTextFIeld.ignoreWhite = true;
MyTextField.onLoad = function()
{
for(var i =0; i<this.firstChild.childNodes.length; i++)
{
nom=this.firstChild.childNodes[i].attributes.nom;
contenu=this.firstChild.childNodes[i].attributes.contenu;
x=this.firstChild.childNodes[i].attributes.x;
y=this.firstChild.childNodes[i].attributes.y;
largeur=this.firstChild.childNodes[i].attributes.largeur;
hauteur=this.firstChild.childNodes[i].attributes.hauteur;
couleur=this.firstChild.childNodes[i].attributes.couleur;
taille=this.firstChild.childNodes[i].attributes.taille;
profondeur = 10+i;
// On crée le champ texte contenant tous les attribut
_root.createTextField(nom,profondeur,x,y,largeur,hauteur);
monFormat = new TextFormat();
monFormat.color = couleur;
monFormat.size = taille;
_root[nom].text = contenu;
_root[nom].setTextFormat(monFormat);
}
}
MyTextField.load("xml/xmlPreload2.xml");
stop() ; // stopper l'animation et lancement du preload.
image clé 2
Code PHP:
pour l'instant c et juste un petit effet de d'alpha progressif cachant le preload
puis redirige vers l'image 3
image clé 3
Code PHP:
xmlBouton.xml
<fields>
<textField nom="go1" adresse="/images/ bt01.jpg" x="170" y="175" largeur="60" hauteur="20"/>
<textField nom="go2" adresse="/images/ bt02.jpg" x="170" y="175" largeur="60" hauteur="20"/>
<textField nom="go3" adresse="/images/ bt03.jpg" x="170" y="175" largeur="60" hauteur="20"/>
</fields>
Code PHP:
xmlFile.xml
<fields>
<textField nom="monChamp1" contenu="Londres" x="320" y="6" largeur="60" hauteur="20" couleur="0xff0000" taille="12"/>
<textField nom="monChamp2" contenu="Amsterdam" x="320" y="20" largeur="60" hauteur="20" couleur="0xff0000" taille="12"/>
<textField nom="monChamp3" contenu="Budapest" x="320" y="35" largeur="60" hauteur="20" couleur="0xff0000" taille="12"/>
</fields>
Code PHP:
movieXML.as
stop();
// Attribut nom = nom du textField qui sera crée
// Attribut contenu = texte qui sera afficher dans le textField
// Attribut X = position X du textField
// Attribut Y = position Y du textField
// Attribut LARGEUR = largeur du textField
// Attribut Hauteur = hauteyr du textField
// Attribut Couleur = Deffinit la couleur du texte dans le textField
// Attibut Taille = Deffinit la taille en "pt" du texte du TextField
/* cet objet va contenir les informations
** que l'on va charger dynamiquement : */
myTextFields = new XML();
myTextFields.ignoreWhite = true;
// ici on definit ce qu'on va faire une
// fois que le xml sera completement chargé
myTextFields.onLoad = function(){
/* on fait une boucle sur tous les sous-noeuds
** (champs de texte) du document xml,
** le nombre de sous-noeuds correspond à la taille
** (nombre d'éléments) du tableau 'childNodes'
** contenant les sous-noeuds */
for(var i = 0; i<this.firstChild.childNodes.length ; i++)
{
/*on range les valeurs du xml dans des variables plus faciles d'utilisation*/
// On récupre l'attribut Nom du Xml
nom=this.firstChild.childNodes[i].attributes.nom;
// On recupere l'atribut contenu du XML
contenu=this.firstChild.childNodes[i].attributes.contenu;
// On recupere l'attribut X du XML
x=this.firstChild.childNodes[i].attributes.x;
// On recupere l'attribut Y du XML
y=this.firstChild.childNodes[i].attributes.y;
// On récupere l'attribut largeur du XML
largeur=this.firstChild.childNodes[i].attributes.largeur;
// On récupere l'attribut hauteur du XML
hauteur=this.firstChild.childNodes[i].attributes.hauteur;
// On récupere l'attribut couleur du XML
couleur=this.firstChild.childNodes[i].attributes.couleur;
// On récupere l'attribut taille du XML
taille=this.firstChild.childNodes[i].attributes.taille;
profondeur=10+i;
/* on créé le champ de texte, avec les caractéristiques prises dans le xml */
_root.createTextField(nom,profondeur,x,y,largeur,hauteur);
// Permet de definir les differnent format du textField
monFormat = new TextFormat();
// On definit la couleur grace a la variable definie plus haut
monFormat.color = couleur;
// On definit la taille grace a la variable definie plus haut
monFormat.size = taille;
/* on lui attribue le texte venant également du xml */
_root[nom].text = contenu;
// on applique tous les format definit plus haut au textField
_root[nom].setTextFormat(monFormat);
} /* fin du 'for' */
} /* fin du 'onLoad' */
/* maintenant que l'on a précisé les actions a accomplir
** après le chargement, on peut le charger : */
a
myTextFields.load("xmlFile.xml");
Mybouton = new XML();
Mybouton.ignoreWhite = true;
Mybouton.onLoad = function()
{
for(var i = 0; i<this.firstChild.childNodes.length; i++)
{
nom=this.firstChild.childNodes[i].attributes.nom;
adresse=this.firstChild.childNodes[i].attributes.adresse;
x=this.firstChild.childNodes[i].attributes.x;
y=this.firstChild.childNodes[i].attributes.y;
profondeur= 50+i;
_root.createEmptyMovieClip(nom, 10+i);
_root[bt01].loadMovie(adresse);
}
}
Mybouton.load("xml/xmlBouton.xml");
vous avez compris que chaque fichier .as et inclue dans l'image clé en question.
Mon probleme principal et le suivant.
Je n'arrive pas a afficher les bouton (grace a xmlBouton et Mybouton en image 3)
la 2 eme et que sur l'image 3 le texte generer au preload par le premier xml reste afficher, ya t il un moyen de dire a flash de decharger le fichier xml ?
L'affichage de tous les texte se fais sans probleme seul les bouton n'apparaissent pas.
Une autre question et il possible de faire passer des variable d'image en image a la maniere du php
$_POST[''];
existe il un equivalent sous flash
sur ce merci d'avance, si ya besoin de plus d info je suis la

.
Moi je me casse a la visite medical du boulot
thx