All dragable except one; why?

i have a mc that is dragable; i also have a button that sends the playhead to frame 2 where it randomly duplicates the mc; when the duplication is performed, all the “clones” are dragable except one; why?
the mc code is:

onClipEvent (load) {
this._x = random(300);
this._y = random(300);
}
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.startDrag(false);
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.stopDrag(false);
}
}

the frame code is:

amount = random(10);
trace(amount);
while(amount>0) {
duplicateMovieClip (ca, “ca”+i, i);//ca is the instance name of the mc
i = i + 1;
amount = amount-1;
}

that one is probably the original, and the code might not call to drag the original MC. try to put a code on the orginal MC that would make it draggable in frame 2

I checked : it is indeed the first movie clip. What you could do is put it outside the screen, because you don’t really need it.

But it’s strange indeed.

pom 0]

i quote you:
“and the code might not call to drag the original MC. try to put a code on the orginal MC that would make it draggable in frame 2”
Can you say from my post that the original - the instance i named “ca” - isnt dragable?
In case that’s right, how can i improve the code?
thanks for helping

pom: its outside the main stage
i even made this action in frame 1:

stop ();
ca._visible=false;

the more curious thing is this:if i comment the last line of code (ca._visible=false;) , even being out of the stage, the mc appears when i test the movie!.. and not dragable…

Don’t listen to Jubba. Actually, I believe Thoriphes is the master of duplication here. He’s a living duplicate debugger.

When you test your movie, you see an area greater than what you’all actually see in your final animation. to check it, press F12.

pom 0]

i think we’r getting a bit off topic, but i didnt get what you mean: press F12 when testing the movie? - nothing happens…

not when you test it. Just when you are at the main stage, press F12 and it will send you to a Browser page, and that is what will be seen when you publish youre .swf

meant to edit, but whatever, I am trying this, and i’m getting something strange.

the code is telling ca (the original) to go to a random spot, however, it keeps going to the same exact location…weird…

now its changing its position, but still not draggable…i have a few mroe ideas.

it has to do with the duplication. Because if it doesn’t get duplicated, or if you do it randomly it will display only the original somewhere on the field occasionally and in these cases it is draggable.

I cleaned up your code a little bit, but no luck with the dragging yet. This code gives the same effect as yours, its just “cleaner”…

onClipEvent (load){
_x = random(300)
_y = random(300)
}
onClipEvent (mouseDown) {
if (hitTest(_root._xmouse, _root._ymouse, true)) {
startDrag(this);
}
}
onClipEvent (mouseUp) {
stopDrag();
}

like i said, still working on the whole draggin thing…running out of options…

this, instead of what i had, and works perfectly:

amount = Math.ceil(Math.random()*10);
for (i=0;i<amount;i++){
ca.duplicateMovieClip (“ca”+i, i);
}

and so it does…did you search through the posts to find one where Thoriphes answered about mouse trails, or something…cuz I remember seeing that code in one of Thor’s posts…or did you come up with that on your own? either way, good job…congrats…

This doesn’t explain why it wasn’t working. Hmmm…

pom 0]

i had a post elsewhere and someone came with that; all that remains is that i really dont understand the diferences between mine (taken from kirupa tuts) and this one…
looks like this one covers all mcs;
what means :

ca.duplicateMovieClip (“ca”+i, i);

?
i read in ActionScript the D G that this is a method, but cant get how it works instead of the other way; anyway the truth is …it works!

It’s exactly the same. It’s just an old object-oriented programmation-like function. I really don’t understand.

pom 0]

then the only option of understanding lies in the way of generating the “ii”; what i suggest is that “my” code perhaps starts in 1 - leaving one mc not dragable - (the original) - while this last code starts at i=0, what would mean including the original, thus making it also dragable.
Does this make sense?

thats possible, and probably the reason. But the code on the MC is “startDrag(this);” and that shouldn’t be influenced by the duplication. It most likely is, however it shouldn’t be.

It’s just an old object-oriented programmation-like function
What the hell did I mean with that ?
Sometimes I surprise myself…

pom 0]

lol sometimes i wonder Pom…

The answer is… it doesn’t work.

You are technicaly only allowed to perform ONE drag function at a time. The fact that yours was working on all BUT one is just part of the glitchiness of trying to attempt what you attempted.

If you want to drag more than one, you’re better off using an
onClipEvent(enterFrame){
//move this towards the mouse or set this equal to the mouse
}

In that instance you can use it on more than one clip at a time.
Pretty much every book I’ve read has mentioned that you can’t do more than one drag movie clip.