Flex custom components


 

Flex custom components

In the Flex 3 development, User can create custom components using mxml or ActionScript

In the Flex 3 development, User can create custom components using mxml or ActionScript

Custom Flex Components:

In the Flex 3 development, User can create custom components using mxml or ActionScript. In this example user can see mxml custom component. The purpose to create custom components in the Flex application is easy to develop, reusability, maintainability. User create these components if application require these custom components. Custom components functionality of the Flex provide us for break up your code with in Flex application into sub parts of the application. We can create custom components in both  mxml and Action Script. In this example we have create a button bar custom component. First we will create a custom component and after using namespace we will used it. The main purpose is to create custom components for your specific application requirements.

Example:-

buttonbar.mxml code:

<?xml version="1.0"?>

<mx:ButtonBar xmlns:mx="http://www.adobe.com/2006/mxml" borderStyle="solid" horizontalGap="5">

<mx:dataProvider>

<mx:String>Submit</mx:String>

<mx:String>Login</mx:String>

<mx:String>Register</mx:String>

</mx:dataProvider>

</mx:ButtonBar>

We have create a ButtonBar component and create a data provider for it after that we have create application using this component.

mainapplication.mxml code:

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:CustComp="custocumponent.*">

<CustComp:buttonbar/>

</mx:Application>

In the mainapplication.mxml, we have used buttonbar custom component with namespace prefix CustComp. The namespace prefix told you to look for the file that implements custom components and tag name corresponds to the file name of the components. In this example we have create a package that hold buttonbar.mxml custom component and mainapplication.mxml  that define Flex application.

Output:-

Download this code

Ads