简体   繁体   中英

Flex 4: Descending vertical DataGroup?

I am currently working on a Photoshop-like transformer application to work with DisplayObjects as layers. I have an ArrayCollection which serves as my data provider for my List of values, but the problem is that the items are appearing in ascending order in the List:

0 - Item 1
1 - Item 2
2 - Item 3
3 - Item 4

Since it's a layer manager application, I need the items to appear in descending order like so:

3 - Item 4
2 - Item 3
1 - Item 2
0 - Item 1

This is because layer 0 is at the bottom of the stack, whereas layer 3 is at the top, rather than the other way around which is the way Flex is currently displaying things.

I know that I can simply apply a Sort to my ArrayCollection to cause the items to be sorted in reverse order, but this breaks functionality in my application. I was wondering if it would be possible to essentially modify my Spark List or DataGroup to have the layout render items backwards. Does anyone know of a short cut by which to do this?

Here's a clue (I'm still working on it) : I created a VerticalReversedLayout.as class based on VerticalLayout. In updateDisplayListVirtual and/or updateDisplayListReal there is a for (var...) positioning the children on the y axis, just invert the direction of the loop. Then you just assign this layout to your DataContainer (or List in my case). It works perfectly.

If you use the dragMove feature, you may have to modify calculateDropIndex as well.

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