0 Replies Latest reply on Jun 29, 2010 2:17 PM by PHANTOMIASA

    Changing the background image of a SkinnableContainer

    PHANTOMIASA

      Hello to all!

       

      I create this component and add it with:

      Main.mxml:

      var test:MySkinnableComp= new MySkinnableComp();
      ...
      this.addElement(test);
      

       

      MySkinnableComp:

      <?xml version="1.0" encoding="utf-8"?>
      <s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"
                            skinClass="styles.skins.SkinBackgroundMySkinnableComp" width="160" height="80" creationComplete="init()">
      

      there I have fx:Script part and a Label.

       

      styles.skins.SkinBackgroundMySkinnableComp:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:mx="library://ns.adobe.com/flex/mx"
              xmlns:s="library://ns.adobe.com/flex/spark">
      
          <fx:Metadata>
              [HostComponent("spark.components.SkinnableContainer")]
          </fx:Metadata> 
      
          <s:states>
              <s:State name="normal" />
              <s:State name="disabled" />
              <s:State name="black" />
              <s:State name="yellow" />
          </s:states>
      
      
          <s:BitmapImage source.yellow="@Embed('styles/assets/Test-yellow.png')" source.black="@Embed('styles/assets/Test-black.png')" left="0" right="0" top="0" bottom="0"/>
          <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" />
      </s:Skin>
      

       

      What I want is that I can change the BitmapImage with the view states. I want to create test, test1, test2, test3, ... but always with another view state.

      So I have for example the states "yellow" and "black". How can I access this and set these states?

       

      Or is there another possibility to change the backgroundImage of this SkinnableComp? I do not want to create SkinnableCompYellow.mxml, SkinnableCompBlac.mxml, ...

       

      Thanks a lot in advance & Best Regards.