Flex 2.0.1 Style Swapping

One of the cool new features of Flex 2.0.1 is the ability to compile your style sheets to swf and then do real time style changes of your application. This sample creates 2 style sheet swfs and then uses the StyleManager to swap them.   Full source is available.

changeit.jpg

Click here to run the application

Rich

6 Responses to “Flex 2.0.1 Style Swapping”

  1. ScaleNine Blog » Blog Archive » Flex 2.0.1 Runtime CSS Example Says:

    [...] found a great example by Rich Tretola on how to switch styles at runtime in Flex 2.0.1. I think I might try to put [...]

  2. ScaleNine Blog » Blog Archive » Theme Swapper Says:

    [...] on Rich Tretola’s example mentioned in my last post, I created a Theme Swapper app using the Flex 2.0.1 runtime CSS feature. [...]

  3. everythingflex Says:

    Glad the sample helped, your styles are excellent.

    Rich

  4. murugast Says:

    Hai,
    Its find Great
    But I am getting Follwoing Error
    —–
    Error: Unable to load style(SWF is not a loadable module):
    at MethodInfo-636()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at ::ModuleInfoProxy/::moduleEventHandler()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at ::ModuleInfo/initHandler()

    Murugan

  5. murugast Says:

    Hai
    I Have tried the vith the Source proivide also i am getting the following error

    Error: Unable to load style(Error #2124: Loaded file is an unknown type. URL: file://D/NewStyleDec/bin/style2.css): style2.css.
    at MethodInfo-636()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at ::ModuleInfoProxy/::moduleEventHandler()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at ::ModuleInfo/errorHandler()

    I can found the Css files are existing in Bin folder

    can u expalin me what might be the Pblm

    Thanks
    Murugan

  6. Cristian Nica Says:

    Murugast, for that, you must compile CSS to swf. To do that, right click on the css file from the navigator pane and choose compile css to swf.
    If you’ll do that, everithing will be fine

Leave a Reply