XML class 751
You could also write this code using the tellTarget action. However, if someOther_mc were not
a movie clip, but an object, you could not use the
with action.
tellTarget ("someOther_mc") {
_x = 50;
_y = 100;
gotoAndStop(3);
}
The with action is useful for accessing multiple items in a scope chain list simultaneously. In the
following example, the built-in
Math object is placed at the front of the scope chain. Setting Math
as a default object resolves the identifiers
cos, sin, and PI to Math.cos, Math.sin, and Math.PI,
respectively. The identifiers
a, x, y, and r are not methods or properties of the Math object, but
since they exist in the object activation scope of the function
polar(), they resolve to the
corresponding local variables.
function polar(r) {
var a, x, y;
with (Math) {
a = PI * r * r;
x = r * cos(PI);
y = r * sin(PI/2);
}
trace("area = " +a);
trace("x = " + x);
trace("y = " + y);
}
You can use nested with actions to access information in multiple scopes. In the following
example, the instance
fresno and the instance salinas are children of the instance california.
The statement sets the
_alpha values of fresno and salinas without changing the _alpha value
of
california.
with (california){
with (fresno){
_alpha = 20;
}
with (salinas){
_alpha = 40;
}
}
See also
tellTarget
XML class
Availability
Flash Player 5 (became a native object in Flash Player 6, which improved
performance significantly).
Description
Use the methods and properties of the XML class to load, parse, send, build, and manipulate
XML document trees.
You must use the constructor
new XML() to create an XML object before calling any of the
methods of the XML class.