tags:

views:

32

answers:

2

Hi, griends! Somewhere in code i have decalred variable:

[Bindable]
var nameWin:String = "";

after this i have an e4x statement

podContent.xml_m = xml_m.item.(nameWin=="necessary name");

that should compare item's namewin with "necessary name" and return only items whose nameWin matches with "necessary name".

xml_m.item:

  <item>
    <nameWin>necessary name</nameWin>
    <nameCol>Брутто-премия начисленная</nameCol>
    <date>2009 Май</date>
    <summa>259267.7976</summa>
  </item>
  <item>
    <nameWin>unnecessary name</nameWin>
    <nameCol>Брутто-премия начисленная</nameCol>
    <date>2010 Апрель</date>
    <summa>104.3254</summa>
  </item>
  <item>
    <nameWin>necessary name</nameWin>
    <nameCol>Брутто-премия начисленная</nameCol>
    <date>2010 Май</date>
    <summa>21.5174</summa>
  </item>

if I use in statement xml-child distinct of nameWin (summa, e. g.), it works good. But with nameWin, e4x compares local variable nameWin (which not interested for me at all at this time) with "necessary name" instead of compare item's nameWin with "necessary name".

Any ideas? Versions of libraries can be reason?

A: 

E4X is working as designed in this case as ANY actionscript statement can be evaluated in those parenthesis. Considering your situation you can either rename you variable OR use the attribute method which I think goes like this:

podContent.xml_m = xml_m.item.attribute("nameWin")=="necessary name";

I may be a little off with my syntax but this is pretty close to what you want.

invertedSpear
It is not seems to be work... It statement will return boolean I think. But thanks for answer;-)
semen
+1  A: 

Try this:

podContent.xml_m = xml_m.item.(elements("nameWin")[0]=="necessary name");
Sophistifunk
thanks a lot! it really works
semen