Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the advantages of using mxml over actionscript in a flex application?

they both seem to accomplish the same things with different syntax, whats the point of using two different technologies. Please highlight every possible benefit of using mxml. Also are there scenarios when one is more beneficial than the other and why.

Please clarify this runtime behavior of mxml vs AS3 as discussed in Oreilly Flex 4 Cookbook page 1:

" Many newcomers to Flex wonder how MXML and ActionScript relate to one another. The MXML compiler (mxmlc), after parsing through the different idioms, translates them into the same objects, so that this:

<s:Button id="btn" label="My Button" height="100"/>

and this:

var btn:Button = new Button();
btn.label = "My Button";
btn.height = 100;

produce the same object. The major difference is that while creating that object in ActionScript (the second example) creates the button and nothing else, creating the object in MXML adds the button to whatever component contains the MXML code. The Flex Framework handles calling the constructor of the object described in MXML and either adding it to the parent or setting it as a property of the parent. "

like image 881
timmaktu Avatar asked Feb 25 '23 22:02

timmaktu


1 Answers

Usually,

  • MXML is used to build the user interface
  • ActionScript is used to code the logic of your application

Of course, you can also build the user interface with ActionScript but :

  • it will take you more time
  • MXML views are easier to read than AS views

In terms of user interface, ActionScript should be used only to manage view elements (add, remove, ...) at runtime.

like image 146
Florian F Avatar answered Apr 28 '23 03:04

Florian F