Archive

Posts Tagged ‘components’

Custom Components

August 24, 2009 Leave a comment

One of the main uses of MXML components is to extend the functionality of an existing Flex component.

Custom Components are one of the best features of flex.you can create custom components in flex  by creating a new component file

<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:dataProvider>
        <mx:String>United States</mx:String>
        <mx:String>United Kingdom</mx:String>
        <!-- Add all other countries. -->

    </mx:dataProvider>
</mx:ComboBox>
a custom component may look like this.
you can notice that its not an application file and it is just a
combo box,because it can be written only as an component and can be called
in any part of the main
application.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:custom="components.*"
    width="220" height="115"
>

    <custom:CountryComboBox/>
</mx:Application>

the main purpose of using a custom components are its reusablity features.

flex video display

August 2, 2009 Leave a comment

In flex, the video display control lets you play an flv file in to a flex application.

Click here to read the full post………

Flex Icon Button

August 1, 2009 Leave a comment

Setting an Icon in a button, in mxml is pretty easy.

Click here to read the full post………

creating flex components in Actionscript

August 1, 2009 Leave a comment

You can create a component in flex in two ways one with MXML we all know that and the other with Actionscript.The latter is a bit difficult but much more effective when it comes to understanding the code.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”absolute” creationComplete=”initApp()”>
<mx:Script>
<![CDATA[
import mx.controls.Button;
private function initApp():void
{
var mybutton:Button=new Button();
mybutton.label=”hi”;
mybutton.setStyle(“fontSize”,”16″);
this.addChild(mybutton);
}
]]>
</mx:Script>
</mx:Application>

The above example shows how to write an entire button component in AS.The function initApp() is called in the main application as creation complete event.All the you have in your mxml application can be called in your script section.

first you need to declare a variable for the button (var mybutton:Button)  then you need to call the constructor for the component (new Button();)

Note: The properties of the component should can be called using a .(dot) parameter(eg: mybutton.label=”hi”;)with the same name.

were as the style property of the component can be called using setStyle( )

(this.addChild(mybutton);)  in this line we are adding the our component to the container  AddChild();,so that our component is added to the main application.