简体   繁体   中英

Flex programmatically ordering Canvas

I am wondering if it is possible to set the display order of your canvas' programmatically?

For Example i have

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

could i set a variable to define the order the canvas' are displayed? so i could have [head, shoulders, toes, knees] for one user and [toes, head, shoulders, knees] for another?

You can use the methods swapChildren and swapChildrenAt to change the Z-order of a component's children.

In MXML, children are created in the order they are displayed, so if you want knees to be above shoulders, you'll have to change the order of your components, like this:

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

Or you could use the above methods to change the order after the fact.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM