I am trying to do the following:
create box0, animate it falling to the bottom of the screen,
then create box1, then animate it falling to the top of box1, etc.
until box4 included. I have attached my code. The flash file has
only 1 movie clip in the first frame (only frame), called blankclip
with instance name "blankclip". This movieclip is empty. the
document is 550px wide by 800px high.
The problem in the attached code is that flash goes inside
the onEnterFrame function only for i=4 (the last cycle of the
loop), so I only get 1 box (the last one) falling.
Does anybody know why by chance and how I could solve the
problem? Is there a better technic for that?
It’s that for-loop that is causing your code not to
work as expected. I believe that all AS code is executed before any
timeline activities are completed. So it will complete that
for-loop before executing the onEnterFrame handler. You can easily
figure out that the variable ‘i’ was not incrementing
as you wanted it to if you would have traced ‘i’ in the
createdBox( ). So you need to increment ‘i’ in the
onEnterFrame. The code below will hopefully show you how it can be