Duplicate Mc from Library & attach a script!

Hi, i have an issue (1 of many) :stuck_out_tongue:

I duplicate a MC from my Library and arrange on stage, using:

for (var x=0; x<4; x++){
for (var y=0; y<4; y++){
this.attachMovie(“dot”,“dot”+ ++depth, depth)
this[“dot”+depth]._x =515.9 + x * 17.2
this[“dot”+depth]._y =199.2 + y * 17.2
}
}

however, i also have a script which i wish to attatch, so the MC becomers draggable.
I normally use this: (The Mc contains a button)

on(press){
this.startDrag();
}

on(release){
this.stopDrag();
if(this,hitTest(_root.trash)){
_root.trash.gotoAndPlay(2);
unloadMovie(this);
}
}

Anyone know how to do this?..

Thanks! :chinaman:

cancel that…
I am a Moron, lol.

anyhow, use this scipt it works well!..

HI. What is the above code for? I am trying to do something where I have a bunch of polka dots on the screen and the user can drag them around to form designs. However, I am not sure if I should use duplicate movie clip, plus I am having probs individually dragging them. I tried putting each dot on individual layers but that doesn’t seem to work. Any sggestions on how to create many individual instances of one movie clip that are individually draggable?
I also have them color coded, for instance on the left side I have color samples so you canc hange the color of the dots. That is why the dots are instances and not separate, so I don’t have to Set RGB for every single one of them.
I would appreciate a response, if you ever look at this post.

Suzie

to affect each dot, you should make a prototype and assign it to each dot that you duplicate… like this:
[AS]numDots = 10;
scrnW = 300;
scrnH = 200;
MovieClip.prototype.drag = function() {
this.onMouseDown = function() {
if (this.hitTest(_xmouse, _ymouse, true)) {
this.startDrag();
}
this.onMouseUp = function() {
this.stopDrag();
};
};
};
for (i=1; i<=numDots; i++) {
dot = “dot”+i;
_root.attachMovie(“dotID”, dot, i);
_root[dot]._x = Math.random()*scrnW;
_root[dot]._y = Math.random()*scrnH;
_root[dot].drag();
}[/AS]

Can I do the prototype function in Flash 5? I tried it and it shows no error but it doesn’t work either. Hm. So I’m making a dot, and duplicating it with control-D and then putting the script on each dot? Is the “numDot” supposed to physically exist or is it just for the “for” statement? WHy is it that I have to have the “numDot” rather than just using “dot?”

Thank you so much for helping.