mr.*_*bio 0 apache-flex flex3 actionscript-3
你越了解自己在做什么,就越能做得更好.
我想深入了解Flex.我做了一些简单的事件处理,你越了解你在做什么,你做得越好.
但我有一个大问题:
编译器做了什么?!MXML文件会发生什么?
假设我们有一个简单的代码(来自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>
Run Code Online (Sandbox Code Playgroud)
这会生成一个Actionscript文件吗?如果是这样的话:我能看到.as文件(就像C++中的预处理器一样)吗?
是.MXML被翻译成ActionScript类.您可以通过将-keep-generated-actionscript开关添加到Project properties-> Flex编译器中的Additional编译器参数来查看生成的代码.