« Swiz framework - Custom Metadata Processor | Main | UiBinder : a simple way to build Widget from XML markup »

Binding improvement

Since Flex 2, the Adobe Flex sdk's contain a class named BindingManager, unfortunately it's not documented in the released ASDoc, but this class it's really helpful to us to manage and debug all kind of binding inside our applications.


BindingManager.debugBinding:
Using the static method provided by the manager you will enable the debug for the property passed as parameter for the method like this:

BindingManager.debugBinding( "myComponent.propertyToDebug" )

Now when you lunch your application in debug mode, you can see in the console something like this:
Binding: destString = myComponent.prpertyToDebug, srcFunc result = First value
Binding: destString = myComponent.prpertyToDebug, error = TypeError: Error #1009: Cannot access a property or method of a null object reference.
Binding: destString = myComponent.propertyToDebug, srcFunc result = Changed value

BindingManager.setEnabled:
Another very handy method can be the setEnabled. By using this static method you will enable or disable all bindings for a specified component or document:

BindingManager.setEnabled( yourComponent, true );


Discover all bindinded properties of a component:
From Flex 2 all documents property of the displayObject components have a non-null public _bindingsByDestination variable, containing the binding instances currently executed for the specified component.
So if you iterate inside the document._bindingsByDestination by String you will access to the "myComponent.bindedProperty":


use namespace mx_internal;

for (var binding:String in myComponent.document._bindingsByDestination)
{
trace( binding );

//And to access the to the binding instance use this:
var myBinding:Binding = myComponent.document._bindingsByDestination[ binding ];
}

This can be accessible only if you specify the use namespace mx_internal.

TrackBack

TrackBack URL for this entry:
http://blog.comtaste.com/mt-tb.cgi/119

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on June 7, 2010 4:39 PM.

The previous post in this blog was Swiz framework - Custom Metadata Processor.

The next post in this blog is UiBinder : a simple way to build Widget from XML markup.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33