0 Replies Latest reply on Mar 28, 2010 2:59 PM by thx1138

    Best way to make skins swappable in Flex 4

    thx1138 Level 1

      Hi, I really love the new Flex 4 skinning architecture! Congrats on an amazing design!

       

       

      Now that I've been using it for a while I'm trying to figure out a few things.

       

      If I want to make my whole app skinnable and dynamic at runtime how would I do it?

       

      For example let's say I have this application:

       

      <MyApp styleName="applicationStyle" >


              <fx:Style source="assets/styles/default.css"/>

       

       

              <s:Button label="feedback" id="feedbackButton"   />

              <s:Button label="contact id="contactButton"   />

       


              <s:SkinnableContainer id="formContainer" width="100%" left="10" right="10" top="50">

       

                      <s:TextInput id="nameInput"   />

                      <s:Button label="submit" id="submitButton"   />

       

              </s:SkinnableContainer>

       

      </MyApp>

       

      I could then style it with this:

       

      default.css:


      @namespace s "library://ns.adobe.com/flex/spark";
      @namespace mx "library://ns.adobe.com/flex/mx";

       

      s|Button#feedbackButton {
           skinClass:ClassReference("com.domain.skins.FeedbackButtonSkin");
      }

       

      s|Button#contactButton {
           skinClass:ClassReference("com.domain.skins.ContactButtonSkin");
      }

       

      s|SkinnableContainer#formContainer {
          skinClass: ClassReference("com.domain.skins.FormContainerSkin");
      }

       

      s|TextInput#nameInput {
           skinClass:ClassReference("com.domain.skins.TextInputSkin");
      }

       

      s|Button#submitButton {
           skinClass:ClassReference("com.domain.skins.SubmitButtonSkin");
      }

       

       

       

      If I have a second css file that points to different skins how would I change that dynamically at runtime? Am I getting the right idea here?

       

      thx