
I made a couple of small updates to BindMax today (read about them at the bottom of the post). I’ve been using it myself for several projects and it has easily become one of my favorite self-made tools. It’s been been rock solid and serving me very well and I feel like more people should be using it. But maybe you don’t know what it improves upon? Let me help you.
Data binding is essentially tha synchonization of values, typically between the model and the views (read more here. For Flex applications data binding is typically accomplished with the [Bindable] compiler meta tag. For pure AS3 applications it’s been a roll-your-own world and some even use [Bindable] here as well. This is just wrong.
These are the reasons why BindMax is better than [Bindable]:
- Mobile loving
Building mobile apps with AIR? Then you know it’s all about squeezing file size out and performace in. BindMax is an implementation of the observer pattern, which is a much simpler structure than the Flash Event bus. In fact it’s beautiful minimalism compared the Events. Smaller file size, better performance. - Speed!
For primitive data types BindMax is generally 3x faster than [Bindable]. Performance with complex data types obviously depends on how fast your compare functions are, if you have any. Without them, complex data types propagate just as fast as the primitve ones. The speed tests are included with the source so check for yourself! - Early type checking
A data binding is usually defined early in the application run cycle. When that happens, BindMax will evaluate each attempt to bind a property or setter against the data type of the binding and throw an error if the data types don’t match. With [Bindable], you get no errors until the target property/setter for that binding is used. For a property that is used only rarely, you may never even see that error until the client/user stumbles over that rare use case and tells you. - Boot time property/getter/setter name validation on both sides of data binding
Just as with type checking, BindMax validates that that the names match between the property or setter you bind a property or getter to. - Easy custom compare functions for complex and custom data types
Primitive data type values like numbers and strings are easy to compare. Complex data types like arrays, dictionaries and custom objects require special handling. For this scenario, BindMax provides setCompareFunction which lets you pass it a function reference to a custom function that takes two instances of the same class and returns true if they are equal. - Optional automatic binding disposal
To play nice with the garbage collector, BindMax lets you turn on automatic disposal of bindings which are no longer in use. When the last target for a binding is removed, BindMax will dispose of it. - Previous value retrieval
BindMax stores the last value of each binding so you can retrieve it with retrieveLast if for comparison with the new value. The typical use case for this functionality is an animated image gallery where animation direction is determined based on image index vs previous image index. I’m sure you can think of several others. - Powerful reset function
With the reset function, you can reset any or all of the bound properties to their default values (value of the property when the binding was defined). A quick call to reset followed by propagateAll will effectively reset you application. - Propagation forcing
There are times when checking if a value is in fact changed simply doesn’t make sense. Then you wanna be sure that a value spreads to you application each time it is set, even if hasn’t changed. BindMax lets you override change detection on a per-update or per-property basis.
So go get it! At Google Code
NOTE: From now on I will be talking mostly about BindMax instead of it’s little brother BindLite. I’m leaving BindLite in the source in case someone finds it useful, but BindMax is much more verastile by not being an all static access class.
I’ve also updated the BindMax tutorial
The updates I made were the following:
- Added reset all functionality when calling reset without arguments
- Added setForcedPropagation function
- Added propagateAll function
- Removed outdated example project

