在Flash AS 3.0中更改嵌套动画片段的级别

时间:2012-06-05 18:15:23

标签: actionscript-3 flash

我正在开发一个缩放的方形导航项目(在视觉上类似于Windows Metro,但是当点击时,方块会占据屏幕)。我无法将方块放到顶层(setChildIndex)。以下是单击方框时的代码:

function zoom(event:MouseEvent):void {
    // saves location and size of icons
    returnto = event.currentTarget;
    returntoX = event.currentTarget.x;
    returntoY = event.currentTarget.y;
    returntoWidth = event.currentTarget.width;
    returntoHeight = event.currentTarget.height;
    // turn off button behaviours
    event.currentTarget.buttonMode = false;
    event.currentTarget.alpha = 1;
    event.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER, rollover);
    event.currentTarget.removeEventListener(MouseEvent.CLICK, zoom);
    event.currentTarget.removeEventListener(MouseEvent.ROLL_OUT, rollout);
    // put clicked box on top
    setChildIndex(returnto, numChildren-1);
    // fade out icon decor
    TweenLite.to(returnto.decor, .25, {alpha:0});
    // make square take over screen, call finished when done
    TweenLite.to(returnto, 1, {x:stage.x,y:stage.y, width:stage.stageWidth, height:stage.stageHeight, ease:Expo.easeInOut, onComplete:finished});
}

正方形都位于舞台上的主要动画片段(名为导航)内(因此第一个方块是navigation.sq_1)

我不是Flash开发人员,所以我真的很难与AS3竞争。希望这足以让有人帮忙。谢谢! 小号

1 个答案:

答案 0 :(得分:0)

尝试使用returnto方法添加addChild()剪辑:

// put clicked box on top
addChild(returnto);

addChild()将孩子置于所有孩子之上时,显示列表的默认行为。其他孩子的指数都是重新计算的。