12 Replies Latest reply on Jan 17, 2012 6:42 AM by CharlieSkin

    4.5.0: style defaults not all getting applied


      I am trying to build some 4.1.0 projects in Flash Builder 4 using the new SDK.


      The projects use a SWC which has default styles applied using a defaults.css file at the root level. Here is an example of something which worked before:


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


      s|Button {

      skin-class: ClassReference("com.mycompany.myapp.ButtonSkin");



      s|Label {

      fontFamily: "MyDefaultFont";



      Also I can't say for sure but it 'appears' fonts are not getting embedded either. They look softer (is that the new sub-pixel font rendering stuff?) Since it's a font I have on this machine I would have to put the SWF on another machine to be sure. Has font embedding changed from 4.1.0 to 4.5.0? I am using a class to embed the font:


      public static const DEFAULT_FAMILY:String = "MyDefaultFont";


      // Myriad Pro

      [Embed(mimeType="application/x-font", exportSymbol="MyriadProRegular",

      embedAsCFF="true", source="/assets/fonts/MyriadPro-Regular.otf", fontName="MyDefaultFont", unicodeRange="U+0020-007E")]

      private static var myMyriadPro:Class;


      The only hint I have is a series warnings I can't seem to do away with such as "The swc .../4.5.0/frameworks/libs/framework.swc has style defaults and is in the library-path, which means dependencies will be linked in without the styles. This can cause applications, which use the output swc, to have missing skins. The swc should be put in the external-library-path."


      That's all fine and good but when I go into Flex Library Build Path which shows the SDK "Merged into code" and change it to "Use default (external)", once it builds it goes right back to "Merged into code" and the warnings re-appear.


      So, is 4.5.0 not compatible with the production Flash Builder 4, or am I missing something which will help me get my fonts and skins working again?




        • 1. Re: 4.5.0: style defaults not all getting applied
          pkrekelberg Level 1

          I was able to get rid of the Warnings by going into the specific swc's under the SDK in Flex Library Build Path which all still said "Merged into code" instead of the SDK default external, and adjusting them to specifically link as external.


          However, the skins still are not getting called when the buttons are constructed despite the ClassReference. Is there a new trick with the 4.5.0 SDK which was not necessary with 4.1.0 to get skins applied in a SWC's defaults.css file?




          • 2. Re: 4.5.0: style defaults not all getting applied
            Flex harUI Adobe Employee

            Generate a link-report and see if the skin classes are in the SWF.

            • 3. Re: 4.5.0: style defaults not all getting applied
              pkrekelberg Level 1

              Thanks, I looked at the link report and the skins were not listed. Is a ClassReference in the defaults.css not enough to get the classes into applications which use the SWC?


              I tried a few things:

              * referencing the classes in another random class within the SWC, like "private static var compileButtonSkin:ButtonSkin = new ButtonSkin()" but that made no difference. they ended up in the link report, but still were not applied as button skins.


              * referencing the skin classes right in <s:Button> tags, just as a test. This worked, but defeats the purpose of the ease of skinning using ClassReferences in CSS.


              Did something change with the way ClassReferences in library defaults.css are linked?

              • 4. Re: 4.5.0: style defaults not all getting applied
                Jorge Raimundo Level 2

                Have you tried to embed fonts like this:


                    font-family: "MyDefaultFont";
                    /* You can choose the font weight if it fits you
                    font-weight: normal;
                    font-weight: bold;
                    embed-as-cff: false;
                    src: url("assets/fonts/my_font.ttf");
                        U+0020-U+007E, /* englishRange */
                        U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183; /* Latin I */
                • 5. Re: 4.5.0: style defaults not all getting applied
                  pkrekelberg Level 1

                  Hi Jorge, I have. I don't think fonts are the issue any longer. The Button skin is the part that is not making it into the application. Thanks.

                  • 6. Re: 4.5.0: style defaults not all getting applied
                    Flex harUI Adobe Employee

                    Use the -keep-generated-actionscript compiler option.  There will be a

                    XX_Styles.as file that contains the styles the compiler decided to put into

                    the application, based on the classes it found while compiling and linking.

                    • 7. Re: 4.5.0: style defaults not all getting applied
                      pkrekelberg Level 1

                      Cool, thanks. I tried that on both the library and the final application and it had no effect. While project should get that compiler option? Is that intended to allow us to use ClassReference in defaults.css?


                      The same stuff works in 4.1.0, if that is helpful.

                      • 8. Re: 4.5.0: style defaults not all getting applied
                        Flex harUI Adobe Employee

                        The project that creates the output SWF.  It should create a folder called

                        "generated" in the output folder and in there should be a XXX_Styles.as


                        • 9. Re: 4.5.0: style defaults not all getting applied
                          pkrekelberg Level 1

                          Got it. I looked in there and my skin classes did not make it in. Nothing from my application's namespace is in there.


                          This is the part describing Button:


                                  // spark.components.Button


                                  selector = null;

                                  conditions = null;

                                  conditions = null;

                                  selector = new CSSSelector("spark.components.Button", conditions, selector);

                                  mergedStyle = styleManager.getMergedStyleDeclaration("spark.components.Button");

                                  style = new CSSStyleDeclaration(selector, styleManager, mergedStyle == null);


                                  if (style.defaultFactory == null)


                                      style.defaultFactory = function():void


                                          this.fontWeight = "normal";

                                          this.borderColor = 0x505050;

                                          this.color = 0xcccccc;

                                          this.skinClass = spark.skins.spark.ButtonSkin;

                                          this.textRollOverColor = 0xffffff;

                                          this.disabledColor = 0x5a5a5a;

                                          this.borderWeight = 1;

                                          this.backgroundAlpha = 1;

                                          this.textSelectedColor = 0xffffff;




                          You can see it saw part of my style from the library's defaults.css, the border color and weight:


                          s|Button {

                               border-color: #505050;

                               border-weight: 1px;


                               skin-class: ClassReference("com.myapp.ButtonSkin");



                          (Yes, my skin is called ButtonSkin, same shortname as the spark skin. I have tried using MyButtonSkin, etc. and it made no difference)


                          Should it make a difference that the skin is mxml? Should I try a straight AS3 class?




                          • 10. Re: 4.5.0: style defaults not all getting applied
                            Flex harUI Adobe Employee

                            Did I see that you are not using Flash Builder 4.5 and are trying to use SDK

                            4.5 in Flash Builder 4.0?  I don't know if that is supported.


                            There might be differences in how SWCs are searched for default styles.

                            Once you use spark.components.Button, the defaults.css from the Spark.SWC is

                            examined and the type-selector is added to the output SWC.  If you have

                            another library with a type-selector for spark.components.Button and it is

                            in the wrong order, its type-selector may get overridden by the one from

                            spark.SWC on a property-by-property basis.


                            Maybe you want to create a theme instead?

                            • 11. Re: 4.5.0: style defaults not all getting applied
                              Darrell Loverin Level 4

                              You can't use a defaults.css file to override values in another defaults.css. There is no guarantee on the order in which the defaults.css files from various SWCs will be applied.


                              To override the values of s|Button there are two options I can think of:

                              1. Put your css in a fx:Styles block in the main application.

                              2. Put you css styles in a themes files. Add your themes file to the command line -theme+=myStyles.css




                              • 12. Re: 4.5.0: style defaults not all getting applied

                                Option 2 solved the problem for me.


                                I had a similar issue. Large project that compiles in Flash Builder 4.0 with sdk 4.1.0 with no problems. In Flash Builder 4.5 with sdk 4.6.0, I get (43) warnings about "xxx.swc has style defaults and is in the library path, etc". Not sure if the warnings are actually related to the problem, since they are still there after adding the compiler option. But that's what led me to this thread.


                                Oh and the problem I had was that all embedded fonts were being displayed as TNR. Anyway thanks for the fix.