Tag Archive for 'Flex'

DistinctArrayCollection extends ArrayCollection

Newest Update: Please read “GroupingCollection -> HierarchicalCollectionView” for a(nother/ better) solution to this problem.

Previous Update: Please read “Distinct Data Providers with GroupingCollection” for a solution.

Have you ever needed to display distinct items from an ArrayCollection based on a property of the objects in the collection? Here’s an example. An ArrayCollection populates a DataGrid with a list of people displaying the following properties: name, job and position. Beside the DataGrid you would like to display a distinct list of the jobs and positions from the data provider.

Continue reading ‘DistinctArrayCollection extends ArrayCollection’

Flex Part 03: The ModelLocator

The ModelLocator is an Action Script Class that is stored in the model directory.

This is a concept used in every Cairngorm application (see here for example) but you don’t need the Cairngorm library in your project to use it. In fact, you don’t need to know anything about Cairngorm to get started.

About the name

The ModelLocator holds instances of Model Objects, making them easy to locate and accessible from anywhere in the application.

Benefits of using the ModelLocator

The ModelLocator will make Flex development easier and more enjoyable. Here’s how: All application data will be stored in one single place, accessible from anywhere in the application at any time. That one place is, of course, the ModelLocator.

Continue reading ‘Flex Part 03: The ModelLocator’

Flex Part 02: Value Objects & Model Objects

Value Objects

Value Objects are ActionSrcipt classes which are stored in the project’s vo directory.

Think of a Value Object as a row in a database table. Let’s imagine a table named
schools with columns for name, phone, address and ranking. Imagine also a related table of students.

Table: schools (one school has many students)
+------------+---------------+
| Field      | Type          |
+------------+---------------+
| id         | Number        |
| name       | String        |
| phone      | String        |
| address    | String        |
| ranking    | Number        |
+------------+---------------+

Table: students
+------------+---------------+
| Field      | Type          |
+------------+---------------+
| id         | Number        |
| school_id  | Number        |
| name       | String        |
+------------+---------------+

Each row in the schools database table will have several properties which effectively describe a single School. The properties of a School contain simple values: strings, numbers, dates etc. This is the essence of a Value Object (VO).

Continue reading ‘Flex Part 02: Value Objects & Model Objects’

Flex Charting: Per-Item Fills

Get the Flash Player to see this player.

(Flex Charting is now Flex Data Visualization.)

Interested in how this was accomplished? Flex application located at the bottom of the post.

Continue reading ‘Flex Charting: Per-Item Fills’

Flex Part 01: Structure

The Flex Project Directory Structure

Structuring your code into manageable chunks is critical your sanity and the success of your project over time. The directory structure that you use will be largely influenced by the structural framework that you choose to employ (such as Cairngorm or PureMVC). I make a basic assumption throughout this series that readers will be using a Model View Controller (MVC) structure.

A Basic MVC Directory Structure


FlexProjectName <- Generated by Flex Builder
- libs
- src
— com
—- domain <- Replace with domain, ex: tsclausing
—– project <- Replace with project name, ex: blogdemo
—— control
—— model
——– vo
—— views
- Main.mxml <- Your default application file

This is a great place to begin your applications. We will not be using any structural framework libraries for quite some time in this series while still utilizing this directory structure. Other folders may exist at the same level as src and libs which are generated by Flex Builder when a new project is created. I won’t be focusing on those here.

Continue reading ‘Flex Part 01: Structure’