3 Replies Latest reply on Nov 6, 2007 5:40 AM by Den.James

    Flex Newbie, Need some help

    Den.James
      Hey all!

      I am a complete newbie to Flex, but after the release of Flex Builder to students, I figured I would give it a shot as a less expensive option to Flash.

      In the past I would do dynamic frontends for recreation centers with flash. The idea was to allow them as much freedom with the design as possible. Part of this was allow some shapes and colors to be determined after the script was compiled by the user.

      Can Flex support changing the color of the background, for example, after the script is compiled? My ultimate goal is to use ActionScript to draw most of the design, can it do this in Flex, and how?

      Thanks!
      -James
        • 1. Re: Flex Newbie, Need some help
          Gregory Lafrance Level 6
          You can change the background color of containers with the backgroundColor style. You can change the background color of many conponents as well, with similar or identical styles. Just look up a component in the FB2 help and examine the styles.
          • 2. Flex Newbie, Need some help
            Karl_Sigiscar_1971 Level 3
            Hi James,

            When I read your post, two things spring in my mind: runtime skinning and programmatic skinning.

            Here is an example of runtime skinning:

            <mx:Script>
            <![CDATA[

            import mx.styles.StyleManager;

            public function applyRuntimeStyleSheet(styleDcl:String):void {
            StyleManager.loadStyleDeclarations(styleDcl)
            }

            ]]>
            </mx:Script>


            <mx:Button id="b1" label="Skin 1" click="applyRuntimeStyleSheet('themes/skin1/skin1.swf')"/>
            <mx:Button id="b2" label="Skin 2" click="applyRuntimeStyleSheet('themes/skin2/skin2.swf')"/>
            <mx:Button id="b3" label="Skin 3" click="applyRuntimeStyleSheet('themes/skin3/skin3.swf')"/>

            Under the themes folder, there is a subdirectory for each skin. In each subdirectory, there is:

            - A SWF file with the skin assets
            - A CSS file for the skin
            - The compiled version of the CSS file (a SWF too). Type mxmlc skinStyle.css in the command line to get skinStyle.swf

            This is the latter SWF that is passed as a parameter to the applyRuntimeStyleSheet() method.

            Concerning programmatic skinning, you can do one of two things:

            1- Create a MXML file whose root node is of the type you want to extend (e.g Box) and override the updateDisplayList() method() to draw something as you would in Flash using ActionScript.

            2- Creating your own component from scratch by creating an AS class and extending the UIComponent class (which means you will have to implement a number of methods of the IUIComponent interface).

            Regards,
            Karl.
            • 3. Re: Flex Newbie, Need some help
              Den.James Level 1
              Ok, that would be a possibility, but what I really wanted to do was use something comparable to the Draw functions in flash.

              The entire window is completely procedural, nothing has been compiled before hand into a 'skin'. Is this what you mean by programmatic skinning?