Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Setting Default Styles

One aspect of component distribution via a SWC has to do with CSS styling. If your component has a default set of styles, you need to provide a process by which these can be accessed; otherwise, if left up to the implementer of your component, he may forget to do it or not be aware that it requires certain CSS properties to display properly by default. To avoid this, you can include a special type of CSS file within your SWC. This file is special, not because it contains anything sophisticated compared to a normal CSS file used in Flex, but because of its name. You see the compiler is pretty clever in Flex, and it has certain directives it scans through and executes if the required criteria are present (in this case, the default CSS values for your components).

It probably comes as no surprise that the CSS file is called defaults.css. By default, the Flex framework has a defaults.css that provides all the CSS values for the Flex components, and this is applied to the components at compile time. You can create a local version of this for use with your components and, when your SWC is compiled within a Flex project, the compiler looks to see if there are any default styles for them and applies those values to your components.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint