VictoriaWelby
07-03-2007, 03:42 AM
Hello,
I've been wanting to run several intervals at the same time. I've managed to do it, but when more than one is running at the same time, all the intervals' paces decrease. Here is the code:
//pour lancer le défilement des textes lors du clic
degre2_mc.onRelease = function ():Void {
//pour s'assuer qu'il y a des éléments dans le tableau (sinon, le tableau reconstruit dans deplacement contient des vides)
if (tableau2.length > 0) {
//choisir un élément du tableau au hasard
texteHasard = Math.floor(Math.random() * tableau2.length);
//trace("nombre du texte au hasard : " + texteHasard);
//définir la variable avec l'élément du tableau
texteChoisi = _root["tableau2"][texteHasard];
trace("nom du texte choisi : " + texteChoisi);
//enlever l'élément du tableau
tableau2.splice(texteHasard, 1);
trace("tableau après le retrait du mc : " + tableau2);
//lancer l'intervalle pour déplacer le texte
_root["mouvement" + texteChoisi] = setInterval(deplacement, 7, texteChoisi);
trace("nom de l'intervalle : " + _root["mouvement" + texteChoisi]);
}// fin if (tableau1.length > 0)
};// fin degre1_mc.onRelease = function ():Void
//pour le déplacement des textes
deplacement = function (texteChoisi:MovieClip):Void {
//déplacement du mc
_root[texteChoisi]._x -= 1;
//rafraîchissement de l'écran
updateAfterEvent ();
//quand le mc a disparu à gauche de l'écran...
if (_root[texteChoisi]._x <= -10 - _root[texteChoisi]._width) {
_root[texteChoisi]._x = 600;
tableau2.push(texteChoisi);
trace("tableau avec élément ajouté : " + tableau1);
clearInterval (_root["mouvement" + texteChoisi]);
}//fin if (texteChoisi._x = 0 - texteChoisi._width)
};// fin deplacement = function ():Void
If anybody would have an idea of the problem... or a solution, I'd be most grateful! :^)
Thanks!
I've been wanting to run several intervals at the same time. I've managed to do it, but when more than one is running at the same time, all the intervals' paces decrease. Here is the code:
//pour lancer le défilement des textes lors du clic
degre2_mc.onRelease = function ():Void {
//pour s'assuer qu'il y a des éléments dans le tableau (sinon, le tableau reconstruit dans deplacement contient des vides)
if (tableau2.length > 0) {
//choisir un élément du tableau au hasard
texteHasard = Math.floor(Math.random() * tableau2.length);
//trace("nombre du texte au hasard : " + texteHasard);
//définir la variable avec l'élément du tableau
texteChoisi = _root["tableau2"][texteHasard];
trace("nom du texte choisi : " + texteChoisi);
//enlever l'élément du tableau
tableau2.splice(texteHasard, 1);
trace("tableau après le retrait du mc : " + tableau2);
//lancer l'intervalle pour déplacer le texte
_root["mouvement" + texteChoisi] = setInterval(deplacement, 7, texteChoisi);
trace("nom de l'intervalle : " + _root["mouvement" + texteChoisi]);
}// fin if (tableau1.length > 0)
};// fin degre1_mc.onRelease = function ():Void
//pour le déplacement des textes
deplacement = function (texteChoisi:MovieClip):Void {
//déplacement du mc
_root[texteChoisi]._x -= 1;
//rafraîchissement de l'écran
updateAfterEvent ();
//quand le mc a disparu à gauche de l'écran...
if (_root[texteChoisi]._x <= -10 - _root[texteChoisi]._width) {
_root[texteChoisi]._x = 600;
tableau2.push(texteChoisi);
trace("tableau avec élément ajouté : " + tableau1);
clearInterval (_root["mouvement" + texteChoisi]);
}//fin if (texteChoisi._x = 0 - texteChoisi._width)
};// fin deplacement = function ():Void
If anybody would have an idea of the problem... or a solution, I'd be most grateful! :^)
Thanks!