Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

new syntax ... two dots?

New Here ,
May 18, 2009 May 18, 2009

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

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 18, 2009 May 18, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 18, 2009 May 18, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2009 May 18, 2009
LATEST

That's great! thank you both.

sk

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines