7 Replies Latest reply on Apr 9, 2007 1:14 PM by MoonPilot

    DuplicateMovieClip fails under Flash 8

    GP_London
      Has anyone else found problems with Flash 8 Player on duplicateMovieClip. I have used the attached script to make multiple versons of a falling rain drop in the past. This script is still functioning fully when published as Flash 6, from Flash 8 Pro.

      In order to take advantage of alpha channel masks which are now available with Flash 8, I would have thought simply reusing this trusty script would have worked as it does under Flash 6. But instead the animation fails to duplicate.

      Any suggestions greatly received.
        • 1. Re: DuplicateMovieClip fails under Flash 8
          kglad Adobe Community Professional & MVP
          where is n initialized?? (hint: fix that.)
          • 2. Re: DuplicateMovieClip fails under Flash 8
            Rothrock Level 5
            And is that supposed to be break; ?
            • 3. Re: DuplicateMovieClip fails under Flash 8
              GP_London Level 1
              Many thanks. Stupid of me really. Now defined and running perfectly. Having said that it has never posed a problem with Flash 6...?
              • 4. Re: DuplicateMovieClip fails under Flash 8
                Rothrock Level 5
                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.
                • 5. Re: DuplicateMovieClip fails under Flash 8
                  MoonPilot
                  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?
                  • 6. Re: DuplicateMovieClip fails under Flash 8
                    Rothrock Level 5
                    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:

                    myNumber=5+n;
                    trace(myNumber);

                    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:

                    var n:Number=0;

                    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.
                    • 7. Re: DuplicateMovieClip fails under Flash 8
                      MoonPilot Level 1
                      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).