Naveen M. Reddy is welcoming U.

Naveen M. Reddy is welcoming U.
Welcome to My Small World.

Sunday, March 14, 2010

Flex:--> Calling a script function.





import mx.events.SliderEvent;
public function handleHS(event:SliderEvent):void{
     //trace(event.value);
     myImage.width = event.value;
}
public function handleVerticalSlider(event:SliderEvent):void{
    myImage.height = event.value;
}
]]>



When the slider is moved, change will occur and then the handleHS function will get called. This is how it is very simple calling the functions in flex.
These functions can be separated by placing them in an another file script file. This is same as separing the javascript file from the HTML page.

this change=""  attribute is for the HSlider similarly there are other attributes called click="" when the link or button is clicked. 
We can see here import statement import mx.events.SliderEvent; s This is how the class files will import when we want to use the classes of other package. Here SliderEvent is the class generated at the backend for the event of HSlider.
We can create a package structure and create a class there and import that class and use the properties of that class in this script tag and any where in other classes.
As I said, ActionScript is based on OOPS concept and we will see many other oops concept in AS.

Flex:--> Layouts and Containers.

There are good number of layouts and containers available in FlexAll layouts, containers, effects and many more components are given in http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html. Examples are also available.

Flex:--> Writing the code in Flex

Write the code in .MXML, .AS files.
When we open MXML, It can be seen in two ways, design and source. On left top corner of editor, we can switch from design view to source view and vice versa.
In designing mode we can drag and drop the components from the Components view, on to the editor. The respective code will be generated in the source.
Source view is to add the functions, to add the properties, to add the binding between the components. These can be done through the design view also. Its our choice to choose the way we want to design and write the code.
Scripting basically is added from the source view.
In the design mode, to adjust the components size or to add any other property, open Appearance view. From here the component can be modified. Click on the component on which you want to edit and change the properties in the Appearance view.

Started Flex

Started learing Flex. Its been around 9 days, started working on flex. Flex Builder is a tool to develop the applications in flex, it is exactly same as Eclipse. Actually It is developed on top of the eclipse and java reflection concepts. It is really a very nice technology to develop rich user interface(RIA).

Flex code can be written in two types of files they are MXML and ActionScipt. MXML is something like mixture of XML and HTML so there is nothing difficult in understanding this MXML. Script files can also be included using the tag , Usually we include the javascript and script files with the script tag.

It is a very powerful tool to develop good looking UI and very secure and also we can develop any type of effects like animation in MXML.

ActionScript (AS) is the main file to write logic's or handling the events or binding the data to components. This is basically an OOPS concept. Whatever we have in java almost all we have in this AS. The way we write the syntax is different but else part is almost all same.