Creating a vertical ButtonBar in Flex

by Peter deHaan on August 20, 2007

in ButtonBar, Embed

This is a simpler version of the “Creating a vertical LinkBar in Flex” entry except it uses the Flex ButtonBar control instead of a LinkBar control. Also, instead of embedding the PNG assets in an <mx:Script /> block, I embedded the images inline using @Embed.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/20/creating-a-vertical-buttonbar-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:HBox>
        <mx:ButtonBar id="buttonBar"
                direction="vertical"
                dataProvider="{viewStack}"
                themeColor="haloOrange"
                fontSize="16"
                width="200"
                height="200" />

        <mx:ViewStack id="viewStack"
                backgroundColor="white"
                width="300"
                height="{buttonBar.height}">

            <mx:Canvas id="checkCanvas"
                    label="Success"
                    icon="@Embed('assets/bulletCheck.png')">
                <mx:Label text="Success" />
            </mx:Canvas>

            <mx:Canvas id="warningCanvas"
                    label="Warning"
                    icon="@Embed('assets/bulletWarning.png')">
                <mx:Label text="Warning" />
            </mx:Canvas>

            <mx:Canvas id="criticalCanvas"
                    label="Error"
                    icon="@Embed('assets/bulletCritical.png')">
                <mx:Label text="Error" />
            </mx:Canvas>

        </mx:ViewStack>
    </mx:HBox>

</mx:Application>

View source is enabled in the following example.

{ 1 comment… read it below or add one }

1 carlos May 12, 2009 at 5:45 am

how do you access <mx:Label text="Error" />

text property from actionscript?
when it is inside a viewstack.
thnx

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: