Desperate for help - can't let this defeat me

I’ve been trying to figure this out for a very long time now and as you can see I still haven’t…

first… here’s a link to the first part

pretty simple… rocks flying through space… if they touch your ship you’re dead… onPress fires a shot… if your shot hits one of the rocks something happens.

now the problem is…

It’s easy to detect when a “ROCK” hits the “SHIP” because the ship is one object and can be done with collision detection using hitTest method inside the “ROCK” movie clip…

but as I mentioned I want to see if my shots hit one of the rocks… and here’s the big BUT…
all my rocks are randomly generated like this:
duplicateMovieClip(, “star”+i, i);

where “star” and “star2” are just ugly circles converted to MovieClips and named that.

this is where the problem occurs… if I was to check for collision detection between a “BULLET” and “STAR” or “STAR2” I would only be able to do it for the initial movie clip and not the duplicated ones because their name changes as they are duplicated and become star200…star201…star202 etc…

I have tried a LOT of things but I don’t seem to be able to figure out a programmatic way of working around this…

I would really appreciate your help even if it’s just a thought… maybe it’s something small that I could do different and make it work

just for reference here is the code… maybe it will help you help me… hehe

Main Timeline Frame 1
startDrag(_root.shooter, true);

SHIP - referred to as “shooter” in the code
on (release) { = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, “bullet”+i, i);

onClipEvent (load) {
this._visible = 0;
if ( == 1) {
this._x = _root.shooter._x;
this._y = _root.shooter._y;

onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if ( == 1) {
this._y -= 10;
this._visible = 1;
if (this._y<0) {

onClipEvent (load) {
this._x = Math.random()*680 + 10;
this._y = 0;
onClipEvent (enterFrame) {
if (!_root.dead){
if (this.hitTest(_root.shooter)) {
xd = _root.shooter._x;
xy = _root.shooter._y;
_root.hit._x = _root._xmouse;
_root.hit._y = _root._ymouse;
_root.hit._visible = true;
_root.shooter._visible = false;
_root.dead = true;

	this._y += 5 - (_root._ymouse/500);
	if (this != {
	if (this._y&gt;520) {



onClipEvent(enterFrame) {
if (j/5 == 5) {
duplicateMovieClip(, “star”+i, i);
duplicateMovieClip(_root.star2, “star2”+i, i+1);
j = 0;

Thank you kindly in advance

thank you… that seems like a great link… hopefully i’ll be able to find what I want on it.

i’m guessing you deleted your post cause I sure don’t see it anymore…heheheh

hmm… here is some pseudo code for you
untested but maybe it will help

if (this._droptarget.indexOf(“rock”)!=-1)

it does use deprecated features of flash though

(_droptarget is a string, so you have to use telltarget to get at the object)

its a challenge to comeup with alternatives to hitTesting every rock, every frame (CPU nightmare).

i changed my mind because it wasnt the link i thought it was
but it is a great page

thanks again… i’ll try your example and read the site

Here’s a thought, have each rock add it’s name to an array, then have each bullet hittest against the array. but i’m not quite sure where to go from there.

that’s something I thought about but as clownstaples said this will still need to be done every frame to detect collision… and considering it’s 40fr/sec and I have to loop through the whole array of current rocks it will still be a CPU nightmare :)…

but I’ll try it later on and let you guys know how it went.

thank you for trying to help