duplicate a mc in flash
- Started
- Last post
- 11 Responses
- Spix
I got a file with 13 dragable MC's. I got 50 targets where you can drop any of those MC's. Each MC' represent a goal you want to achive in life (travel for example) and the 50 targets represent a certain time in life (years). there is 5 targets per year and 10 years.
So lets say I would like to travel 5 times a year the next 10 years. Then the MC that represent travel needs to be draged down to the 50 diffrent targets. So what I need is for that MC to Duplicate when selected and draged away from it's orginal possition. Does that make sence? How do I do that?
thanks very much for any help you might offer.
- function820
so you want the original clip to stay put, but a new one to be created over top of it and begin to drag?
make a movie clip and name it mc_orgClp, paste the code below into the first frame of the movie
its really basic, but can be elaborated from here, probably best to make it a function if you have different movies that need to be selected
depthLevel = 1;
num = 0;
mc_orgClp.onPress = function() {
duplicateMovieClip(this, "mc_newClip"+num, depthLevel);
_root["mc_newClip"+num].startDra...
num++;
depthLevel++;
};
mc_orgClp.onReleaseOutside = function() {
stopDrag();
};
- Spix0
yes thats what I want. thanks...I will try that :)
- Spix0
hmm..dont get it to work..this is waht I got so far...how would i put duplicateMovieClip in here?
on (press) {
startDrag(this);
this.swapDepths(100);
}
on (release) {
stopDrag();
if (this._droptarget=="/target1") {
setProperty(this, _x, 22.0);
setProperty(this, _y, 126.0);
}else {
setProperty(this, _x, 22.0);
setProperty(this, _y, 30.0);
}
}
- Spix0
so I added
duplicateMovieClip( this, "mc_newClip"+num, depthLevel);
to 'on(Press)'
ans at first it duplicate...but then when I try to click the duplicate or the orgnial then the MC I'm draging will not release until I click on something elese..
- Spix0
http://66.129.113.217/test2.html…
please help :(
- function820
are you attaching the movieclip or is it on the stage when you compile the swf? because swapDepths will only work if you attach the movie.
the way you're doing it is you're dragging the old one, and making a new one stay at the old spot, it did it the oppisite way, where the new one is moveable
also, loose the set property (unless you're in flash 5)
this._x = 22 is the same, but easier to work with
checkout
http://prototype.uncredited.net/…
drag the top box into the lower lighter box
is this the effect needed?
heres that code:
first frame of the movie
depthLevel = 1;
num = 0;
countup=0
mc_orgClp.onPress = function() {
duplicateMovieClip(this, "mc_newClip"+num, depthLevel);
currentClip = _root["mc_newClip"+num]
currentClip.startDrag(true);num++;
depthLevel++;
};
mc_orgClp.onReleaseOutside = function() {
stopDrag()
if (eval(currentClip._droptarget) == _root.targetArea){
currentClip._x = countup+=this._width+10
currentClip._y = 150
}else{
removeMovieClip(currentClip)
}
delete currentClip
};
- function820
i checked that link... looks like its working fine?
- Spix0
it works fine the first time you drag it (1st square) then it get out of control...
I'm looking on what you showmed me last now....thanks..hopefully I get somewhere.
- Spix0
it works a litelbit better now when I removed swapdepths...but as you say. it seems like I'm dragin the old one.
I would of never figured that out my self :)
- function820
i gotta run for a bit, but if you need anymore info just email me
- Spix0
thanks man :)