3 Replies Latest reply on Nov 13, 2008 2:06 PM by xtempore

    Icons in MenuBar

    xtempore Level 1
      I have a class called "Img" that contains all my embedded images (icons, cursors, etc). Here's an excerpt...

      public class Img
      {
      [Embed("img/icon_help.png")]
      public static const iconHelp: Class;
      }

      I do this to make things reusable, and it works fine for things like buttons. E.g.
      <mx:LinkButton icon="{Img.iconHelp}"/>

      But it all falls apart when I try to use in in MenuBar. I'm not sure if it's just impossible or if I have my syntax wrong.

      I delved down into the MenuBar.as code and found that it uses...
      iconClass = Class(systemManager.getDefinitionByName(icon))
      ... to produce the class of the image.

      So my question is is there a way to make this work, OR alternately is there a better way to collect all my images into one reusable place that will work with MenuBar?

      Thanks
        • 1. Re: Icons in MenuBar
          Level 7

          "xtempore" <webforumsuser@macromedia.com> wrote in message
          news:gfg8hf$glp$1@forums.macromedia.com...
          >I have a class called "Img" that contains all my embedded images (icons,
          > cursors, etc). Here's an excerpt...
          >
          > public class Img
          > {
          > [Embed("img/icon_help.png")]
          > public static const iconHelp: Class;
          > }
          >
          > I do this to make things reusable, and it works fine for things like
          > buttons.
          > E.g.
          > <mx:LinkButton icon="{Img.iconHelp}"/>
          >
          > But it all falls apart when I try to use in in MenuBar. I'm not sure if
          > it's
          > just impossible or if I have my syntax wrong.
          >
          > I delved down into the MenuBar.as code and found that it uses...
          > iconClass = Class(systemManager.getDefinitionByName(icon))
          > ... to produce the class of the image.
          >
          > So my question is is there a way to make this work, OR alternately is
          > there a
          > better way to collect all my images into one reusable place that will work
          > with
          > MenuBar?

          Try just passing it the string "Img.iconHelp"

          HTH;

          Amy


          • 2. Re: Icons in MenuBar
            ericbelair Level 1
            Have you tried setting the icon values in the MenuBar dataProvider? I haven't tried what you're doing - embedding all images in one class, but it may work. (See pseudo code below).
            • 3. Re: Icons in MenuBar
              xtempore Level 1
              Thanks for the suggestions. I have tried both those ideas.

              The thing is that the value of "icon" must be a String, because the MenuBar code takes that value and then calls getDefinitionByName to get the class.

              If I put all my definitions in the application itself then just having icon="iconHelp" works.

              If I could work out a String that getDefinitionByName would turn into the class value of cls.Img.iconHelp then the problem would be solved. I tried all sorts of variations, but couldn't find one that works.

              I'm about ready to give up on this idea of having all my images in the one static class, but is there a nice alternative?