Adding your own custom CheckBox control icons in Flex

by Peter deHaan on September 29, 2007

in CheckBox

The following example shows how you can override the default icon in the Adobe Flex CheckBox control and replace it with a custom embedded graphic.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/29/adding-your-own-custom-checkbox-control-icons-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        CheckBox {
            /* Unselected icons */
            upIcon: Embed(source="assets/bullet_red.png");
            overIcon: Embed(source="assets/bullet_red.png");
            downIcon: Embed(source="assets/bullet_yellow.png");
            /* Selected icons */
            selectedUpIcon: Embed(source="assets/bullet_green.png");
            selectedOverIcon: Embed(source="assets/bullet_green.png");
            selectedDownIcon: Embed(source="assets/bullet_yellow.png");
        }
    </mx:Style>

    <mx:CheckBox id="cheezburger"
            label="I can has cheezburger?"
            fontSize="12"
            fontWeight="bold" />

</mx:Application>

View source is enabled in the following example.

{ 3 comments… read them below or add one }

1 peterd September 30, 2007 at 5:34 am

Sorry for the lack of SWFs on the last couple posts… I’m currently in a hotel in Chicago for Adobe MAX 2007/North America. I’ll generate and posts the SWFs when I get a bit more time later in the week.

Hope to see you all at MAX!

Peter

Reply

2 Leicht September 30, 2007 at 6:33 am

hi,I’m a fresh,can you give me some advise to study Flex,and can you tell me how do u study Flex,thanks.
关注你的BLOG,很久了,收获很多,感谢你的分享!

Reply

3 Stephen September 30, 2007 at 8:58 am

Hey peterd,

If you need help with Flex, I have an awsome example that needs attention. It is an open source Flex/AMFPHP/MySQL based task management system (like tada). I actually want to make a basecamp replaement in Flex and make it open source. I actually only published a version with project management and task management, but I am working on one that does projects, tasks, calendar and user management in the system. Tell me if your interested or at least the code will get you started.

Stephen Weber
http://www.weberdesignlabs.com
http://www.weberdesignlabs.com/blog/

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: