Actionscript 3 深入Flex

Actionscript 3 深入Flex,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,你越了解自己在做什么,你就会做得越好 我想深入学习Flex。我做了一些简单的事件处理和 你越了解自己在做什么,你就会做得越好 但是我有一个大问题: 编译器做什么?! MXML文件会发生什么情况 假设我们有一个简单的代码(来自blogflexexamples的代码): 麦考尔先生{ swatchPanelStyleName:myCustomSwatchPanelStyleName; } .myCustomSwatchPanelStyleName{ 背景颜色:卤蓝; } 这会生成Actionsc

你越了解自己在做什么,你就会做得越好

我想深入学习Flex。我做了一些简单的事件处理和 你越了解自己在做什么,你就会做得越好

但是我有一个大问题:

编译器做什么?! MXML文件会发生什么情况

假设我们有一个简单的代码(来自blogflexexamples的代码):


麦考尔先生{
swatchPanelStyleName:myCustomSwatchPanelStyleName;
}
.myCustomSwatchPanelStyleName{
背景颜色:卤蓝;
}
这会生成Actionscript文件吗?
如果是的话,我能看到.as文件(比如C++中的预处理器)吗?< /P> < P>是的。MXML被转换为ActionScript类。通过将-keep generated actionscript开关添加到Project properties->Flex compiler中的其他编译器参数,您可以看到生成为代码。

以下是深入了解Flex编译器的一些好地方:

  • (with)-显示如何将[Bindable]转换为actionscript
  • (with)-自定义编译器处理方式的很棒的代码
  • -他曾是Flex编译器的首席工程师,指出了一些很好的资源
  • -编译器的新资源

另一个很好的参考是Mike Jones最近出版的《开发Flex 4组件》一书。第4页提到了将MXML编译为Actionscript,并为Flex组件的工作方式提供了坚实的基础

看看AdobeDeveloperConnection-
<?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>