views:

1212

answers:

1

Hi,

I've been looking at the following example for populating a PupUpMenuButton http://blog.flexexamples.com/2008/02/21/creating-a-custom-label-function-on-a-flex-popupmenubutton-control/ and would like to add icons to each menu. Ideally, I would specify the icon in the xml and assign it in a similar way to using labelFunction for the text. I'm pretty new to Flex and would appreciate some guidance with this. The only information I've found via google is to create a menu as follows

(seems I can't include more than one url, but it is an example that creates a menu object using the following function):

private function initMenu():void {
            menu = new Menu();
            menu.dataProvider = xmlList;
            menu.labelField = "@label";
            menu.iconField = "@icon";
        }

but I would really prefer to build it all from the XML file.

Many thanks,

Bryn

A: 
<mx:PopUpMenuButton id="myPopupMenu">
    <mx:dataProvider> 
        <mx:Array>
            <mx:Object label="" icon="@Embed(source='icon1.png')"/>
            <mx:Object label="" icon="@Embed(source='icon2.png')"/>
            <mx:Object label="" icon="@Embed(source='icon3.png')"/>
        </mx:Array>
    </mx:dataProvider>
</mx:PopUpMenuButton>
mvalentiner