Re: [Flashcoders] E4X question: counting number of subnodes
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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
You can use elements() (and attributes()) to avoid getting the error, i.e. trace(Full games: + games.game.(elements(user).length() == 3).length()); Kenneth Kawamoto http://www.materiaprima.co.uk/ 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 justgame/ 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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
I meant attribute() - attribute() and attributes() are quite different things ;) Kenneth Kawamoto http://www.materiaprima.co.uk/ On 26/08/2010 11:41, Kenneth Kawamoto wrote: You can use elements() (and attributes()) to avoid getting the error, i.e. trace(Full games: + games.game.(elements(user).length() == 3).length()); Kenneth Kawamoto http://www.materiaprima.co.uk/ 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 justgame/ 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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
Thank you for the pointers, I'll read up on child() and attribute() - I've missed them in the docs somehow ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] crossdomain.xml and loadPolicyFile
Yup, works now! http://weber10.ws-wr.com/EM/armyIMV2010/swf/main.swf _ _ _ Erik Mattheis Senior Web Developer Minneapolis T 952 346 6610 C 612 377 2272 Weber Shandwick Advocacy starts here. PRWeek Global Agency Report Card 2009 - Gold Medal Winner The Holmes Report Global Agency of the Year PR News Agency of the Year ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders