views:

139

answers:

1

It's coming from this line of code:

var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == nNode.parent().@question_questionID)[0];

nNode is an XML node sent as an argument to the function this is called in. The code runs, and does everything expected but the compiler sends out that warning. Do I have some formatting issue?

P.S. I've tried telling it that it's XML like this:

var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == XML(nNode).parent().@question_questionID)[0];

but I still get the warning.

+2  A: 

I don't know how it's actually implemented, but I would guess something in the XML filtering does something with it under the hood. A quick solution would be to pull the code in question out of the filtering scope, eg.:

var questionIDToFind:String = nNode.parent().@question_questionID;
XMLTemplate.template.component.section.question.(@question_questionID == questionIDToFind)[0];

If you're curious you can read more about the Filtering operator on pages 62-63 of the ECMAScript for XML (E4X) Specification

Robert Bak
WOW doesn't that whole thing just look like a fascinating read? I hate creating a variable to use once and throw away, but you are right, it does prevent the compiler warning.
invertedSpear
I would guess the warning has something to do with the way resolving E4X queries inside the filter queries is implemented. And I'm starting to suspect it uses something that's related to Actionscript 2, for compatibility maybe? AS2 XML didn't have the "parent()" method.
Robert Bak
Wow, Great call!
Tyler Egeto