...

View Full Version : ActionScript 2 - Duplicating Objects.



udjamaflip
04-26-2009, 02:51 PM
Hi all,

I have the following code which is supposed to create an identically duplicate object of the movieclip (including attached actionscript) except the instance name of course.



on (press) {
n = Number(n)+1;
var myName = "dup" + n;
duplicateMovieClip("swim_btn", myName, n);
startDrag(myName, false);
}
on (release, releaseOutside) {
stopDrag();
}


When I drag the movieclip to an area, it does duplicate the clip but when I try to drag the duplicate it makes the original snap-back to the cursor then it drags the original around.

Can anyone help me with where I am going wrong?

gnomeontherun
04-27-2009, 08:46 AM
Well a duplicate clip doesn't inherit the actionscript of its parent.

"Variables in the parent movie clip are not copied into the duplicate movie clip." from the documentation. You'll need to have functions ready to handle the new movieClip, and they won't be the on (release) type. They will need to be onClipEvent.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum