Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question// on déclare toujours les variables avec la forme // var nomVariable:Type = new Type(); // sauf pour les variables inclus dans le lecteur qui sont déjà "créés" // je sais que c'est pas obligatoire car flash est très "gentil" // mais c'est une habitude à prendre afin de passer à l'as3 qui lui sera moins sympa. var flag:Boolean = false; var chanson:Number = 0; var p:Number = 0; var i:Number = 0; var j:Number = 0; var Fichier_XML:XML = new XML(); Fichier_XML.ignoreWhite = true; // _root.liste // ici inutile de mettre _root puisqu'on y est (à moins que tu intègres ce lecteur un autre // swf, mais dans ce cas, on utilisera _parent à la place de _root. //if (_parent.liste undefined) {_parent.liste "son";} //s'il ne doit pas être intégré mais qu'il peut l'être (gérer les 2 donc) //on fera plus var liste:String = "son"; if (_parent.liste <> undefined) {liste = _parent.liste;} // petite astuce utiliser ? et donc gagner une ligne var liste:String = _parent.liste==undefined?"son":_parent.liste; // je te laisse découvrir cette ligne ;) Fichier_XML.load(liste+".xml"); var musica:Array = new Array(); var artiste:Array = new Array(); var titre:Array = new Array(); var logo:Array = new Array(); var sons:Array = new Array(); Fichier_XML.onLoad = function(Reussite:Boolean) { if (Reussite) { // tu peux créer un type objet afin d'éviter les lignes à rallonge et faire // var node:Object = new Object(); // node = Fichier_XML.childNodes[0].childNodes[i]; // et donc // node.childNodes[0].firstChild; pour musica par exemple for (i=0; Fichier_XML.childNodes[0].childNodes[i]!=undefined; i++) { musica[i] = Fichier_XML.childNodes[0].childNodes[i].childNodes[0].firstChild; artiste[i] = Fichier_XML.childNodes[0].childNodes[i].childNodes[1].firstChild; titre[i] = Fichier_XML.childNodes[0].childNodes[i].childNodes[2].firstChild; logo[i] = Fichier_XML.childNodes[0].childNodes[i].childNodes[3].firstChild; sons[i] = new Sound(); // normalement un objet sound doit être attaché à un clip new Sound(unClip) si tu a une multitude de son à mixer (mais pas obligatoire dans un lecteur mp3) _root.conteneurtitre.attachMovie("titremusica","titremusica"+i,i+10); // alors pour les eval c'est à éviter ça a été remplacer par l'expression this // par exemple la commande suivante pourrait être remplacée par // _root["conteneurtitre.titremusica"+i].textmusica.text = titre[i]; // ou // _root.conteneurtitre["titremusica"+i].textmusica.text = titre[i]; // et donc pareil, on évite le _root donc on fera plus normalement : // _parent["....."+i].te.....; ou // this["...."+i].te....; // ceci afin que tu ne sois pas perdu quand tu passera à l'as3 car eval n'existera plus // // aussi puisque tu pointe plusieurs fois sur cette objet, tu peux créer un objet pour pointer dessus : // var target:MovieClip = _root.conteneurtitre["titremusica"+i]; // et donc ensuite faire tes affectations plus facilement // target.textmusica.text = titre[i]; // target.textartist.text = artiste[i]; // etc.... eval("_root.conteneurtitre.titremusica"+i).textmusica.text = titre[i]; eval("_root.conteneurtitre.titremusica"+i).textartist.text = artiste[i]; textmusica.autoSize = true; eval("_root.conteneurtitre.titremusica"+i)._x = 100; eval("_root.conteneurtitre.titremusica"+i)._y = 18*i+18; eval("_root.conteneurtitre.titremusica"+i).num = i; eval("_root.conteneurtitre.titremusica"+i).attachMovie("bib","bib_load",1); eval("_root.conteneurtitre.titremusica"+i).bib_load._x = -100; eval("_root.conteneurtitre.titremusica"+i).bib_load._y = -8; eval("_root.conteneurtitre.titremusica"+i).bib_load.stop(); eval("_root.conteneurtitre.titremusica"+i).bib_load._visible = false; eval("_root.conteneurtitre.titremusica"+i).onPress = function() { flag = true; // même dans une boucle for on initialise la variable j // for (var j:Number=0;j<sons.length;j++) for (j=0;j<sons.length;j++) { sons[j].stop(); } if (_root.sons[this.num].duration==undefined) { //this.num car on est actuellement dans le onpress de titre.musica _root.sons[this.num].loadSound (_root.musica[this.num],true); //true= oui streaming ; attachSound si le son etait dans la bibliotheque } else { if (_root.sons[this.num].position == _root.sons[this.num].duration) { _root.p == 0; } if (_root.sons[this.num]==_root.sons[_root.chanson]){ _root.sons[this.num].start(_root.p/1000); } else{ _root.sons[this.num].start(0); } } eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=false; this.bib_load.play(); this.bib_load._visible=true; vol = _root.sons[_root.chanson].getVolume(); _root.sons[this.num].setVolume(vol); _root.chanson = this.num; chargeimage(); avancement(); } } } } // je ne commente pas la suite du code je vais finir sur ce commentaire car ce sont principalement les // mêmes "erreurs", qui n'en sont pas vraiment c'est juste pour t'aiguiller // Par contre l'utilisation intensive des onEnterFrame n'est vraiment pas obligatoire, // si elle est utile pour la position du slide de progression (même si on peut remplacer par // un setInterval) par contre cela devient inutile pour la passage automatique des musiques. // il faut faire attention car onEnterFrame est un énorme gouffre à ressources. // pour le passage à la musique suivante quand une musique se termine, il y a plus simple, c'est // l'évènement onSoundComplete. // monSon.onSoundComplete = function() { // on lance une nouvelle musique // } // Je n'ai pas regardé précisemment ton code mais déjà je pense que les diverses pistes que je t'ai // données te seront toujours utiles. // n'hésite pas si besoin. // il faut imaginer que ton _root.onEnterFrame se joue TOUT LE TEMPS vue que tu ne l'efface jamais // tu efface bien un enterFrame plus bas avec delete this.onEnterFrame // mais comme là tu mets _root.onEnterFrame, il ne correspondent pas forcément. // regarde bien l'aide sur setInterval (que tu peux effacer avec un clearInterval) je pense que cela pourra // te servir. _root.onEnterFrame = function () { chargeimage(); } _root.player.debut.onPress = function () { if(_root.flag==false){ var flag = true; _root.sons[_root.chanson].loadSound (_root.musica[_root.chanson],true); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=true; this.bib_load.play(); chargeimage(); avancement(); } else{ eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load.play(); if(_root.sons[_root.chanson].position == _root.sons[_root.chanson].duration) { p==0; } _root.sons[_root.chanson].start(_root.p/1000); } } _root.player.enpause.onPress = function () { eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load.stop(); for (j=0;j<sons.length;j++) { sons[j].stop(); } _root.p= _root.sons[_root.chanson].position; } _root.player.suivant.onPress = function () { if(_root.flag==true){ chansonsuivante(); } } _root.player.precedent.onPress = function () { if(_root.chanson>0){ _root.sons[_root.chanson].stop(); vol = _root.sons[_root.chanson].getVolume(); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=false; _root.chanson --; eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=true; _root.sons[_root.chanson].setVolume(vol); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load.play(); if (_root.sons[_root.chanson].duration==undefined) { _root.sons[_root.chanson].loadSound (_root.musica[_root.chanson],true); } chargeimage(); } _root.sons[_root.chanson].start(0); } _root.progression.onPress = function () { var temps = (_root._xmouse-this._x)/this._width; _root.sons[_root.chanson].stop; _root.sons[_root.chanson].start((_root.sons[_root.chanson].duration)*temps/1000); } chansonsuivante = function(){ if(_root.chanson<(i-1)){ _root.sons[_root.chanson].stop(); vol = _root.sons[_root.chanson].getVolume(); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=false; _root.chanson ++; eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=true; _root.sons[_root.chanson].setVolume(vol); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load.play(); if (_root.sons[_root.chanson].duration==undefined) { _root.sons[_root.chanson].loadSound (_root.musica[_root.chanson],true); } chargeimage(); } else{ _root.sons[_root.chanson].stop(); vol = _root.sons[_root.chanson].getVolume(); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=false; _root.chanson = 0; eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load._visible=true; _root.sons[_root.chanson].setVolume(vol); eval("_root.conteneurtitre.titremusica"+[_root.chanson]).bib_load.play(); if (_root.sons[_root.chanson].duration==undefined) { _root.sons[_root.chanson].loadSound (_root.musica[_root.chanson],true); } chargeimage(); } _root.sons[_root.chanson].start(0); } chargeimage = function(){ if (_root.logo[_root.chanson]!= null) { _root.imageson.loadMovie(_root.logo[_root.chanson]); var totalsuiv:Number; var chargesuiv:Number; var pourcensuiv:Number; this.onEnterFrame = function():Void { totalsuiv = _root.imageson.getBytesTotal(); chargesuiv = _root.imageson.getBytesLoaded(); pourcensuiv = Math.round(chargesuiv/totalsuiv*100); if (isNaN(pourcensuiv) || pourcensuiv == undefined) { pourcensuiv = 0; } else if (pourcensuiv == 100) { _root.imageson._width = 95; _root.imageson._height = 95; delete this.onEnterFrame; } } } else { _root.imageson.unloadMovie(); } } avancement = function(){ _root.progression.progressionbar.onEnterFrame = function(){ this._width = (_root.sons[_root.chanson].position/_root.sons[_root.chanson].duration)*215; if (this._width == 215){ chansonsuivante(); } } }