1.5. Extending Flex

The Flex framework is a feature-rich and robust framework for enterprise RIA development and is often sufficient off the shelf for many simple development tasks. However, it also derives power from the fact that it can be extended and customized with ease.

1.5.1. Creating Custom Components

Creating custom components is likely to be one of the most frequent tasks you will indulge in the moment you start building complex and enterprise-grade RIAs. Sometimes, the motivation behind custom component development is to create reusable pieces of code for productivity enhancements and sometimes it is for feature enhancement and modified component behavior.

The simplest use case for custom components is the aggregation of specific components at one place or the aggregation of certain component types and data. For example, you may see benefit in creating a component that includes a ComboBox that has East, West, and Central as its values. Such a custom ComboBox could be used readily in sales and marketing applications that classify data by regions within the United States. The code for this kind of a ComboBox would be as follows:

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="0xFFFFFF"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] public var regions:ArrayCollection = new ArrayCollection( [ {label:"East", data:1}, {label:"West", data:2}, {label:"Central", data:3} ]); ]]> </mx:Script> ...

Get Professional BlazeDS: Creating Rich Internet Applications with Flex® and Java® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.