错误 1006:Swapdepths 不是函数
我在使用 swapDepths 函数时遇到一些问题。我正在编写一个拖放系统。我创建了一个空的 MovieClip (深度交换器),具有最高的深度,每次拖动其中一个对象时,我都会将其深度与深度交换器交换,因此我的对象始终处于最高深度。
问题,我收到此错误:“错误 #1006:swapDepths 不是函数”。
这是我的脚本:
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 是我正在移动的 MovieClip。我尝试仅使用一个数字来使用 swapDepth,如下所示: e.currentTarget.icone.swapDepths(10); 但我遇到了同样的错误。
有人有想法吗?
感谢您的阅读!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AS3没有swapDepths函数。您可以使用
swapChildren()
执行您需要的操作。 http://help .adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#swapChildren%28%29基本上,您可以在两个剪辑的容器上调用它,并交换它们的深度:
或者,在上下文中(希望如此):
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%29Basically you call it on the container of your two clips, and it swaps their depths:
or, in context (hopefully):
swapDepths 是 AS2 ,您需要使用 AS3 的新技巧之一
这里有很好的解释: http://www.as3dtk .com/?p=493
swapDepths is AS2 , you need to use one of AS3's new tricks
Well explained here: http://www.as3dtk.com/?p=493