深入了解 Flex
你越了解自己在做什么,你就会做得越好。
我想深入了解 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>
这会生成 Actionscript 文件吗? 如果是:我可以看到 .as 文件(如 C++ 中的预处理器)吗?
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++ )?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。 MXML 被转换为 ActionScript 类。您可以通过将 -keep- generated-actionscript 开关添加到项目属性 -> Flex 编译器中的其他编译器参数来查看生成的代码。
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.
另一个很好的参考是 Mike Jones 最近发布的《Developing Flex 4 Components》一书。它在第 4 页提到了将 MXML 编译为 Actionscript,并为 Flex 组件的工作方式提供了坚实的基础。
Another good reference is the recently-released book Developing Flex 4 Components by Mike Jones. It mentions the compilation of MXML to Actionscript on page 4 and provides a solid grounding in how Flex components work.
作为参考,这里有一些深入研究 Flex 编译器的好地方
For reference, here are some good places to digg deep into the Flex Compiler: