Couldn't you just use this instead? Using a nested Group/HGroup/VGroup seems like overkill just to center align something.
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"> <s:Button label="button1" horizontalCenter="0" verticalCenter="0" /> </s:Application> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Markus Sent: Wednesday, October 21, 2009 1:08 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Spark layout / horizonal and vertical centered button Ok, i got it. :-) It was really just a little thing. Only the height="100%" was wrong on the VGroup - so it couldn't be aligned in the middle. So my code looks like this now: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"> <s:Group width="100%" height="100%"> <s:HGroup verticalAlign="middle" width="100%" height="100%"> <s:VGroup width="100%" horizontalAlign="center"> <s:Button label="button1"/> </s:VGroup> </s:HGroup> </s:Group> </s:Application> Watch for the minWidth and minHeight if it doesn't scale right when resizing. Markus --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, "Markus" <kram...@...> wrote: > > Hello, > > this might be an easy question but at the moment I am not sure how to do > this. I want to use the new Spark layout and display a button that is > horizontal and vertical centered in the middle. > > I have tried the following code but it didn't work. > > <?xml version="1.0" encoding="utf-8"?> > <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" > xmlns:s="library://ns.adobe.com/flex/spark" > xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"> > > <s:Group width="100%" height="100%"> > <s:HGroup verticalAlign="middle" width="100%" height="100%"> > <s:VGroup width="100%" height="100%" horizontalAlign="center"> > <s:Button label="button1"/> > </s:VGroup> > </s:HGroup> > </s:Group> > </s:Application> > > Any suggestions or examples? > > Regards Markus > > BTW: Does anybody know where to get the source code from Glenn Ruehle's > presentation about Spark layouts on the MAX 2009? >