R – getting Deep into Flex

actionscript-3apache-flexflex3

The better you understand what you are doing, the better you will do it.

I want to get Deep into Flex . I did some simple Event-Handling and
The better you understand what you are doing, the better you will do it.

But i have i big question:

What does the Compiler do ?!
What happens with the MXML file ?

lets say we have a simple code ( code from blogflexexamples):

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/27/changing-the-flex-colorpicker-controls-swatch-panel-background-color/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        .myColorPicker {
            swatchPanelStyleName: myCustomSwatchPanelStyleName;
        }

        .myCustomSwatchPanelStyleName {
            backgroundColor: haloBlue;
        }
    </mx:Style>

    <mx:Script>
        <![CDATA[
            import mx.events.ColorPickerEvent;

            private function backgroundColor_change(evt:ColorPickerEvent):void {
                var cssObj:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myCustomSwatchPanelStyleName");
                cssObj.setStyle("backgroundColor", evt.color);

                colorPicker.open();
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="backgroundColor:">
                <mx:ColorPicker change="backgroundColor_change(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:ColorPicker id="colorPicker"
            styleName="myColorPicker"
            editable="false" />

</mx:Application>

does this generate an Actionscript file ?
and if it does : Can i see the the .as file ( like preprocessor in C++ )?

Best Answer

Yes. MXML is translated into an ActionScript class. You can see the generated as code by adding -keep-generated-actionscript switch to the Additional compiler arguments in Project properties->Flex compiler.

Related Topic