Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Friday, August 22, 2008

Deciding to create components in MXML or ActionScript

"picked up from Adobe Developer guide"

One of the first decisions that you must make when creating custom components is deciding whether to write them in MXML or in ActionScript. Ultimately, it is the requirements of your application that determine how you develop your custom component.

Some basic guidelines include the following:

  • MXML components and ActionScript components both define new ActionScript classes.
  • Almost anything that you can do in a custom ActionScript custom component, you can also do in a custom MXML component. However, for simple components, such as components that modify the behavior of an existing component or add a basic feature to an existing component, it is simpler and faster to create them in MXML.
  • When your new component is a composite component that contains other components, and you can express the positions and sizes of those other components using one of the Flex layout containers, you should use MXML to define your component.
  • To modify the behavior of the component, such as the way a container lays out its children, use ActionScript.
  • To create a visual component by creating a subclass from UIComponent, use ActionScript.
  • To create a nonvisual component, such as a formatter, validator, or effect, use ActionScript.
  • To add logging support to your control, use ActionScript.
Post a Comment