Archive for the ‘Basic’ Category

Move child of container anywhere

December 20, 2009 Leave a comment

Are you the one who faced tough times when you had to move child of container somewhere else than the position it has to be laid out and ended up using Canvas container . Consider the scenario, you have a VBox container and it contains three children. Now if you would like to position third child wherever you click within the container. Is it possible unless it is a canvas container ?. If you say, we cant, still it has logic as we all know the container and it sub-classes layout the component based on its layout behavior and it wont bent down as we wish to place the control.

But its certainly possible. Set the includeInLayout property of child (you want  to move around) to false and set the x and y position of child by invoking move method on the child control. It will be laid out as we intended. The reason behind the trick is, if you make the includeInLayout property of the control to false, it wont be considered when the container lays out the children and it will leave you to take care of the positioning of control. Thats how it works, got it ???.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" creationComplete="onInit()" layout="vertical">


            protected function  onInit():void
                container.addEventListener(MouseEvent.CLICK, onMouseClick);

            protected function onMouseClick(event : MouseEvent):void
                floatMe.move(event.localX, event.localY);


    <mx:VBox id="container"  width="350" height="150" backgroundColor="#FFFFFF"
        borderStyle="solid" horizontalScrollPolicy="off" verticalScrollPolicy="off">
        <mx:Button id="floatMe" label="Wanna place me here" includeInLayout="false" />


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!!!.

Origins of flex application

May 25, 2009 Leave a comment

Hi folks!!!, we do always compare between flex and flash as they are two other technologies and we always thinking that what we cant do in flash that can do by flex. Here the conclusion for the people who have still doubts about the differences between flash and flex.

There is nothing flash cant do, that flex can do. Both flex and flash application will be compiled in to .swf object and the flash player (run time environment of .swf) will execute swf file with th help of AVM2 (ActionScript virtual machine). So the only difference is the way you are creating application and not how it behaves.

In fact, root application of any flex application is System manager which is responsible for managing and handling flex application. It itself subclass of flash.display.movieclip which is a one of the class in flash which will have timeline and the timeline in turn will have many frames which will contain the content to display when the user runs.

But in flex, the system manager will have only two frames and they are preloader & flex application. When application starts executing, the system manager will create an instance of preloader and the preloader will start loading flex application & run time shared libraries. Once it has been loaded, the preloader will notify the system manager & the system manager will create an instance to main flex application. The application will initialize and layout the child components and once it has been done its task, the application will notify the preloader which will notify the system manager. At last the system manager will remove the preloader from its display list and will add flex application in display list.

You are developing flex application whether using flex or flash, after compilation it will be in form of .swf (to be precise it will be in the form of byte code) which will be executed by flash player which doesn’t know neither flash nor flex, but it knows how to interpret byte code and it executes flex and flash based applications.