Groups | Blog | Home
all groups > flash actionscript > october 2004 >

flash actionscript : SetInterval limitations?


Rothrock
10/20/2004 7:57:01 PM
My guess is that your are getting "collisions." Without seeing your code it is
hard to be sure exactly what is going on.

Here is one idea. Depending upon what your function is, it does take a set
amount of time to perform. For example I did a function that went through about
400 movie clips and set their scale based on how far they were from the mouse
position. It took about 45 milliseconds for this to do it's thing. Therefore
any call to that before it was finished would cause weird chunky scaling. But a
call of say every 60 milliseconds was smooth. Remember: sometimes less is more.

Also if you have been sloppy with variable scoping it is possible that the
multiple calls are having some problems because of "interference."

If these ideas aren't it, post some code to help us figure it out.



Macromedia
10/20/2004 8:18:44 PM
Hello NG

I am using some multiple instances of setInterval and at certain timings
having eratic results.

My question.

Is it possible for two calls to the same function be made at the same
moment - like a collision almost - and therefore some outcome inconsistent
with your script.

My scripts work fine at some tempos but not at others :( - others being the
very short delays

Expert advice greatly appreciated

Dave

Macromedia
10/20/2004 9:20:46 PM
Hi Rothrock

Thanks for your input.

Based on what u say I think that at the higher speeds the calls may be
'colliding'.

It would be nice to see some documentation on MM site about this.

If I say:

call1 = setInterval("fadeStructure",30,v)
call2 = setInterval("fadeStructure",30,z)

If both call1 and call2 happened to be executed simultaneously would call2
simply not take an instance of that function and thereby treating each one
independently?

[Please note that function fadeStructure would also have some setInterval
calls in it]

David

David Stiller
10/21/2004 10:43:15 AM
This is off topic, but I would encourage the original poster to change
his/her forum name. It's showing up as "Macromedia," which could be
misleading. For example, I read this thread because I thought there was a
general message from Macromedia itself.


David
stiller ( at ) quip ( dot ) net

Rothrock
10/21/2004 12:28:22 PM
I don't think the problem is with having call1 and call2 happening at the same
time. Even though code executes fast, the compiler knows how to keep two
instructions (what ever they are) from happening exactly at the same time.

The example I gave is just one way it could go wrong-- where the function
hasn't finished before you call it again. This really help cement in my mind
that more isn't always necessary to get a better reult. But it seems this isn't
your problem.

My guess from what you have shown here is that you aren't clearing your
intervals. So everything is getting called too many times. Let's see the
complete code -- the original calls, the function, and any functions called by
the function.
AddThis Social Bookmark Button