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

by Peter deHaan on November 12, 2009

in Alert, beta2

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 beta, check out the Adobe Flash Builder 4 page on the Adobe Labs site. To download the latest build of the Flex 4 SDK, see http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4. For instructions on using the beta Flex 4 SDK in Flex Builder 3, see "Using the beta Flex 4 SDK in Flex Builder 3".

<?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.

{ 2 comments… read them below or add one }

1 Andreas November 13, 2009 at 11:19 am

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

Reply

2 Peter deHaan November 13, 2009 at 7:53 pm

@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

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: