This content has been marked as final. Show 9 replies
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.
Just curious. What happens when you trace bombNum?
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.
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)
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.
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:
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.
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.
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.