I found the tutorial on duplicating movieclips very helpful, especially the line-by-line translation of the code. I’d appreciate information on how to communicate with those clips—specifically to make them draggable and also to change the _rotation with Key.Right, Key.Left.
This works very elegantly; thank you! I’d been trying to do it with a moviescript and prototype and was getting nowhere.Thanks again for your help.
Cliff
I have one additional question … I’d like to be able to rotate the clips individually rather than have them all rotate at the same time. So I need to be able to click on an individual duplicated movieclip and give it directions directly. Is that possible with this script or do I need a different approach?
I got that to work for dragging the movieclips, as you say, but I’m still having trouble writing the script to rotate the clips individually with the Left/Right keys. I’ll have 50 to 100 duplicate clips so thats why I thought the prototype might work—but I can’t get the syntax right.
This is probably not the most sophisticated approach but I have figured out a solution to my question of controlling individual duplicate movieclips with the keyboard. It involves naming the movieclips and then getting the name. I’m a beginner, so beware! There are probably other errors in this code. I’m sure the more skillful people on the forum could write a much more elegant solution. But for what it’s worth here it is.
myVariable = "currentbar";//will hold the name of the active _mc
i = 1;
speed = 10;
while (i<50 && i>0) {
duplicateMovieClip(_root.bar, "bar"+i, i+1);
i++;
}
movieClip.prototype.onPress = function() {
startDrag(this, false, 0, 0, 500, 350);
myVariable = this._name;//returns the name of the active _mc
trace(myVariable);
};
movieClip.prototype.onRelease = function() {
stopDrag();
};
movieClip.prototype.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
get(myVariable)._rotation -= speed; //gets the name of the active _mc
}
if (Key.isDown(Key.RIGHT)) {
get(myVariable)._rotation += speed;
}
}