Binding
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Classpath: | mx.data.binding.Binding |
| File last modified: | Tuesday, 18 December 2007, 15:44:38 |
Defines an association between two endpoints, a source and a destination.
The Binding object listens for changes to the source endpoint, and copies the
data to the destination endpoint each time the source changes.
The Binding object listens for changes to the source endpoint, and copies the
data to the destination endpoint each time the source changes.
Summary
Constructor
- Binding (source:Object, dest:Object, format:Object, is2way:Boolean)
- Initializes a new Binding object.
Class properties
- counter : Number
- screenRegistry : Object
- bindingRegistry : Array
Instance properties
Class methods
- dispatchEnterFrame
- getRuntimeObject (info:Object, constructorParameter:Object)
- refreshFromSources (component:Object, property:String, bindings:Array) : Array
- refreshDestinations (component:Object, bindings:Array)
- okToCallGetterFromSetter
- copyBinding (b:mx = .data.binding.Binding)
- copyEndPoint (e:mx = .data.binding.EndPoint)
- registerScreen (screen, id)
- registerBinding (binding)
- getLocalRoot (clip)
Instance methods
- execute (reverse:Boolean) : Array
- Fetches the data from the source, formats it, and assigns it to the destination.
- queueForExecute (reverse)
- Queues the binding for execution at a safe time.
- calcShortLoc (endpoint)
- summaryString (reverse:Boolean)
- setUpListener (endpoint, reverse)
- setUpIndexListeners (endpoint, reverse)
- if there are components which are indexes for this endpoint,
Constructor
Binding
function Binding (
source:Object,
dest:Object,
format:Object,
is2way:Boolean)
Initializes a new Binding object. Registers the Binding
as a listener for the 'data changed' event of the source endpoint.
as a listener for the 'data changed' event of the source endpoint.
Parameters:
source:
The source endpoint of the binding. This parameter is nominally of type
"EndPoint", but in fact it can be any actionscript object that has the required fields.
"EndPoint", but in fact it can be any actionscript object that has the required fields.
dest :
The destination endpoint of the binding. This
must not be a constant. The 'event' field of the destination is only
needed if the binding is 2-way.
must not be a constant. The 'event' field of the destination is only
needed if the binding is 2-way.
format:
[optional] An object containing formatting information. The properties of this object are:
- cls : class
- an actionscript class which implements the interface mx.data.binding.Formatter.
- className : String
- a string containing the name of an actionscript class which implements the interface mx.data.binding.Formatter
- settings : Object
- an object whose properties are option settings for the formatter
cls and className contain the same information, and you can give one or the other of these, but not both.
The difference is that cls is an actual reference to the class, whereas className is the name of
the class as a string. If you choose to give the class name as a string, you must also reference that class directly somewhere
in actionscript code - this reminds Flash to include a copy of the class in your SWF. Examples:
{cls: com.mycompany.MyFormatter, settings: {precision: 3, separator: ","}}
{className: "com.mycompany.MyFormatter", settings: {precision: 3, separator: ","}}
is2way:
[optional] A boolean which is true if the binding is bi-directional.
Returns:
- The Binding object that was just created. You don't need to keep a reference to
this object - it will keep itself alive as long as needed.Warning: after creating a Binding, do not modify the fields of the objects
that were passed as parameters to the constructor. The results will be unpredictable.
Example:
-
new Binding ( {constant: "abc123"}, {component: _root.Screen1.serviceCall1, property: "params", location: "password"}); foo = new Binding ( {component: myServiceCall1, property: "results", event: "result"}, {component: myDisplayText1, property: "text"}, {cls: com.mycompany.SpecialFormatter}, true); src = new mx.data.binding.EndPoint(); src.component = myXmlDocument; src.property = "results"; src.event = "result"; new mx.data.binding.Binding (src, {component: myComboBox, property: "dataProvider"}); src.location = "something"; // This line won't work! Do it *before* calling 'new Binding'
Class properties
bindingRegistry
static bindingRegistry:Array = new Array()
(read)
counter
static private counter:Number = 0
(read)
screenRegistry
static private screenRegistry:Object = new Object()
(read)
Instance properties
dest
dispatchEvent
private dispatchEvent:Function
(read)
format
is2way
private is2way:Boolean
(read)
num
private num:Number
(read)
queued
private queued:Boolean = false
(read)
reverse
private reverse:Boolean = false
(read)
source
sub
private sub:Array
(read)
Class methods
copyBinding
static private function copyBinding (
b:mx = .data.binding.Binding)
copyEndPoint
static private function copyEndPoint (
e:mx = .data.binding.EndPoint)
dispatchEnterFrame
static private function dispatchEnterFrame (
)
getLocalRoot
static function getLocalRoot (
clip)
getRuntimeObject
static function getRuntimeObject (
info:Object,
constructorParameter:Object)
okToCallGetterFromSetter
static function okToCallGetterFromSetter (
)
refreshDestinations
static function refreshDestinations (
component:Object,
bindings:Array)
refreshFromSources
static function refreshFromSources (
component:Object,
property:String,
bindings:Array) : Array
registerBinding
static function registerBinding (
binding)
registerScreen
static function registerScreen (
screen,
id)
Instance methods
calcShortLoc
private function calcShortLoc (
endpoint)
execute
function execute (
reverse:Boolean) : Array
Fetches the data from the source, formats it, and assigns it to the destination.
Validates the data and causes either a 'valid' or 'invalid' event to be emitted by
the destination and source components. Data is assigned to the destination even
if its invalid, unless the destination is read-only.
Validates the data and causes either a 'valid' or 'invalid' event to be emitted by
the destination and source components. Data is assigned to the destination even
if its invalid, unless the destination is read-only.
Parameters:
reverse:
A boolean which is true if the binding is to be executed in the
reverse direction (dest -> source).
reverse direction (dest -> source).
Returns:
- any error messages that were generated as a result of the assignment. These are either
queueForExecute
private function queueForExecute (
reverse)
Queues the binding for execution at a safe time.
Returns:
- none
setUpIndexListeners
private function setUpIndexListeners (
endpoint,
reverse)
if there are components which are indexes for this endpoint,
set up a listener so that we can re-evaluate the binding
when the index changes.
set up a listener so that we can re-evaluate the binding
when the index changes.
setUpListener
private function setUpListener (
endpoint,
reverse)
summaryString
private function summaryString (
reverse:Boolean)