Does this behave?

games.game.child("user").(length()  == 3).length()



On 26/08/2010 11:00, Alexander Farber wrote:
Hello fellow flashcoders,

I'm still struggling with my e4x problem. With Kenneth's
help I've got it partly working for the cases
where each game has at least 1 user node:

   var games:XML =
    <games>

      <game>
        <user/>
        <user/>
        <user/>
      </game>

      <game>
        <user/>
        <user/>
      </game>

      <game>
        <user/>
        <user/>
      </game>

    </games>;

   trace("All games: " + games.game.length());
   trace("Full games: " + games.game.user.(length() == 3).length());
   trace("Vacant games: " + games.game.user.(length()<  3).length());

This works well. But once I have a game with no user's,
i.e.<game></game>  or just<game/>  it fails with runtime error:

   ReferenceError: Error #1065: Variable user is not defined.

I know, that when using e4x you're first supposed to test
for a game.user.length()!=0 before referencing a user node.

But how do you do it in this case, when I'm trying to count total numbers?

Thank you
Alex
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to