Archive

Posts Tagged ‘mxml vs actionscript’

MXML : Why i am always getting late, is it from from my heredity ?

May 26, 2009 Leave a comment

Hi very good morning, today i am going to explain about how mxml and actionscript differs from each other and which one is better suits for building flex application. Before we gonna look at which one is best, let me tell one thing that the flex framework is written using actionscript alone, now you would have realized how great actionscript is. but it would not be a surprise to the people who knows that actionscript is object oriented programming language which is used to write a client side business logic and whatever mxml tag we have, we do also have corresponding actionscript class.

you may have doubt that why certain properties which is available either in actionscript or mxml which could not access by other. In order to resolve this conflict i must explain the three tiers of actionscript api. They are follows.

  • Flex framework api
  • Flash player api
  • custom api

Flex framework api

All the controls, containers, managers, effects which resides in the mx package are part of flex framework api and it was written using actionscript.

Flash player api

All the classes which resides in the flash package are part of flash player api. All the core classes and network specific classes of flash player api are part of flash player.

Custom api

All the custom classes which are written using flex framework api as well as flash player are custom api.

Now you would have known why certain properties available in one could not access by other because they are not belong to the same package and they are not belong to same api so some properties available in one may not be available in other.

Come back to our discussion that which one is better suited for web application ?. Both has certain advantages and disadvantages. Using mxml, we can easily layout the controls and design a page but the run time environment of flex application is flash player which doesnt know mxml. so when we compile the mxml component or application, it will be converted to actionscript class and then it will converted in to swf object along with the libraries you have used in mx package when you developed the mxml component or application. therefore the swf object size will be increased and it also have greater impact when loading application.

But this is not the same case for actionscript because it will only reference the classes in flash player so it doesnt need to add any libraries from flex framework api therefore the swf object will be lesser relatively compared to swf object created from mxml. Although creating user interface in actionscript is not preferable way to do, we can easily create user inteface with mxml tag than actionscript. Actionscript is meant for developing client side businees logic and used to define dynamic behavior of components.

In certain cases like custom preloader where we must develop a custom preloader component using actionscript since its loading time will be lesser compared to mxml. So choose wisely which one to use for your component and dont blame mxml it is not its fault but its ancestors.

And finally thank you for reading my post!!!.