开发者

What is the real difference between MXML and ActionScript for mobile?

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 eac开发者_JAVA百科h 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.)


  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜