It's not a bug.  It has to do with variable scoping.

 

I'll assume you have data like 

{ label: "foo", icon : "myTopIcon" }

 

The icon property is a string, not a class.  The menu renderer wants a
class.

 

You could set up your data like:

{ label: "foo", icon: myTopIcon }

 

Then icon is a class, but that's almost impossible to do when data is
coming from a server.  So, as a convenience, the menu renderer says that
if it gets a String value as the icon, it will assume it is the name of
a variable in the current document that holds a class.

 

Every MXML file is a document and variables are scoped within.  Popups
assume the scope of the application document.  So the menu renderer is
looking for a variable called "myTopIcon" in the application's MXML file
and you moved it elsewhere.

 

I think the solution will be to set the Menu's document property after
it is put on the displaylist and before it creates renderers (or force
it to re-create renderers).  I'd start with MENU_SHOW event.

 

________________________________

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

 

When I use the same code for making a menu is the main app, it works,
when I move it into its own component and call it from the main app,
the icons disappear. And no, it is not a "path" problem, the code
compiles fine with no warnings.

Here are more details:
I am using a menu that has labels and icons. The icons are attached
using snips like this, in an actionscript fragment:

[Bindable]
[Embed(source="icon_revised.gif")]
public var myTopIcon:Class;

As I said, it works fine until I move it into a component, and then it
runs but with missing icons.

I did a search and did find this issue, but did not see any solution.
I am guessing it is a bug, but hope to find a workaround.

Thanks,
Ann

 

Reply via email to