This content has been marked as final. Show 7 replies
where is n initialized?? (hint: fix that.)
And is that supposed to be break; ?
Many thanks. Stupid of me really. Now defined and running perfectly. Having said that it has never posed a problem with Flash 6...?
That is because Flash 6 works differently. If you don't declare a variable and then try to increment it it assumes it was zero and is now one. In Flash 8, it assumes it is undeclared and when you add one to nothingness it is still nothingness – not zero, just not anything.
I have been slowly working with various AS in Flash 8. I decided to work with the duplicateMovieClip stuff last night to create a simple "rainlike" effect. I'm not creating the effect for use, only to practice and continue learning with AS. I have had little success thus far.
So as usual, I find myself here. I seached and discovered this thread and the above script seems to be very simple and I certainly understand what it conveys. I still can't get it to work however. How should the code read to initialize n?
You probably should have started a new thread with your specific questions, but since you are here…
Under Flash 6 you could do something like this:
And you would get a trace of 5. Flash just assumed that n was a variable with a value of zero. But in Flash 7 (and after) this behaviour changed. If you try this you will get a trace of "NaN" meaning Not a number.
That is because since you haven't given n a value it makes no sense to add 5 to something that doesn't have a value. (Not having a value and having a value of zero are not the same thing!)
So someplace you need to have:
Or whatever value you want n to start at. Flash will no longer just assume you wanted it to start at zero.
But if you are doing the above code in some kind of loop, you don't want to have the initilization inside the loop. Otherwise, n will just keep resetting to zero and you won't ever get anywhere.
Hmm. Thanks Roth.
I actually did initialize n in the correct manner. I'm not getting the output I want because I thought the above code would simplify the process and do the work for me. Shame on me.
I will continue to work with the rain effect. As of now the MC duplicates only once. The duplication does not tween as the original MC does and remains stationary on stage. I need to work with script until multiple MC are created and they duplicate the tweening effect of the original "raindrop" (MC).