MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 227

Components language reference
Table of Contents

Advertisement

For XML and ActionScript objects, you can also specify a string that contains an ActionScript
path. An ActionScript path contains the names of fields separated by dots (for example,
).
"a.b.c"
You can also specify an array of strings as a location. Each string in the array "drills down"
another level of nesting. You can use this technique with both XML and ActionScript data.
(See Example 2 below.) When used with ActionScript data, an array of strings is equivalent to
use of an ActionScript path; that is, the array
If you specify an object as the location, the object must specify two properties:
. The
property is an array of strings, as discussed above, except that one or more
indices
path
of the specified strings may be the special token
, there must be a corresponding index item in
path
indices are used to index into arrays. The index item can be any EndPoint object. This type of
location can be applied to ActionScript data only—not XML. (See Example 3 below.)
Example
Example 1: This example uses an XPath expression to specify the location of a node named
in an XML object:
zip
var sourceEndPoint = new mx.databinding.EndPoint();
var sourcObj = new Object();
sourceObj.xml = new XML("<zip>94103</zip>");
sourceEndPoint.component = sourceObj;
sourceEndPoint.property = "xml";
sourceEndPoint.location = "/zip";
Example 2: This example uses an array of strings to "drill down" to a nested movie clip
property:
var sourceEndPoint = new mx.data.binding.EndPoint();
// Assume movieClip1.ball.position exists.
sourceEndPoint.component = movieClip1;
sourceEndPoint.property = "ball";
// Access movieClip1.ball.position.x.
sourceEndPoint.location = ["position","x"];
Example 3: This example shows how to use an object to specify the location of a data field in
a complex data structure:
var city = new Object();
city.theaters = [{theater: "t1", movies: [{name: "Good,Bad,Ugly"},
{name:"Matrix Reloaded"}]}, {theater: "t2", movies: [{name: "Gladiator"},
{name: "Catch me if you can"}]}];
var srcEndPoint = new EndPoint();
srcEndPoint.component = city;
srcEndPoint.property = "theaters";
srcEndPoint.location = {path: ["[n]","movies","[n]","name"], indices:
[{constant:0},{constant:0}]};
is equivalent to
["a","b","c"]
. For each occurrence of this token in
"[n]"
. As the path is evaluated, the
indices
.
"a.b.c"
and
path
EndPoint.location
225

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents