# Duplicate Movie Clip problems

**URL:** https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773
**Category:** Uncategorized
**Created:** [June 8, 2003, 1:39pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773 "2003-06-08T13:39:18Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Fargate](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@Fargate](https://forum.kirupa.com/u/Fargate)
#### Post date: [June 8, 2003, 1:39pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/1 "2003-06-08T13:39:18Z")

</div>

Hi, I have this shooter where this crab mc follows your mouse and whenvever you click it shoots a bullet from the mouse. There’s a blue button in the middle of the movie that allows you to generate targets by the duplicate movie clip function. Now when you fire a bullet though, a target just disappears without the bullet Hittesting at all with any of them! What is wrong??? Also is there a way to just have the targets to constantly duplicate independently without having to click a blue button to respawn them???I really hope someone can fix this. This problem has been plaguing me for over a month!!!Thanks in advance :).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 2:08am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/2 "2003-06-09T02:08:11Z")

</div>

Fargate -  
Hey! I read your post and opened your fla. I have never really gotten a grasp on hitTest nor have I ever tried to make a game. So, I made this game. It’s still has some bugs, but for the most part works. Like the hitTest doesn’t always work??? I’m hoping that some of the game-rupa members can help me out with the bugs - cause I think I’ve changed everything around the best I can.

It should solve your problem though. Maybe…I hope!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 2:21am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/3 "2003-06-09T02:21:37Z")

</div>

Here’s the same thing with some sound. Thought it was neat. Maybe I’ll keep working on this. It’s kinda fun!!

[http://www.freddythunder.com/test/mygame.php](http://www.freddythunder.com/test/mygame.php)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 4:34pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/4 "2003-06-09T16:34:28Z")

</div>

wow thanks a lot that’s great…man now the only problem is the hittest bug…sometimes the targets don’t blow up when you hit them o\_O…very odd…so close…lol…frustrating :p…anyone know what the solution could be???

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 7:46pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/5 "2003-06-09T19:46:19Z")

</div>

You’re telling me. I sent a message to Clownstaples, he seems to know a lot about games. Hopefully he (or someone else hint hint) can figure it out…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 7:46pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/6 "2003-06-09T19:46:59Z")

</div>

lol…Ok thanks a lot Freddythunder.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 8:38pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/7 "2003-06-09T20:38:58Z")

</div>

im actually rather new to flash and games in general, however, this is a great page for all kinds of actionscript stuff  
[http://ericlin2.tripod.com/collision/bb5.html](http://ericlin2.tripod.com/collision/bb5.html)  
basically he says that hittest cant be accurate 100% of the time because the motion is based on frames. If objects collide between frames, flash never catches it

the simplest solution is never let the bullet move faster than the width of the target, so it cant possibly “jump over” it

Freddy - the code in your file looks just fine all around. 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 8:42pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/8 "2003-06-09T20:42:30Z")

</div>

How would you slow it down in the current .fla though…arg…could someone explain the code to me if it isn’t too much trouble. I don’t understand what controls the speed at which the bullets and the targets move at.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 10:56pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/9 "2003-06-09T22:56:06Z")

</div>

Fist off - Thank you Clownstaples for your time and looking over my code. Now that you said that, I do understand that article, but I don’t think that’s the problem with mine becase you can shoot one target 10 times in a row and it won’t blow up, but the next hundred do…However, by ‘bullets’ are streaming quickly. Thanks again!!  
Fargate:  
In your fla, the target is tweened back and forth. To slow that down would mean making the tweens longer. In mine, the targets are falling due to actionScript. One line of code:  
[AS]  
onClipEvent(enterFrame){  
\_x=40+Math.random()\*450;  
\_y+=speed;  
}  
[/AS]  
Think of enterFrame as code that loops indefinately. Each time, the variable speed (which is defined in onClipEvent(load); ) is added to the location of \_y. For the bullets - it’s the same way. In the original movieClips actions, there is a line of code that I believe says:  
[AS]  
\_y-=20;  
[/AS]  
If you make that 20 smaller, the increments will change each time Flash runs through that formula. If I confused you more, I’m sorry. Either way, check this out:  
[http://www.bit-101.com/tutorials/gravity.html](http://www.bit-101.com/tutorials/gravity.html)  
This is the tut that first taught me how to use object orientation programming. I reference it a lot. It should help you…

…Meanwhile, I’ll try to fix my game. ![](http://freddythunder.com/test/laugh.gif)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 11:58pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/10 "2003-06-09T23:58:31Z")

</div>

ok whoa I’ll try to work that out…and thanks for the source site…so if this frame thing isn’t why the hittest randomly doesn’t work sometimes…then what is!!!

EDIT: Ag a new bug…sometimes when you fire a bullet a target just dissapears ( pretty much randomly) before its hittested with anything! What is going on…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 12:23am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/11 "2003-06-10T00:23:52Z")

</div>

i havent seen a disappearing problem in your game on my computer. it sounds weird though

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 12:32am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/12 "2003-06-10T00:32:12Z")

</div>

I dunno…this is going to drive me insane lol…ah well you can’t expect to learn flash in a day ;).

EDIT: I discovered that this disappearing problem on occurs for the first couple seconds of gameplay…then oddly it just fixes itself…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 1:09am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/13 "2003-06-10T01:09:19Z")

</div>

Oh no no no! I’ve had it happen for a couple targets in the beginning, or not at all, or halfway through play. I have no idea why it’s doing that. I figured it would be something wrong with a removeMovieClip() action, but the target doesn’t have any. I agree - it’s very weird…But it’s still fun to play! (I have a record low entertainment value - you will have to excuse me). Well, maybe someone will tell me what I’m doing wrong, cause now it’s bugging me…Grrr…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 1:22am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/14 "2003-06-10T01:22:27Z")

</div>

lol it’s bugging me too…It’s good nonetheless. How would I add a score to that…I’m gonna try and add a health component tommorow…I think I may know how…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 2:17am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/15 "2003-06-10T02:17:50Z")

</div>

i know why it disappears sometimes

duplicateMovieClip(“bulllet”  
is replacing some of the  
dyplicateMovie(“work”  
items  
you have to either

1. put the bullets into a separate movieclip instead of \_root
2. pick a maxnumberof bullets and modify i++ to loop around to zero after the max, then change k to be k+maxNumOfBullets

basically when you create a “work” and you give it a level based on k

if you ever put a bullet into the level with the same number, it replaces the “work” that was there, so you can either separate them into different clips, or move the k level numbers up a 100 or so (k+100), and stop the bullets from ever reaching i=100

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 2:19am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/16 "2003-06-10T02:19:28Z")

</div>

just had a thought.  
you should also add a line that says  
if(\_y \> Stage.height)  
this.removeMovieClip();  
in the target code so they dont just fall forever when you miss them

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 4:39am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/17 "2003-06-10T04:39:12Z")

</div>

You are correct. As soon as I wrote my last post I thought to myself (self) Where do those missed movieClips go. They do stop on an empty frame in the timeline, but I guess it does still exist, right? Either way, I’ll throw that it - might make a difference with the bugs…maybe - Doesn’t make much sense, but niether do the bugs…(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 6:10pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/18 "2003-06-10T18:10:40Z")

</div>

lol I’m confused…😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 6:55pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/19 "2003-06-10T18:55:16Z")

</div>

If you look at the fla…everything there is a movieClip, even when you shoot the red circles (when it works, that is) that movieClip still exists in the computer’s memory. When you remove it, it doesn’t clog any memory up - basically, the computer can forget about it. You use a line of code removeMovieClip to tell the computer to forget about objects - that’s all. All this stuff can be very confusing, but a lot of the things we’re going through are not basic. Stick with it though, you’ll get it, I have faith!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 10, 2003, 6:59pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773/20 "2003-06-10T18:59:31Z")

</div>

ok thanks…so are you saying that this remove movie clip thing will fix the bug or what exactly?

[Next page](https://forum.kirupa.com/t/duplicate-movie-clip-problems/22773.md?page=2)
