Skip to main content
Known Participant
January 5, 2007
Question

how to drag and move duplicated movieclip in flashMX

  • January 5, 2007
  • 5 replies
  • 567 views
i would like to know how to drag and move duplicated movie clip in flashMX? i'm unable to drag and move duplicated movieclips but able to see duplicated movieclip on the stage. Is there anyone who can show me or direct me to any tutorial site?

Thanks
This topic has been closed for replies.

5 replies

kglad
Community Expert
Community Expert
January 12, 2007
just call dragging() after each movieclip (that you want to be able to drag) is created. dragA() stores the absolute path/instance name of your movieclip.
kglad
Community Expert
Community Expert
January 8, 2007
what movieclip are you trying to duplicate and drag? other than the empty movieclip you create in wire and which won't respond to mouse handlers because its parent is intercepting them and which you wouldn't see being dragged (because it's empty) even if it were being dragged, what problem are you having?
spysumAuthor
Known Participant
January 9, 2007
Thanks kglad for guiding me! i have edited my code and would like to drag my duplicated movieclip which is mc in mycode.
Below is my code:


kglad
Community Expert
Community Expert
January 9, 2007
you can't use mouse handlers on mc because its a child of wire and wire has a mouse handler (onPress) which intercepts mouse events that you are trying to have mc detect.

to remedy, you must use a loop or an onMouseDown handler and a hitTest between the mouse and mc instead of a mouse handler:

spysumAuthor
Known Participant
January 8, 2007
i have just changed to Flash MX2004 and below is my code. I'm not sure what has gone wrong with my script as i still unable to drag my duplicated movieclip? hope u guys can help me out!

var mySelection = "";//Global declaration
var totalmc = 0;

wire.onPress = function ()
{
this.createEmptyMovieClip(["mc"+totalmc], this.getNextHighestDepth(["mc"+totalmc])); //Create a newMovieClip with variable name "mc1""
duplicate(["mc"+totalmc]);
//trace(["mc"+totalmc]);
dragging(["mc"+totalmc]);
mc = attachMovie("idwire", ["wire"+totalmc++], this.getNextHighestDepth(["wire"+totalmc])); //store the Movie into mc1 by attaching
mc._x = 273;//(Stage.width - mc1._width)/2;
mc._y = 196.5;//(Stage.height - mc1._height)/2; //setting the corrdinates for x and y axis
dragging(["wire"+totalmc]); //calling the dragging function
//trace(mc1._width +","+ mc1._height);

}

//Function for dragging
function dragging()
{
mc.onPress = function()
{
this.startDrag(true);
mySelection = this;

}
mc.onRelease = mc.onReleaseOutside = function()
{
stopDrag();
}
}

function duplicate()
{

mc.duplicateMovieClip (["mc"+i], i);
i++;

//trace("mc"+i);
//trace(x);


}

//Btn function for flipping
flip.onRelease = function()
{
mySelection._rotation += 10;
}

//Btn function for delete
del.onRelease = function()
{
mySelection.removeMovieClip();
}
kglad
Community Expert
Community Expert
January 8, 2007
there are several problems with your code that are corrected below. and it's possible there are more problems with your logic, but start with the following and see if it does what you want:

spysumAuthor
Known Participant
January 8, 2007
Thanks kglad for viewing my post and helping me out. Yup! the codes r working fine and is showing wat i wanted. Now is that i wanted to be able to drag my duplicated movieclips which i was unable to do it. I have try all sorts of method but still unable to make it!
January 5, 2007
Sure...

var clip:MovieClip = myClip.duplicateMovieClip("myClip2", 50);
clip.onPress = function (){
this.startDrag();
}
clip.onRelease = clip.onReleaseOutside = function (){
this.stopDrag();
}
kglad
Community Expert
Community Expert
January 5, 2007
just apply the startDrag() method to your duplicated movieclip. for more specific help, show the code that duplicates your movieclip.