Setting the accent color on the MX Alert control default button in Flex 4

The following example shows how you can set the accent color on the MX Alert control’s default button in Flex 4 by setting the new accentColor style.

Full code after the jump.

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/2009/11/12/setting-the-accent-color-on-the-mx-alert-control-default-button-in-flex-4/ -->
<s:Application name="Halo_Alert_accentColor_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo"
        creationComplete="init();">
    <s:controlBarContent>
        <s:Button id="btn"
                label="Show alert"
                click="init();" />
    </s:controlBarContent>
 
    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/halo";
 
        mx|Alert {
            accentColor: red;
        }
    </fx:Style>
 
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
 
            protected function init():void {
                Alert.show("Mauris sem nisl, feugiat at fermentum eget, lacinia et nisi. Aenean vitae elit purus, et placerat quam. In justo odio, euismod vel vestibulum ac, tincidunt sit amet lectus. Aliquam non est felis, at lacinia metus. Sed odio magna, adipiscing auctor elementum eu, tempus vitae tellus. Suspendisse varius felis ac ligula pellentesque egestas lobortis mauris hendrerit. Duis vulputate, leo vel lobortis aliquet, dui nunc scelerisque lacus, at convallis ipsum enim et ipsum. Aenean id posuere felis. Nullam bibendum sapien nec dui vehicula ullamcorper. Curabitur placerat auctor erat eget tristique. ", "Lorem ipsum dolor sit amet, consectetur adipiscing elit", Alert.YES|Alert.NO|Alert.OK|Alert.CANCEL);
            }
        ]]>
    </fx:Script>
 
</s:Application>

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.

3 thoughts on “Setting the accent color on the MX Alert control default button in Flex 4

  1. Hi,

    Just want to thank you for a great blog, hope you guys blogging forever! :D
    I curious why you’re not have any live demos for Flash Builder?

    Thanks!

    /Andreas

    1. @Andreas,

      I haven’t been posting SWFs on the blog lately because they take a lot of extra time, plus the Flex 4 API is still somewhat changing which means I’ll eventually have to redo all these examples anways so they compile in the final Flex 4.0 release SDK (and then deleting all the old example SWFs and reposting them is a lot of extra extra work).

      One day all of these should have examples (or not, depending on how much work it is). Depends on if I want to spend all my time playing with old examples or writing new content.

      Peter

Comments are closed.