9 Replies Latest reply on Feb 6, 2008 9:45 PM by kglad

    Instances of MCs dissapearing

    Blindgator
      Here is the script.
        • 1. Re: Instances of MCs dissapearing
          kglad Adobe Community Professional & MVP
          the only thing with its _y property changing is the movieclip to which that code is attached. and you're probably having a depth collision that's causing your movieclips to disappear.
          • 2. Re: Instances of MCs dissapearing
            rlc5611 Level 1
            Just curious. What happens when you trace bombNum?
            • 3. Re: Instances of MCs dissapearing
              Blindgator Level 1
              When I trace bombNum I get a weird sequence like 1,2,3,4,1,2,5,1,2,6,1,2.
              So how would I go about fixing the depth collision problem? I am kindve confused because when I trace bombNum it doesnt even get close to 900 before resetting.
              • 4. Re: Instances of MCs dissapearing
                rlc5611 Level 1
                Based on the script you showed, you shouldn't even get that. So you must be declaring and manipulating that variable some place else in your script in addition to your enterFrame function. Where else are you using this variable?

                And in the script you posted, when you say, for example, this._y += 10; what do you believe 'this' is referring to? (as kglad suggested)
                • 5. Re: Instances of MCs dissapearing
                  kglad Adobe Community Professional & MVP
                  yep, bombNum has to be initialized somewhere (unless this is flash 6 or earlier) and it's being changed elsewhere, timer is doing nothing useful and you're definitely getting depth collisions with that sequence of bombNum.
                  • 6. Re: Instances of MCs dissapearing
                    rlc5611 Level 1
                    Oh I see said the blind man... So you must have these onClipEvent functions assigned to your movieclip named 'bomba'. When you duplicate the clip, you duplicate these functions as well. So all the new clips are stepping all over each other by running the same functions at the same time until each clip is removed.

                    BTW, what version of Flash are you using?

                    Rather than do this duplication work in a clip event (at least of a clip that you are duplicating), why don't you place the script in the timeline where the clip resides. Then script each bomb so it takes care of itself. For example:
                    • 7. Re: Instances of MCs dissapearing
                      Blindgator Level 1
                      Sorry I am new to flash and am just learning. I have been busy and its taken me a while to digest this with my previous knowledge of Flash and I just now think I am catching on a little. I am using Flash MX which I believe is Flash 6 so maybe thats where some confusion comes in with the timer var and bombNum.


                      Before I got your response I finally took all the script from what you put in the bomb script and also the timer, then I attatched it to the main character which there is only one instance of and it worked fine. Then I took all that script again and used the function that you put together. It worked fine also. Are both ways acceptable or is there a certain benefit to one over the other? Just so I get this straight in my head, the original way I tried was bad because it caused there to be a gazillion instances all repeatedly running a script to just do one thing and all I really needed was one script to do do all that work?


                      So for the (this.removeMovieClip) code when the bomb goes offscreen would it be better for that to be attatched to each and every instance of the bomb? If I understand this right, it would be better because unlike the create bomb function, if I had to check every bomb out there (lets say numbers 1 through 100) to see that if it went off the screen on every enterframe, that would require a lot more processing power. Correct?


                      Thanks for being helpful with all my probably stupid questions. I am just learning and I really apreciate all the time you have put in to help me.
                      • 8. Re: Instances of MCs dissapearing
                        Blindgator Level 1
                        Sorry just one more question. When you say depth collision problems, do you mean that the bombs and the bullets are on the same depth? Because when I changed the bombNum repeating from 0-100 and the bulletNum from 101-200 it seemed to get rid of the disappearing bombs.
                        Thanks again,
                        Brian
                        • 9. Re: Instances of MCs dissapearing
                          kglad Adobe Community Professional & MVP
                          there can only be, at most, one movieclip at any given depth. a depth collision occurs when you assign a 2nd movieclip to a depth that already contains a movieclip. when that happens the most recently assigned movieclip occupies that depth and the other movieclip is removed from existence.