Yes, you are in the situation I described. Your menu data is XML, so the
value of the icon attribute is a String, not a class.

 

I would try something like this:

 

private function createAndShow():void {
myMenu = Menu.createMenu(null, myMenuData, false);
myMenu.labelField="@label";
myMenu.addEventListener("itemClick", menuHandler);

myMenu.setStyle('checkIcon', myCheckIcon);
myMenu.setStyle('radioIcon', myRadioIcon);
myMenu.iconField="@icon";

myMenu.addEventListener(Menu.MENU_SHOW, menuShowHandler);
myMenu.show(150, 150);
}



private function menuShowHandler(event:Event):void

{

            event.target.document = this;

}

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of missgiggygirl
Sent: Thursday, March 22, 2007 12:18 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Icons disappear from Menu at Compile Time

 

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
> It's not a bug. It has to do with variable scoping.
> I'll assume you have data like 
> 
> { label: "foo", icon : "myTopIcon" }

Well, I actually populate the menu by calling a function when a button
is clicked... the function is here:

private function createAndShow():void {
myMenu = Menu.createMenu(null, myMenuData, false);
myMenu.labelField="@label";
myMenu.addEventListener("itemClick", menuHandler);

myMenu.setStyle('checkIcon', myCheckIcon);
myMenu.setStyle('radioIcon', myRadioIcon);
myMenu.iconField="@icon";
myMenu.show(150, 150);
}

and its XML is here:
<mx:XML format="e4x" id="myMenuData">
<root>
<menuitem label="MenuItem 1" icon="myTopIcon"/>
<menuitem label="MenuItem 2" icon="myCheckIcon"/>
<menuitem type="separator"/>
<menuitem label="MenuItem 3" icon="myRadioIcon"/>
</root>
</mx:XML>

I am not sure if this supports what you are saying or not, but I hope
not, because I don't know what to do with your tip! (Kinda new to this
all...)

Thanks,
Ann, The Original Giggle Girl

 

Reply via email to