【问题标题】:Error 1006 : Swapdepths is not a function错误 1006:交换深度不是函数
【发布时间】:2011-08-12 05:01:53
【问题描述】:

我在使用 swapDepths 函数时遇到了一些问题。我正在编写一个拖放系统。我创建了一个具有最高深度的空 MovieClip (depthSwaper),每次拖动一个对象时,我都会将其深度与 depthSwaper 交换,因此我的对象始终处于最高深度。

问题,我收到此错误:“错误 #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 是我正在移动的影片剪辑。我尝试只使用一个数字来使用 swapdepth,如下所示:e.currentTarget.icone.swapDepths(10); 但我遇到了同样的错误。

有人有想法吗?

感谢阅读!

【问题讨论】:

    标签: actionscript-3 depth


    【解决方案1】:

    没有swapDepths功能的是AS3。您可以使用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);
    

    【讨论】:

      【解决方案2】:

      swapDepths 是 AS2 ,你需要使用 AS3 的新技巧之一

      这里解释得很好:http://www.as3dtk.com/?p=493

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-17
        • 2011-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-22
        • 1970-01-01
        • 2011-01-03
        相关资源
        最近更新 更多