I take that back...never use it...you can always use onEnterFrame on the
root. 

-----Original Message-----
From: Kalani Bright [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 28, 2007 6:15 PM
To: '[email protected]'
Subject: RE: [Flashcoders] Getting frustrated. regarding set Interval,and
for loop.

When I was using AS2 I found that no matter what there were always memory
leaks with set interval and even after I explicitly tell Flash to remove the
interval it never got removed...

So even though I never wrote it I would offer the following advice, which is
to *almost* not use setInterval at all.  Just use it once, for the root...
1) Move all functionality for intervals to a script on the root
2) The root is always available, and you won't have intervals all over the
place
3) Create only one interval for a function on the root which is responsible
for calling functions
4) The function should get the same sort of information as whats required by
setInterval.
5) Call functions based on the timer.  Time since movie started.  A little
math should test if the objects which are registered with your script should
be called again.  I would also recommend enabling this function to support
something like  "call this function X times every 1000 ms).  Rather than
call this object every 1000ms.  That way you can delete it automatically if
its reached that number.
6) That script keeps information on what intervals are set
7) The script periodically checks for objects which no longer exists and
deletes them from the interval array.
8) Intervals are set or removed by calling a root function.  Use the
delegate class to say which function gets the interval callback and also
pass a reference to the object.

Good luck,

Kalani
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Omar Fouad
Sent: Wednesday, February 28, 2007 5:18 PM
To: Paul V.; [email protected]
Subject: Re: [Flashcoders] Getting frustrated. regarding set Interval,and
for loop.

assign the setInterval to a variable than clear the interval this way :

var myInterval = setInterval(blah blah blah); clearInterval(myInterval);
read about clearInterval on the docs... U'll realize it more

On 3/1/07, Paul V. <[EMAIL PROTECTED]> wrote:
>
> Let me explain the problem I am having and then I will send you some 
> code.  I want to load up images in a slide show with set interval, 
> with the images being called image1 image2 image 3 etc.  I want to be 
> coding a dynamic slide show so that if I change the images I can just 
> replace the mc images.
>
> here is the code I am working on, I am a little new to setInterval 
> (completely new to that function actually) - I do understand the basic 
> syntax, setInterval( function (){ //entire function here;},1000);
>
> But I don't know how to run a for loop inside it and pass a variable 
> to it. (I am a newbie).
>
> function loadImages(){        //Ihave this here so I can run an external
> for loop.
>     for(i=1;i<6;i++){
>      setInterval(function(){     //set interval and begins anonymous
> function  i.e function() -no name
>      attachMovie("image"+i,"image"+i,41);   //trying to attach the images,
> image1 - image5
>      image = eval("image"+i);                    //instance assigned to
> variable  'image'
>      image._x = ((Stage.width / 2)-(image._width/2));   //positioning
>      image._y =
> (yFactor);                                        //positioning
>      oldwidth = image._width;                                   //saving
> dimensions for resizing formula
>      oldheight = image._height;                                //saving
> dimensions for resizing formula
>
>      image._height = yheight;                                 //image
> height set to variable
>      image._width = ((oldwidth*yheight)/oldheight);   //image width set to
> proportions of original
>    },1000);
> //interval to 1 sec. 1000 milliseconds
> }
//end
> for loop
> }                                                           //end
> container function
>
> I am trying to set the images up for a second and then have them switch.
> Help me out if you you know a solution.  Or even if you see some 
> obvious errors. Like I said I am new with the set interval.  by the 
> way if you like that little resizing technique, you can use it. Thank you.
>
> Looking forward to a response on this one.
>
> Paul Vdst
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training 
> http://www.figleaf.com http://training.figleaf.com
>



--
Omar Fouad - Digital Emotions...

Love is always patient and kind. It is never jealous. Love is never boastful
nor conceited It is never rude or selfish. It does not take offense and is
not resentful. Love takes no pleasure in other people's sins...but delights
in the truth. It is always ready to excuse, to trust, to hope... and to
endure... whatever comes.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to