Skip to main content
Known Participant
May 31, 2010
Answered

how to swap one movie clip to another??

  • May 31, 2010
  • 1 reply
  • 1132 views

im making a drop and drop game and i would like to swap one movie clip to another...

the first movie clip is the draggable mc, when it hits the drop zone i'm planning to put an animated version of it...

as of now this is the code that i'm using....

if (eval(this._droptarget) == pitsel_mc) {
this._x = this._x;
this._y = this._y;
} else {
this._x = start1x;
this._y = start1y;

}

as you can see, after leaving the mc in the drop zone, the mc just remained on its position....

is there a script to swap it to an animated version of the current mc??

Hope you guys could help...

This topic has been closed for replies.
Correct answer kglad

use:



sugar_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == pitsel_mc) {
var mc:MovieClip=attachMovie("sugarpour","sugarpour",getNextHighestDepth());

mc._x=this._x;

mc._y=this._y;

this.swapDepths(getNextHighestDepth());

this.removeMovieClip();

} else {
    // take back to start pos
this._x = start1x;
this._y = start1y;
}
};

p.s.  please mark this thread as answered, if you can.

1 reply

kglad
Community Expert
Community Expert
May 31, 2010

no.

but you can use the movieclip methods attachMovie(), swapDepths() and removeMovieClip() to do what you want.

dn0myar06Author
Known Participant
May 31, 2010

its quite working already but the mc sugarpour is located at (0,0)

i was trying to put the sugarpour mc to the location where the release of sugarpour is...

sugar_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == pitsel_mc) {
attachMovie("sugarpour","sugarpour",this.getNextHighestDepth());
_parent.sugarpour._x =_root.sugar_mc._x;                                    // i'm not sure what script to use so i tried this
_parent.sugarpour._y =_root.sugar_mc._y;
this._x = this._x;
this._y = this._y;
} else {
    // take back to start pos
this._x = start1x;
this._y = start1y;
}
};

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 31, 2010

use:



sugar_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == pitsel_mc) {
var mc:MovieClip=attachMovie("sugarpour","sugarpour",getNextHighestDepth());

mc._x=this._x;

mc._y=this._y;

this.swapDepths(getNextHighestDepth());

this.removeMovieClip();

} else {
    // take back to start pos
this._x = start1x;
this._y = start1y;
}
};

p.s.  please mark this thread as answered, if you can.