| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Apr 2007
Posts: 6
|
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: HTML 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
Thanks! |
|
|
|
|
|
#2 |
|
Saliences
|
I want to help but dont understand your comment languange on AS
![]()
__________________
Seek knowledge from the cradle to the grave fauzi at skywhisper.co.cc |
|
|
|
|
|
|
|
|
#3 | |
|
it's all about patience
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
|
Did you try not using updateAfterEvent function?
Quote:
|
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Apr 2007
Posts: 6
|
I just did, and it doesn't solve the problem. :-(
And I'm wondering about the quote from Documentation. What I gave is almost the entirety of my code (there are 5 more lines to begin with, to create arrays). Would that be considered a "long, memory-intensive script"? Thank you for your suggestion! |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Apr 2007
Posts: 6
|
Sorry, English is a second language for me. I am much more at ease in French, and therefore comment my code in French. But here is the scenario for the intervals. I've got a mc:
HTML Code:
degre2_mc HTML Code:
_root["mouvement" + texteChoisi] = setInterval(deplacement, 7, texteChoisi); Across all this, there is an array to identify the movieclips of texts. Whenever one movieclip is moving, it is removed from the array, and is therefore not available anymore. It is put back once it has gone through the screen. Hoping that makes it clearer... |
|
|
|
|
|
#6 |
|
Registered User
Join Date: Apr 2007
Posts: 6
|
A friend of mine has suggested a solution that works quite well. It consists in running only one interval that loops through an array containing all the movieclips that need to be moved.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why everyone hates (or should hate!) mircosoft | stealthelephant | General Chat | 102 | 11-28-2008 10:02 PM |
| clearing errant intervals | as_apprentice | ActionScript 2.0 | 5 | 09-05-2006 06:01 PM |
| Function problem: 1st time ok second time not work | Astralp | ActionScript 2.0 | 2 | 09-04-2004 04:07 PM |
| Two intervals running at once | Morg | ActionScript 2.0 | 1 | 08-28-2004 07:10 PM |
| running a for loop a certain amount of time before executing another function | fullf0rce | ActionScript 1.0 (and below) | 1 | 04-25-2001 03:15 AM |