Styling buttons in an Alert control

by Peter deHaan on August 9, 2007

in Alert

Here’s a basic example of applying a custom style to an Alert control’s buttons and giving them a nice, rounded effect.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/09/styling-buttons-in-an-alert-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">

    <mx:Style>
        .roundedAlertButtons {
            cornerRadius: 10;
            font-weight: bold;
            color: black;
        }
    </mx:Style>

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function showAlert():void {
                alert = Alert.show("The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.", "I'm an Alert control.", Alert.YES | Alert.NO);
                alert.setStyle("buttonStyleName", "roundedAlertButtons");
            }
        ]]>
    </mx:Script>

    <mx:Button label="Show alert" click="showAlert();" />

</mx:Application>

View source is enabled in the following example.

{ 3 comments… read them below or add one }

1 kris August 9, 2007 at 11:40 pm

hI. I really liked the hover effects at the bottom of your page here: http://dougmccune.com/flex/awesomerss2/

please tell me how i can make something like that.
Thanks in advance and more power!

Reply

2 peterd August 9, 2007 at 11:54 pm

kris,

I didn’t make that app, its the work of Mr. Doug McCune. You can find more information on it here:
“Updated MXNA RSS Reader Flex App – Now With Source” and you can even check out the full source code for the application (Thanks Doug!)

And I believe the effect you were thinking of is “Ely Greenfield’s Fisheye Component”.

Happy Flexing!

Reply

3 kris September 25, 2007 at 9:14 am

Many thanks for that piece of info. I’ll check it out. :)

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: