没有 Flex 框架/组件的 MXML
Flex 编译器可以编译不包含任何 Flex 组件字节码的“纯 AS3”SWF 文件。 那么,
是否可以创建一个自定义组件框架(用于代替 Flex 框架),该框架仍然可以使用 MXML(阅读:标记)进行可视化布局,并编译为 SWF,而不依赖于 Flex 框架本身?
The Flex compiler can compile "pure AS3" SWF files that don't contain any Flex Component bytecode. So,
Would it be possible to create a custom component framework (used in place of the Flex Framework), that can still be visually laid out using MXML (read: markup), and compiled down to a SWF without any dependencies on the Flex Framework itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是可能的。 您的 MXML 文件本质上只是指定类的不同方式。 您可以通过编译项目并向
mxmlc
提供-compiler.keep- generated-actionscript=true
来查看 mxml 文件归结为哪些内容。bar.mxml:
用
mxmlc -compiler.keep- generated-actionscript=true bar.mxml
编译后,变成下面的样子。生成/栏生成.as:
Yes, it's possible. Your MXML files are essentially just a different way to specify classes. You can see what mxml files boil down to by compiling your project and providing
-compiler.keep-generated-actionscript=true
tomxmlc
.bar.mxml:
After compiling with
mxmlc -compiler.keep-generated-actionscript=true bar.mxml
, it turns into the following.generated/bar-generated.as:
有两种不同的编译器:一种用于将 ActionScript 代码编译为 AVM 字节码,另一种 (mxmlc) 将 MXML 文件编译为 ActionScript 代码,然后由第一个编译器依次编译。 如果您想查看生成的 AS3 代码,请将“-keep”参数传递给 MXML 编译器。
理论上可以按照你的建议去做。 我的猜测是,mxmlc 很大程度上依赖于 UIComponent 类的功能,因此您可能需要对 mxmlc 进行一些修改,这样它就不会在非 UIComponent 类上呕吐。 即便如此,由于 [Bindable] / 数据绑定之类的东西使用了 Flex 框架功能(而不是普通的 Flash Player / AVM 功能),您将重写大量代码。
There are two different compilers: one that is used for compiling ActionScript code to AVM bytecode and another (mxmlc) that compiles MXML files into ActionScript code which is then in turn compiled by the first compiler. If you want to see what AS3 code is generated, pass the "-keep" parameter to the MXML compiler.
In theory it's possible to do what you suggest. My guess is that mxmlc keys heavily into features from the UIComponent class, so you'd probably have to hack on mxmlc a bit so that it didn't puke on non-UIComponent classes. Even still, since things like [Bindable] / data binding make use of Flex framework features (not plain Flash Player / AVM features) you would be rewriting an awful lot of code.