SuperViewStack
by Ruben
For a Flex project I'm working on I decided I would need a ViewStack that also showed the children underneath the selectedChild. As some might know, the ViewStack class displays its children by setting the visibility of one to true, and that of the others to false.
This got me expecting that bringing my concept of an extended ViewStack would be a piece of cake, some piece that was.. Eventually I ended up extending the Canvas class, rather than ViewStack, because the latter seemed to have some creationPolicy issues and doesn't like instanciating children that are not its selectedChild.
SuperViewStack by default displays all of its children that are underneath its selectedChild.
You can easily adjust the factor with which underlying children fade, and with what tint. It is also possible to switch back to normal ViewStack mode.
SuperViewStack has almost all of the functionality that ViewStack has, and all the child-methods (for example addChild()) are still functional.
So go check out the demo, if you're interested you can also check out the source and documentation.
One 'feature' that might seem a little odd to some is that it uses reversed z-indexing, which means that the first added child is on top, and the last on the bottom of the stack. However, you won't notice much of this since all of it is worked out underwater and the first added child still has 0 (zero) as its index, and the fifth will still have 4 as its index..
Comments (read newer)
Hi Ruben, cool component. However, you really should consider renaming it
No joke; in my opinion using *ViewStack indicates that it’s an extended ViewStack and it’s not…. a viewstack indeed has creationPolicy features which are really important from a performant point of view (ie not rendering/loading elements that are not visible on the screen). From the quick look, it seems like your component is not inheriting that same functionality and thus might confuse people.
For the rest, cool stuff and keep sharing!
Good point about the strange name, in fact, you’re the second to mention the (apparently) weird name for the component.. Actually the original intension was to extend ViewStack, hence the name.
I’ve been thinking about a new name for the SuperViewStack, but I’m having a hard time coming up with something suitable, believe it or not :p
And of course thanks for taking the effort to post a comment, I appreciate it..
Don’t think anyting is wrong with the name. It’s a stack of views. That it’s not extending the ViewStack, pfff…. Who cares…if it was a subclass of the ViewStack it would be called SubViewStack:). Anyway great work…
Cool work Ruben! Perhaps you should consider posting it on the Flex Cookbook and on FlexBox to share it with the community:)
Thanks! As a matter of fact it was already noted for the next FlexBox update before I had even sent an email about it.. I’ll try to find time to post it on the Flex Cookbook during the weekend..