Component Based Development in the Flex framework

This was one of the MUST SEE presentations on my list. Building reusable components is a great way to provide customized Flex functionality and I was very excited to actually get a seat in this packed session. There were at least 40 people sitting on the floor!. I took a lot of notes and will make some available below. The slides are a great reference and they are available at: Chafic Kazoun's blog located at http://www.rewindlife.com

Notes below:

Flex Components are reusable components that are self contained. Using component are a proper way to write maintainable applications in Flex. Using components can be a lifesaver for team environments because it helps insulate the impacts of change in component development.

A cheat sheet for starting a new custom component:

  1. Decide on what the component should do
  2. Don't overthink the API just yet
  3. Provide protected data access and limit what can be passed into the component
  4. Finally, decide on the public API

Setting up the component:

  1. The root MXML tag is the base class. This is often a container you use to contain the component.
  2. Next, specific a package through a directory structure.
  3. You MUST reference the Flex mxml namespace.
  4. Using the component in a Flex application means you must import the component and assign it to a namespace.
  5. Treat the component like a black box.

Fun Facts:

  • When you import a component into a Flex application, Flex Builder will find the namespace and give code hints based on the properties of the component.
  • If you make a public bindable, the get and the set are both made binable regardless if the [bindable] directive is on the get or the set declaration.
  • Using past tense events is not good practice. For example, FormChangedEvent is not a good representation, use FormChangeEvent instead.
  • Override the public function clone inside your Event class. The clone should return a new event and provide the setup code for initializing the event.

5226 Views Print Print Comments (0) Flex

Related Blog Entries

There are no comments for this entry.

Add Comment Subscribe to Comments