[size=4][font=Comic Sans MS][color=#680aac]Does anyone know a way to apply actions to an attached/created movie clip at runtime? I.E. You use attachMovieClip to attach a clip, and then you add a startDrag/stopDrag system to it dynamically. Is it possible?[/color][/font][/size]
when you attach a movie clip you have to give ot an instance name
this.attachMovie(“id”, “instanceName”, 5);
you can use that instance name to dynamically start and stop drag it
instanceName.stratDrag();
[font=Comic Sans MS][size=4][color=#680aac]What I need is to apply a whole long section of code to a duplicated movie clip, and maybe to see if I can attach a contextMenu to a clip with a number in the instance, such as, you load the clip, and it has an instance name of “blahblahblahblah”+i, and attach a premade _cm to it. Does anyone know how?[/color][/size][/font]
once you’ve got the instance name of the movieclip you’ve attatched, simply:
*target*.onMouseDown = function() {
if (*target*.hitTest(_root._xmouse, _root._ymouse, true)) {
*target*.startDrag(true);
}
}
*target*.onMouseUp = function() {
*target*.stopDrag(true);
}
hope this helps