2012-07-18 72 views
0

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

例如,我有

<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> 

可我设置一个变量,以限定的顺序画布被显示?所以我可以为一个使用者[头部,肩膀,脚趾,膝盖]和另一个使用者[脚趾,头部,肩膀和膝盖]?

回答

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> 

或者您可以使用上述方法在事实之后更改顺序。