0

我想知道是否可以以编程方式设置画布的显示顺序?

例如我有

<mx:Canvas id="head">
...content...
</mx:Canvas>

<mx:Canvas id="shoulders">
...content...
</mx:Canvas>

<mx:Canvas id="knees">
...content...
</mx:Canvas>

<mx:Canvas id="toes">
...content...
</mx:Canvas>

我可以设置一个变量来定义画布的显示顺序吗?所以我可以有一个用户的[头、肩膀、脚趾、膝盖],另一个用户有[脚趾、头、肩膀、膝盖]?

4

1 回答 1

1

您可以使用方法swapChildrenswapChildrenAt来更改组件子级的 Z 顺序。

在 MXML 中,子元素是按照它们的显示顺序创建的,因此如果您希望膝盖高于肩膀,则必须更改组件的顺序,如下所示:

<mx:Canvas id="head">
...content...
</mx:Canvas>

<mx:Canvas id="knees">
...content...
</mx:Canvas>

<mx:Canvas id="shoulders">
...content...
</mx:Canvas>

<mx:Canvas id="toes">
...content...
</mx:Canvas>

或者您可以使用上述方法在事后更改订单。

于 2012-07-18T18:43:00.507 回答