Setting the height of the control bar in a Spark Application container in Flex 4

The following example shows how you can set an explicit height on the Spark Application container control bar by setting the height property on the controlBarGroup skin part.

By default the control bar sizes itself to its content, so I don’t really recommend setting an explicit height unless you really want to.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see www.adobe.com/products/flex/. To download the latest nightly build of the Flex 4 SDK, see opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/04/21/setting-the-height-of-the-control-bar-in-a-spark-application-container-in-flex-4/ -->
<s:Application name="Spark_Application_controlBarGroup_height_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:controlBarContent>
        <mx:Form backgroundAlpha="0.3" backgroundColor="red"
                creationComplete="sldr.value = controlBarGroup.height;">
            <mx:FormItem label="controlBarGroup.height:" direction="horizontal">
                <s:HSlider id="sldr"
                        minimum="30" maximum="150"
                        change="controlBarGroup.height = sldr.value;" />
                <s:Label id="txt"
                        fontWeight="bold"
                        enterFrame="txt_enterFrameHandler(event);" />
            </mx:FormItem>
        </mx:Form>
    </s:controlBarContent>
    <s:layout>
        <s:VerticalLayout paddingLeft="20" paddingTop="20" />
    </s:layout>
 
    <fx:Script>
        <![CDATA[
            protected function txt_enterFrameHandler(evt:Event):void {
                if (controlBarGroup) {
                    txt.text = controlBarGroup.height.toString();
                }
            }
        ]]>
    </fx:Script>
 
    <s:CheckBox id="chckBx"
            label="controlBarVisible"
            selected="true"
            change="controlBarVisible = chckBx.selected;" />
 
</s:Application>

[GoogleAdsWide]

View source is enabled in the following example.

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.