Hi Guys,
I’m trying to write a script that creates more than one duplicate instance of a movie clip when the user clicks on and drags the movie clip. This works perfectly for one duplicate instance, however, when one attempts to duplicate an additional instance, the previously duplicated instance dissapears from the stage. Why is this? Does duplicateMovieClip() only permit one duplicate instance? Below is my is an exert of my code:
// Author: PrinceTaj
// Date: 09/04/2007
// Script creates duplicate instances of Square_mc
// When the user clicks on the MovieClip and attempts
// to move it onto the canvas
var count:Number = 0; // Counter
function duplicate() {
Square_mc.onMouseDown = function() {
// Duplicate MovieClip
Square_mc.duplicateMovieClip("clone"+count, this.getNextHighestDepth());
var clone:MovieClip = eval("clone"+count); // Reference the MovieClip
//
count++
addToCanvas(clone);
}
}
duplicate();
//Function adds cloned MovieClip to canvas
function addToCanvas(inputMC:MovieClip):Void {
var cloneMC:MovieClip = inputMC;
//
cloneMC.startDrag();
// Check that cloneMC is dropped in Canvas_mc
// Otherwise delete MovieClip
cloneMC.onMouseUp = function() {
if (eval(cloneMC._droptarget) == Canvas_mc) {
cloneMC.stopDrag();
}else {
cloneMC.removeMovieClip();
}
}
}
Please find attached a copy of my source file.
If anybody could shed some light on the situation, it would be much appreciated.
Many thanks
PrinceTaj