MXML and ActionScript Correlations
MXML is a powerful way to simplify the creation of user interfaces. In most cases, it is far better to use MXML for layout than to attempt the same thing with ActionScript. ActionScript is far better suited for business logic and data models. However, MXML and ActionScript are not really so different. In fact, MXML actually gets converted to ActionScript during compilation, and the MXML structure can be understood in terms of an ActionScript class. This can be useful because it allows you to better understand how MXML works and how it relates to ActionScript.
Note
Because MXML is compiled into ActionScript, there is no runtime performance difference between components written in MXML and components written in ActionScript. The difference is primarily seen at authoring time. When you're writing a component, you will find there are differences between using MXML and using ActionScript. MXML is usually faster to write than ActionScript, but it also has its limitations. When you need to create something that is dynamic or can be highly parameterized, ActionScript is usually the better approach simply because it gives you greater low-level control. Furthermore, although an MXML component gets converted to an ActionScript class during compilation, it is not possible to customize the constructor for an MXML component. Therefore, if you need to customize the constructor, you must use ActionScript.
When you use an MXML tag to create a component instance, it ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access