Archive for January, 2009
Data binding and ActionScript 3
Data binding is really easy to do in MXML. But what do you do if you need to bind some dynamic objects at runtime using ActionScript? Here’s how I solved this particular problem in the following localization example.
Assume you want to add localization to a MenuBar component and the data provider is an Object. Let’s assume, for the sake of this example, that the Object that will act as dataProvider for the MenuBar component looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | private var menu:Array = [ { label: "FILE", children: [ { label: "NEW" }, { label: "OPEN" }, { label: "IMPORT", children: [ { label: "PROJECT" }, { label: "OTHER" } ] }, { type: "separator" }, { label: "EXIT" } ] }, { label: "EDIT", children: [ { label: "UNDO" }, { label: "REDO" }, { type: "separator" }, { label: "CUT" }, { label: "COPY" }, { label: "PASTE" } ] }, { label: "PROJECT", children: [ { label: "BUILD" }, { label: "CLEAN" }, { type: "separator" }, { label: "EXPORT" } ] }, { label: "LANGUAGE", children: [ { label: "ENGLISH", children: [ { label: "AMERICAN" }, { label: "BRITISH" } ] }, { label: "ROMANIAN" } ] } ]; |
Progress
For mrm’s TV Guide I needed a visual representation for displaying progress (i.e., saving data to the local database), so I used the built-in ProgressBar component. What’s nice about this component is that you can use three different methods to update the progress bar. You choose one of the methods by setting the mode property in MXML to one of the following values:
- event The control specified by the
sourceproperty must dispatch progress and completed events. The ProgressBar control uses these events to update its status. The ProgressBar control only updates if the value of thesourceproperty extends the EventDispatcher class - polled The
sourceproperty must specify an object that exposesbytesLoadedandbytesTotalproperties. The ProgressBar control calls these methods to update its status. - manual You manually update the ProgressBar status. In this mode you specify the
maximumandminimumproperties and use thesetProgress()property method to specify the status. This mode is often used when theindeterminateproperty is true
mrm’s TV Guide
Like any respectable person in this world, I don’t watch TV. But I do like some TV shows, so I watch them online or download them from various sources and watch them offline. Lately the number of shows I had to keep track of has grown substantially so I had a hard time doing it. (Actually, I’m just really lame and remembering 8 shows’ air dates is too big an effort for me)
So I had a few days off and I decided to build myself a little Adobe AIR app to help me out with my little problem. So without further ado, here’s the awesomeness of an application which I’ve dubbed “mrm’s TV Guide”:
Pretty Coolâ„¢, ain’t it? Yeah, I know. Now awarded with Softpedia’s “100% Clean” award!

So here’s how it works. Click to continue…
