Copy link to clipboard
Copied
Hello Forum
I came across this line of code in a sample :
var varList:XMLList = flash.utils.describeType(SWFAddressTool)..constant;
Yes there are two dots right before constant. and it works... ? What is this syntax called? Where can I read up on it.
Just trying to learn new things ![]()
Thanks
sk
Copy link to clipboard
Copied
the two dots used here are called a 'decendant operator' and is used to access the parent(s) of an xml object.
you can read more about it in the docs under: Actionscript3.0 language and components>language elements>operators
Copy link to clipboard
Copied
A single dot would attempt to retrieve nodes with the name (or other queries) following the dot which are a direct child of the node adressed.
The double dot would attempt to retrieve nodes with that name which are a descendent at any level of the adressed node.
The second trace uses that double dot to retrieve all the img nodes throughout the document. The first trace would only find img nodes which are a direct descendent of the root node.
var xml:XML = <rootnode>
<slideshow>
<img src="test.jpg" />
</slideshow>
<slideshow>
<img src="test2.jpg" />
<img src="test2.jpg" />
</slideshow>
</rootnode>;
trace( xml.img.length() ); // traces 0
trace( xml..img.length() ); // traces 3
Copy link to clipboard
Copied
That's great! thank you both.
sk
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more