apache-flexpopupmenubutton

Error in embeding icons in PopUpMenuButton node


I am trying to create a popupmenubutton, with images and label as its nodes. But I am unable to embed the icons. It gives me and error(given below). Thou the label alone are working fine.

<mx:PopUpMenuButton id="menu_file" labelField="@label" itemClick="{menuClickHandler(event);}" visible="false"
        height="20" left="0" top="0" width="15" alpha="0.5" cornerRadius="5" useHandCursor="true"
        toolTip="Delete, Move, Rename or Modify other properties">
        <mx:dataProvider>
            <mx:XMLList>
                <node label="{LABEL_DELETE}" icon="@Embed(source='assets/FileManager/images/cancel2.png')"/>
                <node label="{LABEL_DOWNLOAD}" icon="@Embed(source='assets/FileManager/images/cancel2.png')"/>
                <node label="{LABEL_MOVE}" icon="@Embed(source='assets/FileManager/images/cancel2.png')"/>
                <node label="{LABEL_RENAME}" icon="@Embed(source='assets/FileManager/images/cancel2.png')"/>
                <node label="{LABEL_SET_PRIVACY}" icon="@Embed(source='assets/FileManager/images/cancel2.png')"/>
            </mx:XMLList>
        </mx:dataProvider>

This gives me an error: Initializer for 'Embed': unrecognized compile-time directive.

Plz can someone tell me what I am doing wrong here.

Thanks Zeeshan


Solution

  • I normally create a class for each Icon i need

    [Embed("img/Print.png")]
    public const printIcon : Class;
    

    and than use this class as icon

             <mx:XMLList>
                <menuitem label="File">
                    <menuitem label="Print" icon="printIcon"/>
                    <menuitem label="Logout" icon="logoutIcon" />
                    <menuitem label="Close" icon="closeIcon"/>
                </menuitem>
                <menuitem label="Modify">
                    <menuitem label="Preferences" icon="toolIcon" />
                </menuitem>
                <menuitem label="Help">
                    <menuitem label="About Us" icon="infoIcon"/>
                </menuitem>
            </mx:XMLList>