Home Tutorial Flex Flex-components Flex custom components

 
 

Share on Google+Share on Google+
Flex custom components
Posted on: July 13, 2010 at 12:00 AM
Advertisement
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

Action Script custom components
You can create custom components by define Action Script class.
 
Package in Action Script 3
Package is the collection of related classes. Package describe the directory structure of your component of your application
 
Advertisement

Related Tags for Flex custom components:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 13, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com