适用于移动设备的 MXML 和 ActionScript 之间的真正区别是什么?
Adobe 建议在 Flex Hero 移动应用程序中对外观和 ItemRenderer 使用 ActionScript。我的印象是 MXML 被编译为 ActionScript。
当我在 MXML 中声明组件时,幕后究竟发生了什么?
as3创建的对象和MXML创建的对象到底有什么区别?
如果我将 MXML 组件转换为 as3 类(即添加每个子组件并在代码中手动设置每个子组件的每个属性,而不是使用声明性 MXML 语法),我会得到什么吗?
(目前我没有实际的设备可供测试,并且当使用 MXML ItemRenderers 处理包含数百个项目的列表时,我的台式计算机上没有性能下降。)
Adobe recommends using ActionScript for skins and ItemRenderers in Flex Hero mobile apps. I was under the impression that the MXML is compiled down to ActionScript.
What exactly is going on behind the scenes when I declare a component in MXML?
What exactly are the differences between the objects created by as3 and those created by MXML?
If I convert a MXML component into an as3 class (i.e. add each child and set each property on each child manually in code instead of in the declarative MXML syntax) am I gaining anything?
(At the moment I do not have an actual device to test on, and there is no performance degradation on my desktop computer when using MXML ItemRenderers for a List with hundreds of items.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你关心正确。 MXML 被编译成 ActionScript。您可以使用 keep 编译器参数来查看此 ActionScript。它可能会变得非常复杂。手工编写的代码要优雅得多。我想这就是 Adobe 告诉我们使用 AS 作为移动皮肤的原因。
如果您指的是内存中的对象,则没有区别。 MXML 组件是类,就像 ActionScript 组件一样。但是,如果您使用 MXML 生成 ActionScript,则正在运行的实际组件将具有不同的代码库。
您可以更精细地控制组件的工作和操作方式。我为 InsideRIA 写了一篇关于这个主题的文章:http: //insideria.com/2010/05/7-reasons-to-write-in-actionsc.html
需要澄清的是,您意识到基于列表的类仅呈现屏幕上的内容,对吧?因此,即使您的列表有数百个项目,它很可能一次只显示 5-10 个。这意味着仅创建 5-10 个渲染器。滚动列表是模拟的,而不是真实的。渲染器只是改变它们的数据。无论如何,我试图表达的观点是,包含数百个项目的列表应该与包含十个项目或包含一千个项目的列表具有相同的效率。我希望您会在桌面和设备上看到截然不同的性能。
You care correct. MXML is compiled down into ActionScript. You can review this ActionScript by using the keep compiler argument. It can get pretty convoluted. Code you write by hand is much more elegant. I assume this why Adobe tells us use AS for mobile skins.
If you mean objects in memory, there is no difference. MXML components are classes just like ActionScript components are. However, if you use MXML to generate ActionScript, then the actual component that is running has a different code base.
You have more granular control over the how the component work and operates. I wrote an article for InsideRIA on this exact topic: http://insideria.com/2010/05/7-reasons-to-write-in-actionsc.html
As a matter of clarification, you realize that list based classes only render what is on the screen, right? So, even if your list has hundreds of items, it is most likely only displaying 5-10 at once. That means that only 5-10 renderers are created. Scrolling through the list is simulated, not real. The renderers just change their data. Anyway, the point I was attempting to make is that a list with hundreds of items should work with the same efficiency as a list with ten items, or a list with a thousand items. I would expect that you'll see very different performance on your desktop and on a device.