Reputation: 25
I'm having some trouble with swapDepths function. I'm programming a drag/drop system. I created a empty MovieClip (depthSwaper), with the highest depth, and every time I drag one of my objects, I swap its depths with depthSwaper, so my object is always on the highest depth.
Problem, I get this error : "Error #1006 : swapDepths is not a function".
Here's my script :
public function monDown(e:MouseEvent) {
e.currentTarget.icone.swapDepths(depthSwaper);
e.currentTarget.startDrag();
} //monDown
public function monUp(e:MouseEvent) {
e.currentTarget.icone.swapDepths(depthSwaper);
e.currentTarget.stopDrag();
if(e.currentTarget.hitTestObject(slotTete) && (e.currentTarget.type == "arme")) {
e.currentTarget.x = slotTete.x;
e.currentTarget.y = slotTete.y;
} else if(e.currentTarget.hitTestObject(slotTorse) && (e.currentTarget.type == "torse")) {
e.currentTarget.x = slotTorse.x;
e.currentTarget.y = slotTorse.y;
} else {
annulerDrag(e.currentTarget);
}
} //monUp
currentTarget.icone is the MovieClip I'm moving. I tried to use swapdepth with just a number, like this : e.currentTarget.icone.swapDepths(10); but i'm getting the same error.
Does anyone has an idea?
Thanks for reading!
Upvotes: 1
Views: 789
Reputation: 15580
There is no swapDepths function is AS3. You can do what you need with swapChildren()
. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#swapChildren%28%29
Basically you call it on the container of your two clips, and it swaps their depths:
myContainer.swapChildren(child1,child2);
or, in context (hopefully):
e.currentTarget.swapChildren(icone,depthSwaper);
Upvotes: 2
Reputation: 2097
swapDepths is AS2 , you need to use one of AS3's new tricks
Well explained here: http://www.as3dtk.com/?p=493
Upvotes: 1