17 Replies Latest reply on Oct 5, 2008 10:33 AM by kglad

    duplicateMovieClip problem

    NeronBurningRome Level 1
      Hi,

      I've found an animation somewhere in the web. This is an animation a flame, which burns constantly. The animation is made with the following AS:

      i++;
      duplicateMovieClip ("flame", "flame"+i, i);
      flame = eval("flame"+i)
      flame._x = 206+random(2);
      flame._y = 55+random(8);
      if (i==20){
      i=0;
      }

      Of course there is an object (a movie clip with a motion tween inside) named 'flame' and there is also second frame with the following AS: 'gotoAndPlay(_currentframe-1);'

      Now, I've made my own animation based on the one I've just depicted. I've changed the object and it's name and in AS I've replaced all the 'flame' with my object's name .

      The problem is that the original animation creates constant flame - the object duplicates itself one after another creating impression of a burning flame, but in my animation object duplicates itself only after it finishes playing this 'inside' motion tween. It looks like this: the object starts motion tween, it stops the tween, then it duplicates and plays the tween again.
      This doesn't look like a burning flame at all :) I've been looking for the differences between my animation and the one depicted above, but I can't find any. What else besides object's name should I change? Are there any 'hidden' settings I didn't found?
      This animation is said to be made in Flash mx, and I'm using Flash 8 Proffesional.

      I'm not sure If I've made myself cleare about this problem, but if anyone can help I'd appreciate it.
        • 1. Re: duplicateMovieClip problem
          kglad Adobe Community Professional & MVP
          you shouldn't re-execute that code until your tween has completed.

          • 2. Re: duplicateMovieClip problem
            NeronBurningRome Level 1
            How should I do that?
            • 3. Re: duplicateMovieClip problem
              kglad Adobe Community Professional & MVP
              if your tween is 11 frames in duration, the timeline that contains your code should contain 11 frames.
              • 4. duplicateMovieClip problem
                NeronBurningRome Level 1
                Thanx for help kglad. I did as you said and the result is that when timeline of the 'scene' finds AS "gotoAndPlay (1);" on the last frame it goes back to frame 1,but the duplicated MC disappears as the timeline starts playing again. This animation I found works in a different way: when timeline goes back to frame 1 duplicated MCs stay on the stage all the time and play their tweens (untill number of duplicated MCs reaches 'i==20' I presume). From your suggestions it looks like it isn't possible.

                So I'm looking for a way to duplicate a MC (with tween inside) and leave the duplicated and tweening MC on the stage as the timeline of the stage replays itself and creates another duplicates of the MC.
                • 5. Re: duplicateMovieClip problem
                  kglad Adobe Community Professional & MVP
                  your duplicated movieclips are replaced every 20 times your code executes. that's the way it's setup. if you want something different, you'll need to change the code.

                  i'm not sure what you want, so i don't know how you should change your code.
                  • 6. Re: duplicateMovieClip problem
                    NeronBurningRome Level 1
                    I want the duplicated movie clips to stay on the stage when AS code reexecutes. So after 2 repetitions there are 2 duplicated movie clips. And after 3 repetitions there are 3 duplicated movie clips. And so on.

                    Now it's like duplicated movie clip disapears when AS code reexecutes. So after 2 repetitions I have 1 duplicated movie clip.
                    • 7. Re: duplicateMovieClip problem
                      kglad Adobe Community Professional & MVP
                      then you changed something, because that code wouldn't cause movieclips to be replaced until twenty were onstage (assuming i starts at zero).
                      • 8. duplicateMovieClip problem
                        NeronBurningRome Level 1
                        I found the solution. The AS code was the same, but the problem was somewhere else. In publish settings there was set 'Flash player 8' version and it didn't work (what I was trying to explain:) I changed to 'Flash player 6' version and it works just as it supposed to.

                        I don't know why, but in Flash Player versions 7 and 8 the AS code was replacing duplicated movie clips (they were disappearing when code was reexectuing itself). In version 6 and lower the duplicated movie clips stay on the stage when code reexecute itself - this is how it should work from the first place.

                        So I suppose that when I publish this animation on a website with version of Flash Player set to '6' people who have Flash Player 7 or 8 wont be able to view this animation. Am I right? Is there a way to make it work like it's supposed to and view this in Flash Player 7 or 8?

                        • 9. Re: duplicateMovieClip problem
                          kglad Adobe Community Professional & MVP
                          it works in flash player 6 because you weren't initializing i to be zero.

                          people with more up-to-date player will be able to view swfs published for fp 6.

                          or you could initialize i to be zero and then you could publish for fp 7 or fp 8.
                          • 10. Re: duplicateMovieClip problem
                            NeronBurningRome Level 1
                            Thanx for explanation.

                            But why I can't see the proper animation in Flash 8 Professional when (in Publish Settings) I set Flash Player version to '8' and I hit Ctrl+Enter? By hitting Ctrl+Enter doesn't it starts Flash Player in the newest version?

                            • 11. Re: duplicateMovieClip problem
                              kglad Adobe Community Professional & MVP
                              the test environment (default ctrl-enter) emulates the flash player assigned in your publish settings.

                              your code won't work as you intend in anything beyond fp 6 unless you initialize i.
                              • 12. duplicateMovieClip problem
                                NeronBurningRome Level 1
                                You wrote :
                                quote:

                                Originally posted by: kglad
                                people with more up-to-date player will be able to view swfs published for fp 6.


                                and then:

                                quote:

                                Originally posted by: kglad
                                the test environment (default ctrl-enter) emulates the flash player assigned in your publish settings.


                                My AS code doesn't work when I set Publish settings to Flash Player 8 version, but it works on 6 and lower. So Flash Player used in web browsers is compatible with older versions of Flash Player but the test environment (Ctrl+Enter) is NOT compatible with older versions. Is that right?

                                Then you wrote:
                                quote:

                                Originally posted by: kglad
                                your code won't work as you intend in anything beyond fp 6 unless you initialize


                                So people with Flash Player 8 won't be able to view this animation? I'm confused:)
                                • 13. Re: duplicateMovieClip problem
                                  kglad Adobe Community Professional & MVP
                                  there's nothing inconsistant with my statements. they are all correct and consistant.

                                  fp8 players can view fp6 swfs. however, if you have a coding problem (and you do), fp6 users may see your animation as you intend it to be seen and fp8 users will not.

                                  so, why don't you fix your code? for the third time, initialize i to be zero.
                                  • 14. Re: duplicateMovieClip problem
                                    NeronBurningRome Level 1
                                    Don't get upset, I was just trying to understand the mechanism of Flash:)

                                    And of course I'll change the code - I want all the users to view my animation, not only those with fp 6 and lower.

                                    So I was trying to add: ' i=0 ' at the beginning of my AS code, but it didn't work. Anything else should I do? Now the code looks like this:

                                    i=0;
                                    i++;
                                    duplicateMovieClip ("flame", "flame"+i, i);
                                    ...
                                    if (i==20){
                                    i=0;
                                    }
                                    • 15. Re: duplicateMovieClip problem
                                      kglad Adobe Community Professional & MVP
                                      every time you enter the frame that contains that code, you're (re)initializing i = 0. and that's not what you want. you want to intialize i to be zero, once:

                                      • 16. Re: duplicateMovieClip problem
                                        NeronBurningRome Level 1
                                        Thanks for your help, and your patience:)
                                        • 17. Re: duplicateMovieClip problem
                                          kglad Adobe Community Professional & MVP
                                          you're welcome.