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
Re: [Flashcoders] E4X question: counting number of subnodes
Hello Kenneth and others, On Thu, Aug 19, 2010 at 9:05 PM, Kenneth Kawamoto kennethkawam...@gmail.com wrote: trace(Full games: + games.game.(user.length() == 3).length()); trace(Vacant games: + games.game.(user.length() 3).length()); thank you - now my Flash code is working, but my Flex code is still not working and I've already spent several days on it. Here is the test case (a copy and screenshot are at http://stackoverflow.com/questions/3517298/flex-listening-for-collectionevent-in-custom-component ) Games.mxml (my component, trying to use e4x): ?xml version=1.0 encoding=utf-8? mx:VBox xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:my=* mx:Script ![CDATA[ private var _xlist:XMLList; public function get xlist():XMLList { return _xlist; } public function set xlist(x:XMLList):void { _xlist = x; trace(111: + _xlist.toString()); trace(222: + _xlist.game.toString()); list.dataProvider = x; all.text = All games: + _xlist.game.length(); full.text = Full games: + _xlist.game.(user.length() == 3).length(); vacant.text = Vacant games: + _xlist.game.(user.length() 3).length(); } private function gameLabel(item:Object):String { return game: + it...@label; } ]] /mx:Script mx:Label id=all text=All games/ mx:Label id=full text=Full games/ mx:Label id=vacant text=Vacant games/ mx:List id=list labelFunction=gameLabel/ /mx:VBox MyTest.mxml: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:my=* mx:Script ![CDATA[ import mx.events.*; private function changeXML1():void { games = games game label=1 user/ user/ user/ /game game label=2 user/ user/ /game game label=3 user/ user/ user/ /game /games; } private function changeXML2():void { games = games game label=A user/ user/ user/ /game game label=B user/ user/ /game game label=C /game /games; } ]] /mx:Script mx:XML id=games games game label=X user/ user/ /game game label=Y user/ user/ /game /games /mx:XML mx:Button label=Change XML 1 click=changeXML1()/ mx:Button label=Change XML 2 click=changeXML2()/ my:Games xlist={games.game}/ /mx:Application It prints empty list for the
[Flashcoders] E4X question: counting number of subnodes
Hello, my server delivers XML data over socket, representing games, with up to 3 players in each. In my custom component I'd like to display a summary: total number of games, number of full games (3 players) number of vacant games (joinable, because less than 3 players). I've prepared a reduced test case demonstrating my problem: 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()); It prints wrong results for the 2 last calculations: All games: 3 Full games: 0 Vacant games: 7 And a warning: Warning: 1060: Migration issue: The method length is no longer supported. Use the length property of the argument instead.. Please advise me Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
Hi, I am not sure you can count the sub-nodes without having some sort of differentiator between parent nodes. You might have to loop through the list of games to find how many users are in each one as your tests for 2 3 are returning the total number of user nodes in the tree. You can test your e4x stuff quite nicely here: http://www.linkwerk.com/pub/javascript/e4x/e4x-tester/ Glen Alexander Farber wrote: Hello, my server delivers XML data over socket, representing games, with up to 3 players in each. In my custom component I'd like to display a summary: total number of games, number of full games (3 players) number of vacant games (joinable, because less than 3 players). I've prepared a reduced test case demonstrating my problem: 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()); It prints wrong results for the 2 last calculations: All games: 3 Full games: 0 Vacant games: 7 And a warning: Warning: 1060: Migration issue: The method length is no longer supported. Use the length property of the argument instead.. Please advise me Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
Yeah you should add attributes to your game nodes to seperate them: var games:XML = games game id=1 user/ user/ user/ /game game id=2 user/ user/ /game game id=3 user/ user/ /game /games; then you can use E4X to find the actually amount of users in each game: **Pseudo Code** games.game(@id == 1).user.length(); Nathan Mynarcik nat...@mynarcik.com 254.749.2525 www.mynarcik.com On Thu, Aug 19, 2010 at 1:18 PM, Glen Pike postmas...@glenpike.co.ukwrote: Hi, I am not sure you can count the sub-nodes without having some sort of differentiator between parent nodes. You might have to loop through the list of games to find how many users are in each one as your tests for 2 3 are returning the total number of user nodes in the tree. You can test your e4x stuff quite nicely here: http://www.linkwerk.com/pub/javascript/e4x/e4x-tester/ Glen Alexander Farber wrote: Hello, my server delivers XML data over socket, representing games, with up to 3 players in each. In my custom component I'd like to display a summary: total number of games, number of full games (3 players) number of vacant games (joinable, because less than 3 players). I've prepared a reduced test case demonstrating my problem: 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()); It prints wrong results for the 2 last calculations: All games: 3 Full games: 0 Vacant games: 7 And a warning: Warning: 1060: Migration issue: The method length is no longer supported. Use the length property of the argument instead.. Please advise me Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] E4X question: counting number of subnodes
May be this is what you after? trace(Full games: + games.game.(user.length() == 3).length()); trace(Vacant games: + games.game.(user.length() 3).length()); // Trace Full games: 1 Vacant games: 2 Kenneth Kawamoto http://www.materiaprima.co.uk/ Alexander Farber wrote: Hello, my server delivers XML data over socket, representing games, with up to 3 players in each. In my custom component I'd like to display a summary: total number of games, number of full games (3 players) number of vacant games (joinable, because less than 3 players). I've prepared a reduced test case demonstrating my problem: 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()); It prints wrong results for the 2 last calculations: All games: 3 Full games: 0 Vacant games: 7 And a warning: Warning: 1060: Migration issue: The method length is no longer supported. Use the length property of the argument instead.. Please advise me Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] asfunction passing a Number as x,x ??
this is a strange one for asfunction i'm constructing my a function call like this productVariations += pa href='asfunction:_parent.itemOverlay,+product+,+i+'I'd like to view this/a/p; to pass 2 dynamic variables - product and i - to the itemOverlay function but if i run function itemOverlay(product:Number, variation:Number) { trace (product: +product+ variation: +variation); } i get a trace of product: 0,0 variation: undefined so the asfunction call is passing 0,0 to the first (Number) variable leaving no more arguements for the second one what did i do wrong? hope you can help obie ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] asfunction passing a Number as x,x ??
asfunction only allows one parameter to be passed to the invoked function. You can split the argument using the delimiter (comma in your case). simplified version for readability 'asfunction:itemOverlay,value1,value2,value3,value4' itemOverlay() { var args:Array = arguments[0].split(,); var len:Number = args.length; for(var i=0; ilen; i++) { trace(args[i]); } } To make a clear destinction between the function and arguments, you could use a different delimiter, as in: 'asfunction:itemOverlay,value1|value2|value3|value4' And use arguments[0].split(|) to get the values. regards, Muzak - Original Message - From: Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED] To: flashcoders flashcoders@chattyfig.figleaf.com Sent: Friday, May 25, 2007 3:01 PM Subject: [Flashcoders] asfunction passing a Number as x,x ?? this is a strange one for asfunction i'm constructing my a function call like this productVariations += pa href='asfunction:_parent.itemOverlay,+product+,+i+'I'd like to view this/a/p; to pass 2 dynamic variables - product and i - to the itemOverlay function but if i run function itemOverlay(product:Number, variation:Number) { trace (product: +product+ variation: +variation); } i get a trace of product: 0,0 variation: undefined so the asfunction call is passing 0,0 to the first (Number) variable leaving no more arguements for the second one what did i do wrong? hope you can help obie ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] asfunction passing a Number as x,x ??
oh wow - thankyou very much On 25 May 2007, at 14:27, Muzak wrote: asfunction only allows one parameter to be passed to the invoked function. You can split the argument using the delimiter (comma in your case). simplified version for readability 'asfunction:itemOverlay,value1,value2,value3,value4' itemOverlay() { var args:Array = arguments[0].split(,); var len:Number = args.length; for(var i=0; ilen; i++) { trace(args[i]); } } To make a clear destinction between the function and arguments, you could use a different delimiter, as in: 'asfunction:itemOverlay,value1|value2|value3|value4' And use arguments[0].split(|) to get the values. regards, Muzak - Original Message - From: Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED] To: flashcoders flashcoders@chattyfig.figleaf.com Sent: Friday, May 25, 2007 3:01 PM Subject: [Flashcoders] asfunction passing a Number as x,x ?? this is a strange one for asfunction i'm constructing my a function call like this productVariations += pa href='asfunction:_parent.itemOverlay,+product+,+i+'I'd like to view this/a/p; to pass 2 dynamic variables - product and i - to the itemOverlay function but if i run function itemOverlay(product:Number, variation:Number) { trace (product: +product+ variation: +variation); } i get a trace of product: 0,0 variation: undefined so the asfunction call is passing 0,0 to the first (Number) variable leaving no more arguements for the second one what did i do wrong? hope you can help obie ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Re: [Flash_ActionScript] Digest Number 1512
You should probably try to post this in the flashcoders forum. A lot more help available there. [EMAIL PROTECTED] wrote: There is 1 message in this issue. Topics in this digest: 1a. Re: Set Visibility For Next/Prev Buttons From: Bad Aegis Message 1a. Re: Set Visibility For Next/Prev Buttons Posted by: Bad Aegis [EMAIL PROTECTED] badaegis Date: Mon Apr 2, 2007 3:17 pm ((PDT)) --- In [EMAIL PROTECTED], Shara [EMAIL PROTECTED] wrote: I'm working on a flash project that scrolls through pages of text pullef from an external source. I would like to have the next button invisible once it reaches the last page. Similarly, I want the previous button to be invisible on the first page. I've tried creating a buttonVisibility function but I end up with one button or the other (sometimes both) off or on permanently. Any help you can offer would be greatly appreciated. Thanks in advance. this.nxtBtn_mc._visible = true; var totalPages:Number = n; //total number of pages, could be pulled from an array if this Number is dynamic. var currentPage:Number = n; //current page # pulled from ext. file function hideNext():Void { if(currentPage == totalPages) { this.nxtBtn_mc._visible = false; } else { this.nxtBtn_mc._visible = true; } } Hope that helps. My scripting leaves much to be desired... Messages in this topic (3) Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/Flash_ActionScript/ * Your email settings: Digest Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/Flash_ActionScript/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] flv playback version number
Hello list. I updated flash 8 with the update mpx. Supposedly I should have gotten the 1.0.1 version of the FLV Playback component. http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=3acdb2ff The problem is that when I trace out the version I get: version: 1.0.0.103 Anyone else run into this issue? I downloaded the mpx Restarted flash Deleted the component from library Deleted aso files Restarted flash again Added the component back Same version number ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] assigning properties to Number vs Objects
/* QUESTION: Why can I assign a property to number value created with Number constructor, but CANNOT assign a property to a number value create with just a number value? I thought Number was kind of an Object too? Maybe this has something to do with primitive and complex data types? -- Keith H -- */ // Example 1 //Here I define number variable 'a' with the 'Number' constructor, //with the number value 5 as an argument. //I can give variable 'a' the property 'numberProp' and assign a value to it. //- var a = new Number(5); a.numberProp = 20; trace(a +typeof a); trace(a.numberProp == null returns +(a.numberProp==null)); trace(a.numberProp == undefined returns +(a.numberProp==undefined)); trace(a.numberProp returns +a.numberProp); //returns 20 // Example 2 //Here I define number variable 'b' ONLY by assigning a number value. //I give variable 'b' the property 'numberProp' and assign a value to it, //but it's value is traced as undefined. //- var b = 5; b.numberProp = 20; trace(\n\n\n); trace(b +typeof b); trace(b.numberProp == null returns +(b.numberProp==null)); trace(b.numberProp == undefined returns +(b.numberProp==null)); trace(b.numberProp returns +b.numberProp); //returns undefined ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] assigning properties to Number vs Objects
On Feb 18, 2006, at 1:54 PM, keith wrote: Why can I assign a property to number value created with Number constructor, but CANNOT assign a property to a number value create with just a number value? When you use the new operator it returns an object (an instance of the Number class) complete with methods and other properties - a Compex Data Type. If you just assign a number value to a var then you are assigning a Primitive Data Type. var a = new Number(5); var b = 5; trace(typeof(a)); trace(typeof(b)); //traces: //object //number From the manual: [new] Creates a new, initially anonymous, object and calls the function identified by the constructor parameter blue skies, bryan ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Is Not a Number
Run this, once in flash player6-setting, and one time in 7/8, both compiled with as2. The Strong-typing of the parameter doesn't affect the result. But how come this is so indifferent results, was perhaps the output of flsahplayer6 wrong accordingly to ecma? trace(!isNaN(undefined)) / martin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Is Not a Number
Martin Klasson wrote: Run this, once in flash player6-setting, and one time in 7/8, both compiled with as2. The Strong-typing of the parameter doesn't affect the result. But how come this is so indifferent results, was perhaps the output of flsahplayer6 wrong accordingly to ecma? trace(!isNaN(undefined)) That would be pretty old news and was one of the things changed back then. var t; trace(Number(t)); // gives: // 0 in Flash 6 // NaN in Flash 7+ Just like: var s; trace(String(s)); // gives: // in Flash 6 // undefined in Flash 7+ That is, Number- and String-conversion of undefined was changed. So was String-to-Boolean-conversion (non-empty string are alwas true now) and null-to-Number-conversion (null is NaN, not 0) - at least those are the 4 primitive datatype conversion changes that I remember :) It was done in order to conform with the ECMAScript standard, yes. :) -- Morten Barklund - Information Architect - Shockwaved Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark Phone: +45 7027 2227 - Fax: +45 3369 1174 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders