public function resort():void {
while (tickets.numChildren > 0) {
tickets.removeChildAt(tickets.numChildren - 1);
}
for(var i:int = 0; i < ticketsBought.length; i++)
{
var t:TicketCard = ticketsBought[i] as TicketCard;
tickets.addChild(t);
}
}
执行此功能后,票据会在视觉上闪烁,但我不希望这样,是否有办法在舞台中对对象进行排序而不闪烁?
答案 0 :(得分:1)
我认为您可以使用setChildIndex
类的DisplayObjectContainer
方法(请参阅documentation)重新排序对象,而无需删除然后重新添加它们。
不幸的是,我目前无法对此进行测试,但我认为以下情况应该有效:
public function resort():void {
for(var i:int = 0; i < ticketsBought.length; i++)
{
var t:TicketCard = ticketsBought[i] as TicketCard;
tickets.setChildIndex(t, i);
}
}