# All dragable except one; why?

**URL:** <https://forum.kirupa.com/t/all-dragable-except-one-why/2449>\
**Category:** Uncategorized\
**Created:** [March 30, 2002, 11:55pm UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449 "2002-03-30T23:55:12Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [March 30, 2002, 11:55pm UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/1 "2002-03-30T23:55:12Z")

</div>

## 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; }

---

<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:** [March 31, 2002, 12:04am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/2 "2002-03-31T00:04:27Z")

</div>

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

---

<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:** [March 31, 2002, 12:13am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/3 "2002-03-31T00:13:47Z")

</div>

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]

---

<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:** [March 31, 2002, 12:16am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/4 "2002-03-31T00:16:31Z")

</div>

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

---

<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:** [March 31, 2002, 12:21am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/5 "2002-03-31T00:21:44Z")

</div>

## 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…

---

<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:** [March 31, 2002, 12:35am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/6 "2002-03-31T00:35:23Z")

</div>

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]

---

<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:** [March 31, 2002, 12:57am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/7 "2002-03-31T00:57:44Z")

</div>

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

---

<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:** [March 31, 2002, 1:32am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/8 "2002-03-31T01:32:06Z")

</div>

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

---

<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:** [March 31, 2002, 1:36am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/9 "2002-03-31T01:36:06Z")

</div>

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.

---

<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:** [March 31, 2002, 1:51am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/10 "2002-03-31T01:51:30Z")

</div>

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…

---

<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:** [March 31, 2002, 2:08am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/11 "2002-03-31T02:08:07Z")

</div>

## 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); }

---

<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:** [March 31, 2002, 2:21am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/12 "2002-03-31T02:21:08Z")

</div>

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…

---

<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:** [March 31, 2002, 10:01am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/13 "2002-03-31T10:01:29Z")

</div>

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

pom 0]

---

<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:** [March 31, 2002, 10:49am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/14 "2002-03-31T10:49:06Z")

</div>

## 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!

---

<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:** [March 31, 2002, 11:12am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/15 "2002-03-31T11:12:01Z")

</div>

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

pom 0]

---

<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:** [March 31, 2002, 11:34am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/16 "2002-03-31T11:34:22Z")

</div>

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?

---

<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:** [March 31, 2002, 2:03pm UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/17 "2002-03-31T14:03:31Z")

</div>

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.

---

<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:** [April 1, 2002, 9:24am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/18 "2002-04-01T09:24:11Z")

</div>

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

pom 0]

---

<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:** [April 1, 2002, 12:33pm UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/19 "2002-04-01T12:33:46Z")

</div>

lol sometimes i wonder Pom…

---

<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:** [April 2, 2002, 4:15am UTC](https://forum.kirupa.com/t/all-dragable-except-one-why/2449/20 "2002-04-02T04:15:24Z")

</div>

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.
