Dynamic Icons in a ComboBox

Wrote this example for a gent on the Flashcoders list. Didn’t want an orphan page on my site, so linking to it from here. Shows how to use a cellrenderer in a ComboBox to show an icon. I should of only changed in the icon in the setValue function if it changed, like so:

if(lastIcon != item.icon)
{
   lastIcon = item.icon;
   image_ldr.load(item.icon);
}

That would of prevented the flicker you see when you roll over the items. The more I code in Flash, the more I love Flex. Flash is still faster though, no doubt.

Icon in a ComboBox using a cellrenderer

Comments

3 responses to “Dynamic Icons in a ComboBox”

  1. Stefan Avatar

    thanks for posting this – but ideally the icon should also show in the closed combobox state. I couldn’t figure that one out yet…

  2. Phillip Kerman Avatar
    Phillip Kerman

    I’m pretty sure you could get rid of the blinking via BitmapData class. Naturally, I’m just pointing this out instead of doing the legwork.

  3. Jack Strube Avatar
    Jack Strube

    I got rid of the flicker by using this code gleaned from minorgod on sephroth’s forum. Thanks for your example.

    if(!item.loaded_once){
    item.addProperty(‘loaded_once’);
    item.loaded_once = true;
    image_ldr.load(item.icon);
    }