4 Replies Latest reply on Dec 24, 2008 5:15 AM by Newsgroup_User

    Embed image for use in entire app

    Brent Lamborn Level 2
      Does anyone know how I can embed an image in a Flex app that can be used anywhere in the app? I have several itemRenderers in my app. All of them have something like this in them:

      <mx:Script>
      <![CDATA[
      [Bindable]
      [Embed("assets/images/closeicon/closeiconup.png")]
      public var closeUp:Class;
      ]]>
      </mx:Script>
      <mx:Image id="dragImage" visible="false" source="{closeUp}" width="18" height="18" />


      I was lazy and did it that way for each renderer. How can I embed an image (with CSS?) so that I only have a single Embed that makes my closeUp class available for use throughout the application?
        • 1. Re: Embed image for use in entire app
          john isaacks Level 1
          Maybe make a Singleton class that has a get method for the image?
          • 2. Re: Embed image for use in entire app
            Level 7

            "BrentLamborn" <webforumsuser@macromedia.com> wrote in message
            news:gigikc$ro0$1@forums.macromedia.com...
            > Does anyone know how I can embed an image in a Flex app that can be used
            > anywhere in the app? I have several itemRenderers in my app. All of them
            > have
            > something like this in them:
            >
            > <mx:Script>
            > <![CDATA[
            > [Bindable]
            > [Embed("assets/images/closeicon/closeiconup.png")]
            > public var closeUp:Class;
            > ]]>
            > </mx:Script>
            > <mx:Image id="dragImage" visible="false" source="{closeUp}" width="18"
            > height="18" />
            >
            >
            > I was lazy and did it that way for each renderer. How can I do embed an
            > image
            > (with CSS?) so that I only have to have a single Embed that makes my
            > closeUp
            > class available for use throughout the application?

            Most List based controls have an Icon function, and many of the default
            itemRenderer classes have an icon property or style you can tap into.

            You can also look at what I did here to show the current day on a calendar:

            http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

            HTH;

            Amy


            • 3. Re: Embed image for use in entire app
              Brent Lamborn Level 2
              I found this can be done simply by creating a new public class containing the Embeds, then importing the class into each component that needs to use the icons.

              I really wanted to avoid even having to use an import statement, but this will do. If anyone know of a way to do it without importing anything or importing a script file, let us know!
              • 4. Re: Embed image for use in entire app
                Level 7

                "BrentLamborn" <webforumsuser@macromedia.com> wrote in message
                news:girnfj$72s$1@forums.macromedia.com...
                >I found this can be done simply by creating a new public class containing
                >the
                > Embeds, then importing the class into each component that needs to use the
                > icons.
                >
                > I really wanted to avoid even having to use an import statement, but this
                > will
                > do. If anyone know of a way to do it without importing anything or
                > importing a
                > script file, let us know!

                Yes. Use the icon function. Or if you're setting the background graphic,
                use a styleFunction.