错误 1006:Swapdepths 不是函数

发布于 2024-11-03 02:18:34 字数 1184 浏览 5 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你的占有欲 2024-11-10 02:18:34

AS3没有swapDepths函数。您可以使用 swapChildren() 执行您需要的操作。 http://help .adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#swapChildren%28%29

基本上,您可以在两个剪辑的容器上调用它,并交换它们的深度:

myContainer.swapChildren(child1,child2);

或者,在上下文中(希望如此):

e.currentTarget.swapChildren(icone,depthSwaper);

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);
假扮的天使 2024-11-10 02:18:34

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文