1 Reply Latest reply on Jul 19, 2011 1:43 PM by Amy Blankenship

    missing backgroundImage style - recommended alternative

    Sefi Ninio

      Hey,

       

      The application I am working on was originally written using the Flex 3.5 SDK, and relied extensively on the backgroundImage style.

      Now, I am in the process of migrating it to Flex 4.5 but the intention is not to do a full migration, replacing all MX compoennts with their Spark counterparts, but rather to "make it compile" with the Spark theme eliminating all errors and warnings, and from this point on develop new features using the Spark architecture.

       

      This puts me in a position where I can't migrate components that use the backgroundImage to full blown Spark components (doing so would easily solve the problem - just add the background image as an image/bitmapImage control in the skin) but I still have to display the image in the background.

       

      The solution I found was kind of "in the middle".

      I created a generic skin, it's hostComponent being SkinnableContainer. It looks exactly like the default SkinnableContainer skin with one difference: it defines a BitmapImage inside a Group instead of the background rect graphics.It also exposes public API to get an embedded image Class.

      Then, I wrapped the mx component that should have the background image in a component that extends SkinnableContainer. That wrapper embeds the images and has it's skinClass set to the skin above. on skinAttach, I assign the embedded image Class to the skin public API.

       

      While that works, I am a bit buffled. I am unsure this is the best approach.

      I know there is also BorderedContainer, which does support backgroundImage style but I was unable to use it effectively.

       

      My question is, is there another, simpler way to accomplish this?

       

      Thanks,

      Sefi