PDA

View Full Version : Why does this part of the code create lag?


PopcornPlaya
04-11-2012, 09:44 PM
Why does this part of the code create lag?
for (x=1; x<=dist; x++)

The Error:A script in this movie is causing Flash Player to run slowly.
It had worked but now it loads improperly.

This is the link for the rest of the "OK" code:

http//stackoverflow.com/questions/7619257/as3-line-of-sight-without-using-hittest-object

PopcornPlaya
04-11-2012, 09:46 PM
Why does this part of the code create lag?
for (x=1; x<=dist; x++)

The Error:A script in this movie is causing Flash Player to run slowly.
It had worked but now it loads improperly.

This is the link for the rest of the "OK" code:

http//stackoverflow.com/questions/7619257/as3-line-of-sight-without-using-hittest-object

Maybe it has to be AS3...

dialectric
04-16-2012, 01:20 AM
Hi,

The code as written should be fine in as2 or as3, as long as dist is defined, set to an integer, and dist is not changing as you are looping. It could be what you are doing inside the loop that is causing the lag. You would get the same error. Post more of your code for more specific responses.

One additional thought is that i, j, and k are frequently used for for loops instead of x,y, and z because the later are often used for object locations, would thus be confusing in uses where position isn't involved, and in as3 at least, x and y are reserved keywords. You could try using i instead of x.

- dialectric