适用于移动设备的 MXML 和 ActionScript 之间的真正区别是什么?

发布于 2024-10-08 12:16:09 字数 372 浏览 6 评论 0原文

Adobe 建议在 Flex Hero 移动应用程序中对外观和 ItemRenderer 使用 ActionScript。我的印象是 MXML 被编译为 ActionScript。

  1. 当我在 MXML 中声明组件时,幕后究竟发生了什么?

  2. as3创建的对象和MXML创建的对象到底有什么区别?

  3. 如果我将 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.

  1. What exactly is going on behind the scenes when I declare a component in MXML?

  2. What exactly are the differences between the objects created by as3 and those created by MXML?

  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

芸娘子的小脾气 2024-10-15 12:16:09
  1. 当我在 MXML 中声明组件时,幕后究竟发生了什么?

你关心正确。 MXML 被编译成 ActionScript。您可以使用 keep 编译器参数来查看此 ActionScript。它可能会变得非常复杂。手工编写的代码要优雅得多。我想这就是 Adob​​e 告诉我们使用 AS 作为移动皮肤的原因。

  1. 这些对象之间到底有什么区别
    由 as3 创建的以及由
    MXML?

如果您指的是内存中的对象,则没有区别。 MXML 组件是类,就像 ActionScript 组件一样。但是,如果您使用 MXML 生成 ActionScript,则正在运行的实际组件将具有不同的代码库。

  1. 如果我将 MXML 组件转换为 as3 类(即添加每个子组件)
    并为每个孩子设置每个属性
    手动在代码中而不是在
    声明性 MXML 语法)我有收获吗
    有什么吗?

您可以更精细地控制组件的工作和操作方式。我为 InsideRIA 写了一篇关于这个主题的文章:http: //insideria.com/2010/05/7-reasons-to-write-in-actionsc.html

(目前我没有实际的
要测试的设备,并且没有
我的桌面性能下降
使用 MXML ItemRenderers 时的计算机
对于包含数百个项目的列表。)

需要澄清的是,您意识到基于列表的类仅呈现屏幕上的内容,对吧?因此,即使您的列表有数百个项目,它很可能一次只显示 5-10 个。这意味着仅创建 5-10 个渲染器。滚动列表是模拟的,而不是真实的。渲染器只是改变它们的数据。无论如何,我试图表达的观点是,包含数百个项目的列表应该与包含十个项目或包含一千个项目的列表具有相同的效率。我希望您会在桌面和设备上看到截然不同的性能。

  1. What exactly is going on behind the scenes when I declare a component in MXML?

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.

  1. What exactly are the differences between the objects
    created by as3 and those created by
    MXML?

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.

  1. 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?

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

(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.)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文