Sometimes it is necessary to display a formatted value such as currency or a percentage in a NumericStepper component, but that is not a default behavior. I need something extremely simple that can be written as:
XML:
-
<mx:CurrencyFormatter id="currencyFormatter"
-
currencySymbol="$"
-
precision="2"/>
-
-
<controls:FormattedStepper formatter="{currencyFormatter}"/>
My internet searches turned up this similar attempt, but it seemed overly complicated (just my opinion). Continue reading to view my attempt at a simple formatted numeric stepper with source. I've also included an example of a custom formatter as well as an item renderer / item editor in a DataGrid.
Continue reading 'FormattedStepper extends NumericStepper'
I work on a lot of charting and data visualization applications. Flex is great for these projects, but what happens when a client wants to use a chart (or any DisplayObject) from the application in a document, presentation, website or email? I needed a way to let users save jpeg and png files to their computers without storing any images on the server. The following solution works with PHP but it should be very simple to duplicate the process for other environments. Continue reading to try it out and view code.
Continue reading 'DisplayObject to JPEG or PNG with IImageEncoder'
This post is a continuation of "Distinct Data Providers with GroupingCollection." The code and example is extremely similar - there are a couple minor changes to accommodate one addition: the use of HierarchicalCollectionView.
What's new?
We saw in the previous post that a GroupingCollection works very well for creating a grouped data provider for an AdvancedDataGrid or even for use in part in a List or ComboBox control. But there's a(nother/ better) way to populate that distinct List or ComboBox from the GroupingCollection. Use a HierarchicalCollectionView. It's a more elegant solution and also lets you use your grouped data to populate a Tree or Menu control! Continue reading to try it out and view code.
Continue reading 'GroupingCollection -> HierarchicalCollectionView'
Update: This post is updated and continued in the next post, "GroupingCollection -> HierarchicalCollectionView." Please see that post for additional (better) suggestions.
This post is itself an update to "DistinctArrayCollection extends ArrayCollection." The old post describes the problem and proposes a solution. I did not post code in that article because I felt like there had to be a better way of doing things. Here's a better way (see the update for a much better way): use the GroupingCollection class in Flex 3. Continue reading to try it out and view code.
Continue reading 'Distinct Data Providers with GroupingCollection'
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'
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'