Well not exactly bigger in terms of file size, but since BindLite was taken it had to be BindMax for its brother. BindLite was released earlier this year as a flex-less, event-less alternative to data binding in AS3. But whereas BindLite is a static class suitable for smaller projects, I quickly realized that to make it more usable, it could no longer be all static. Enter BindMax.
BindMax does exactly the same as BindLite does but with the added flexibility of being an instance. The recommended approach is to extend it for your Model class. Example:
public class MyModel extends BindMax {
public var state:String = State.INPUT;
public var captureDelay:uint = 0;
public var capturePhase:String;
public var currentSwf:SwfVO;
public var error:ErrorVO;
public var render:BitmapData;
}
This is all you need for BindMax to do its magic. Your model class need no additional code, not even a constructor. As the superconstructor is implicitly called, BindMax will auto-enumerate all public variables and accessors as bindable with the correct data type for you. Explicitly calling the superconstructor lets you set the autoEnumerate argument to false if you wish to prevent this behaviour.
After this, all is the same as with BindLite with the exception that you need access to the MyModel instance. I recommend providing this acces through a dependency injection-driven framework such as RobotLegs.
Examples of use:
// Binding a property to a public property or setter on view
model.bind( "state", view );
// Property name needs to be passed as string, so using enums is recommended
model.bind( Bindable.STATE, view );
// Changing a property and propagate the change if value is different
model.update( Bindable.STATE, "main" );
// Changing a model property and force propagation
model.update( Bindable.STATE, "main", true );
// Resetting model properties to their values at define time
model.reset( Bindable.STATE, Bindable.FILE );
// Removing a data binding. Omit the second argument to unbind target from all data bindings
model.unbind( view, Bindable.STATE );
// Retrieve the before-change value of a bindable property
model.retrieveLast( Bindable.STATE );
// Control what happens when last target unbinds from a property
// true : Discard orphaned bindings
// false : retain orphaned bindins (default)
model.autoDisposeBindings = true;
Download BindLIte and BindMax as a combined package here: http://code.google.com/p/bindlite/
Docs are here: http://www.oyvindnordhagen.com/bindlite/docs/


