【问题标题】:Arrange (z) order of objects in Flash with ActionScript 3?使用 ActionScript 3 在 Flash 中排列 (z) 对象的顺序?
【发布时间】:2011-07-14 23:39:52
【问题描述】:

是否可以使用 ActionScript 3 在 Flash 中排列 (z) 对象的顺序?

例如我在给定图层上有 3 个符号实例,我想执行相当于“带到前面”、“向前”的操作,和/或定位某个 z 位置。

【问题讨论】:

    标签: flash actionscript-3 z-index flash-cs5


    【解决方案1】:

    您可以使用这样的动作脚本来更改同一层中影片剪辑的 z-index(堆叠顺序)。

    parent.setChildIndex(childObject, i)
    

    将 childObject 更改为要更改 z-index 的影片剪辑的名称,将 i 更改为整数(所需的 z-index 值)。

    如果您想在鼠标事件上实现这一点,请将上述代码放入函数中,并将事件侦听器附加到按钮以在鼠标事件上调用此函数。

    【讨论】:

      【解决方案2】:

      放在前面会是这样的:

      myObject.parent.setChildIndex( myObject, myObject.parent.numChildren - 1);

      提前会是这样的:

      myObject.parent.setChildIndex( myObject, myObject.parent.getChildIndex( myObject ) + 1);

      设置特定的 z 索引将是:

      myObject.parent.setChildIndex( myObject, newZIndex);

      【讨论】:

        猜你喜欢
        • 2011-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-12
        • 2011-01-15
        • 2013-07-29
        相关资源
        最近更新 更多