Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-03-2007, 03:42 AM   #1
VictoriaWelby
Registered User
 
Join Date: Apr 2007
Posts: 6
Default Running many intervals at the same time

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
If anybody would have an idea of the problem... or a solution, I'd be most grateful! :^)

Thanks!
VictoriaWelby is offline   Reply With Quote
Old 07-03-2007, 04:33 AM   #2
fauzira
Saliences
 
fauzira's Avatar
 
Join Date: Feb 2007
Location: Singapore, Indonesia
Posts: 339
Send a message via MSN to fauzira Send a message via Yahoo to fauzira Send a message via Skype™ to fauzira
Default

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
fauzira is offline   Reply With Quote
Old 07-03-2007, 04:52 AM   #3
inhan
it's all about patience
 
inhan's Avatar
 
Join Date: Jun 2005
Location: istanbul
Posts: 5,859
Default

Did you try not using updateAfterEvent function?

Quote:
Originally Posted by Documentation
(...) Executing long, memory-intensive scripts during an interval causes delays.
__________________
Ali Inhan
Turkish graphic and web designer
an Apple fan
www.aliinhan.com
inhan is offline   Reply With Quote
Old 07-03-2007, 12:39 PM   #4
VictoriaWelby
Registered User
 
Join Date: Apr 2007
Posts: 6
Default

Quote:
Originally Posted by inhan View Post
Did you try not using updateAfterEvent function?
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!
VictoriaWelby is offline   Reply With Quote
Old 07-03-2007, 12:45 PM   #5
VictoriaWelby
Registered User
 
Join Date: Apr 2007
Posts: 6
Default

Quote:
Originally Posted by fauzira View Post
I want to help but dont understand your comment languange on AS
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
to which are associated three other mc, which I want to move to the left when the first mc is clicked:
HTML Code:
_root["mouvement" + texteChoisi] = setInterval(deplacement, 7, texteChoisi);
"deplacement" is the function associated with the intervals, it moves the movieclips, and gets them back to their initial position once they've disappeared from the screen.

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...
VictoriaWelby is offline   Reply With Quote
Old 07-04-2007, 12:13 AM   #6
VictoriaWelby
Registered User
 
Join Date: Apr 2007
Posts: 6
Default

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.
VictoriaWelby is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 09:22 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.