有没有办法在舞台上将特定的movieClip发送到所有其他movieClip的前面?
我知道setChildIndex,但我无法找到一种动态计算顶部位置的方法。
答案 0 :(得分:13)
您可以将setChildIndex()
与numChildren
一起使用。
setChildIndex(childClip, numChildren - 1);
答案 1 :(得分:4)
您不需要使用setChildIndex。 addChild正在发送所有剪辑顶部的子节点。 您可能认为addChild将双重添加您的MC,但它不会,第二次它只会更新它的子索引。
答案 2 :(得分:0)
默认情况下,flash会将动画片段添加到显示列表的顶部,这样您就可以重复将子项添加到容器中。
stage.addChild(bottom);
stage.addChild(top);
// top is now on bottom.
stage.addChild(bottom);
// bottom is now on top.
答案 3 :(得分:0)
在画布上添加了动画片段(mc),
canvas.setChildIndex(mc, 0);
画布已添加到舞台上,
stage.setChildIndex(canvas, 0);
答案 4 :(得分:-1)
/* Bring Any Clicked Object to the Front
Clicking on any symbol on the Stage moves it in front of all other instances.
*/
// This code makes all symbol instances on stage clickable by making them listen for the CLICK event.
for (var fl_ChildIndex:int = 0;
fl_ChildIndex < this.numChildren;
fl_ChildIndex++)
{
this.getChildAt(fl_ChildIndex).addEventListener(MouseEvent.CLICK, fl_ClickToBringToFront);
}
// This is the function that moves the clicked object to the front of the display list
function fl_ClickToBringToFront(event:MouseEvent):void
{
this.addChild(event.currentTarget as DisplayObject);
}
来自Adobe Flash Professional代码段。