Re: [Flashcoders] Simplify XML Call
I don't even know why I'm responding to this, but. Ktu gave you the answer yet you seemed to ignore it? You don't need an eval at all. function getNumItems(level:int, xml:XML):int{ var levelXML:XML = xml.menu; for(var i:int = 0; i level; i ++){ levelXML = levelXML.item[whichItems[level]]; } return levelXML.length(); } does exactly what this would do, if AS3 had an eval: var j:String = xml.menu.item[whichItems[0]]; var k:String = new String(); var l:int = level; while (l--) { k += .item[whichItems[ + String(l) + ]]; } totalItems = (j + k); Taka On Sat, Aug 13, 2011 at 7:17 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: And here's another recursive function example for XML, slightly different, with a more complex structure, showing how to get all values from some attributes in an XML file (in this case, firstName and lastName), no matter where or how deep they lie: var peopleXML:XML = people person firstName=Bob lastName=Smith person firstName=Timmy lastName=Smith / person firstName=Jenny lastName=Jones person firstName=Sal lastName=Stephens / /person person firstName=Marcia lastName=Marquez person firstName=Julio lastName=Rogers/ /person /person person firstName=Tom lastName=Williams person firstName=Mary lastName=Jones / person firstName=Albert lastName=Denniston person firstName=Barney lastName=Elmington / person firstName=Campo lastName=Fatigua person firstName=Harpo lastName=Oprah/ /person person firstName=Hugo lastName=Boss person firstName=Benny lastName=Elkins/ person firstName=Sheri lastName=Downing/ /person /person /person person firstName=Marcia lastName=Marquez person firstName=Manny lastName=Peterson/ /person person firstName=Joe lastName=Merritt/ /people; function recurseXML(xml:*):void { var xmlList:XMLList = xml.children(); for each (var currentNode:* in xmlList) { trace(currentNode.@firstName+ +currentNode.@lastName); if(currentNode.children()) recurseXML(currentNode); } } recurseXML(peopleXML); //Traces: Bob Smith Timmy Smith Jenny Jones Sal Stephens Marcia Marquez Julio Rogers Tom Williams Mary Jones Albert Denniston Barney Elmington Campo Fatigua Harpo Oprah Hugo Boss Benny Elkins Sheri Downing Marcia Marquez Manny Peterson Joe Merritt Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Saturday, August 13, 2011 9:58 PM To: Flash Coders List Subject: RE: [Flashcoders] Simplify XML Call Then I think I hit on what Jason was suggesting: Not really. :) I think you're over complicating this. This is all I was suggesting you do from my original suggestion, it's pretty straightforward (this is a test case you could copy paste and run): //DUMMY DATA: var myXML:XML = data functionalarea type=amountKeying backgroundImage=images/background.png exercises exercise type=NoviceRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem fileURL=myImages/myFile5.png invertedFileURL=myImages/myFileInverted5.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile6.png invertedFileURL=myImages/myFileInverted6.png legible=false amount=342132 / keyingItem fileURL=myImages/myFile7.png invertedFileURL=myImages/myFileInverted7.png legible=true amount=78400 / /keyingItems /exercise
Re: [Flashcoders] Simplify XML Call
errr... function getNumItems(level:int, xml:XML):int{ var levelXML:XML = xml.menu; for(var i:int = 0; i level; i ++){ levelXML = levelXML.item[whichItems[i]]; } return levelXML.length(); } On Sun, Aug 14, 2011 at 1:24 AM, Taka Kojima t...@gigafied.com wrote: I don't even know why I'm responding to this, but. Ktu gave you the answer yet you seemed to ignore it? You don't need an eval at all. function getNumItems(level:int, xml:XML):int{ var levelXML:XML = xml.menu; for(var i:int = 0; i level; i ++){ levelXML = levelXML.item[whichItems[level]]; } return levelXML.length(); } does exactly what this would do, if AS3 had an eval: var j:String = xml.menu.item[whichItems[0]]; var k:String = new String(); var l:int = level; while (l--) { k += .item[whichItems[ + String(l) + ]]; } totalItems = (j + k); Taka On Sat, Aug 13, 2011 at 7:17 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: And here's another recursive function example for XML, slightly different, with a more complex structure, showing how to get all values from some attributes in an XML file (in this case, firstName and lastName), no matter where or how deep they lie: var peopleXML:XML = people person firstName=Bob lastName=Smith person firstName=Timmy lastName=Smith / person firstName=Jenny lastName=Jones person firstName=Sal lastName=Stephens / /person person firstName=Marcia lastName=Marquez person firstName=Julio lastName=Rogers/ /person /person person firstName=Tom lastName=Williams person firstName=Mary lastName=Jones / person firstName=Albert lastName=Denniston person firstName=Barney lastName=Elmington / person firstName=Campo lastName=Fatigua person firstName=Harpo lastName=Oprah/ /person person firstName=Hugo lastName=Boss person firstName=Benny lastName=Elkins/ person firstName=Sheri lastName=Downing/ /person /person /person person firstName=Marcia lastName=Marquez person firstName=Manny lastName=Peterson/ /person person firstName=Joe lastName=Merritt/ /people; function recurseXML(xml:*):void { var xmlList:XMLList = xml.children(); for each (var currentNode:* in xmlList) { trace(currentNode.@firstName+ +currentNode.@lastName); if(currentNode.children()) recurseXML(currentNode); } } recurseXML(peopleXML); //Traces: Bob Smith Timmy Smith Jenny Jones Sal Stephens Marcia Marquez Julio Rogers Tom Williams Mary Jones Albert Denniston Barney Elmington Campo Fatigua Harpo Oprah Hugo Boss Benny Elkins Sheri Downing Marcia Marquez Manny Peterson Joe Merritt Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Saturday, August 13, 2011 9:58 PM To: Flash Coders List Subject: RE: [Flashcoders] Simplify XML Call Then I think I hit on what Jason was suggesting: Not really. :) I think you're over complicating this. This is all I was suggesting you do from my original suggestion, it's pretty straightforward (this is a test case you could copy paste and run): //DUMMY DATA: var myXML:XML = data functionalarea type=amountKeying backgroundImage=images/background.png exercises exercise type=NoviceRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem fileURL=myImages/myFile5.png invertedFileURL=myImages/myFileInverted5.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile6.png invertedFileURL=myImages/myFileInverted6.png
Re: [Flashcoders] Simplify XML Call
From: Taka Kojima t...@gigafied.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Sunday, August 14, 2011 4:24 AM Subject: Re: [Flashcoders] Simplify XML Call function getNumItems(level:int, xml:XML):int{ var levelXML:XML = xml.menu; for(var i:int = 0; i level; i ++){ levelXML = levelXML.item[whichItems[level]]; } return levelXML.length(); } I modified your code to correct an oversight or two like this: private function getNumItems(level, xml):int { var levelXML:XMLList = xml.menu; for(var i:int = 0; i level - 1; i ++) { levelXML = levelXML.item[whichItems[i]] as XMLList; trace(String(levelXML)); } return levelXML.length(); } The problem here is that it traces null because you can't convert a string into an XMLList and, of course, you can't assign a string to an XMLList either, which is why I tried the conversion. (I also tried casting levelXML as a wildcard with the same result: null.) Regarding Jason's code, private function countItems(xmlNode:XML):void { var total:int = 0; var xmlChildren:XMLList = xmlNode.children(); if(xmlChildren.length() 0) { for each (var xmlNode:XML in xmlChildren) { total++; countItems(xmlNode); //The recursive call } } trace(totalItems2: , total); } it doesn't do what I need. What I need it to target a specific sequence of nodes. Let's suppose I have the following xml: data item label![CDATA[Bracelets]]/label item label![CDATA[Hook Bracelets]]/label item label![CDATA[one]]/label /item item label![CDATA[two]]/label item label![CDATA[three]]/label /item /item /item /data Perhaps it would clarify things to state I'm building a drop-down menu. So the client mouses over Bracelets. Out pops Hook Bracelets. She mouses over that and out pops one and two. In order to accomplish this, I need to discover which node is being moused over, in this case: item[0].item[0] but clearly it could just as easily be: item[46].item[27] and I could care less about the rest of the tree. Having said as much, my revised code: var x:*; x = xml.menu.item[whichItems[0]]; var levelsLeft:int = level - 2; var q:int; while(levelsLeft--) { q++; x = x.item[whichItems[q]]; } trace('xxx', x.item.length()); does, in fact, appear to work :)) Thanks again, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Simplify XML Call
What I need it to target a specific sequence of nodes. You can do that with my function as well - just pass in the sequence you want to target. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Sunday, August 14, 2011 9:40 AM To: Flash Coders List Subject: Re: [Flashcoders] Simplify XML Call From: Taka Kojima t...@gigafied.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Sunday, August 14, 2011 4:24 AM Subject: Re: [Flashcoders] Simplify XML Call function getNumItems(level:int, xml:XML):int{ var levelXML:XML = xml.menu; for(var i:int = 0; i level; i ++){ levelXML = levelXML.item[whichItems[level]]; } return levelXML.length(); } I modified your code to correct an oversight or two like this: private function getNumItems(level, xml):int { var levelXML:XMLList = xml.menu; for(var i:int = 0; i level - 1; i ++) { levelXML = levelXML.item[whichItems[i]] as XMLList; trace(String(levelXML)); } return levelXML.length(); } The problem here is that it traces null because you can't convert a string into an XMLList and, of course, you can't assign a string to an XMLList either, which is why I tried the conversion. (I also tried casting levelXML as a wildcard with the same result: null.) Regarding Jason's code, private function countItems(xmlNode:XML):void { var total:int = 0; var xmlChildren:XMLList = xmlNode.children(); if(xmlChildren.length() 0) { for each (var xmlNode:XML in xmlChildren) { total++; countItems(xmlNode); //The recursive call } } trace(totalItems2: , total); } it doesn't do what I need. What I need it to target a specific sequence of nodes. Let's suppose I have the following xml: data item label![CDATA[Bracelets]]/label item label![CDATA[Hook Bracelets]]/label item label![CDATA[one]]/label /item item label![CDATA[two]]/label item label![CDATA[three]]/label /item /item /item /data Perhaps it would clarify things to state I'm building a drop-down menu. So the client mouses over Bracelets. Out pops Hook Bracelets. She mouses over that and out pops one and two. In order to accomplish this, I need to discover which node is being moused over, in this case: item[0].item[0] but clearly it could just as easily be: item[46].item[27] and I could care less about the rest of the tree. Having said as much, my revised code: var x:*; x = xml.menu.item[whichItems[0]]; var levelsLeft:int = level - 2; var q:int; while(levelsLeft--) { q++; x = x.item[whichItems[q]]; } trace('xxx', x.item.length()); does, in fact, appear to work :)) Thanks again, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed
Re: [Flashcoders] Simplify XML Call
From: Henrik Andersson he...@henke37.cjb.net To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Friday, August 12, 2011 1:43 PM Subject: Re: [Flashcoders] Simplify XML Call ActionScript 3 is a compiled language. There is no such thing as an eval function in as 3. Well, that's the crux of my problem, Henrik. How do I get around writing code that adds just the right number of item units without doing it as a string to evaluate or writing a switch statement that's obviously limited? Again, here's my pseudo-code: var j:String = xml.menu.item[whichItems[0]]; var k:String = new String(); var l:int = level; // I don't know this value in advance: it's passed to the class while (l--) { k += .item[whichItems[ + String(l) + ]]; } totalItems = eval(j + k); // eval() doesn't work in AS3, concept from Python TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
Maybe Try var evalJ = eval(j); var evalK = eval(k); totalItems = evalJ + evalK; Evaluate the strings before you combine them? Karl On Aug 13, 2011, at 1:52 PM, John Polk wrote: From: Henrik Andersson he...@henke37.cjb.net To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Friday, August 12, 2011 1:43 PM Subject: Re: [Flashcoders] Simplify XML Call ActionScript 3 is a compiled language. There is no such thing as an eval function in as 3. Well, that's the crux of my problem, Henrik. How do I get around writing code that adds just the right number of item units without doing it as a string to evaluate or writing a switch statement that's obviously limited? Again, here's my pseudo-code: var j:String = xml.menu.item[whichItems[0]]; var k:String = new String(); var l:int = level; // I don't know this value in advance: it's passed to the class while (l--) { k += .item[whichItems[ + String(l) + ]]; } totalItems = eval(j + k); // eval() doesn't work in AS3, concept from Python TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
There is still no eval function. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
From: Henrik Andersson he...@henke37.cjb.net To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Saturday, August 13, 2011 3:37 PM Subject: Re: [Flashcoders] Simplify XML Call There is still no eval function. I know there is no eval fn. Jason Merrill earlier wrote: You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. I tried googling [as3 recursive loop xml node] without much luck. Then I think I hit on what Jason was suggesting: var x:*; x = xml.menu.item[whichItems[0]]; var levelsLeft:int = level - 2; var q:int = 4; while(levelsLeft--) { x = x.item[whichItems[q]]; q--; } trace('xxx', x.item.length()); The problem is that for reasons that don't bear explaining I'm not ready to test this beyond the first level today :-} But I think it (or some tweak) should work (and I'll clean out that wildcard var). Thanks, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Simplify XML Call
Then I think I hit on what Jason was suggesting: Not really. :) I think you're over complicating this. This is all I was suggesting you do from my original suggestion, it's pretty straightforward (this is a test case you could copy paste and run): //DUMMY DATA: var myXML:XML = data functionalarea type=amountKeying backgroundImage=images/background.png exercises exercise type=NoviceRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem fileURL=myImages/myFile5.png invertedFileURL=myImages/myFileInverted5.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile6.png invertedFileURL=myImages/myFileInverted6.png legible=false amount=342132 / keyingItem fileURL=myImages/myFile7.png invertedFileURL=myImages/myFileInverted7.png legible=true amount=78400 / /keyingItems /exercise exercise type=ExpertRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem fileURL=myImages/myFile5.png invertedFileURL=myImages/myFileInverted5.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile6.png invertedFileURL=myImages/myFileInverted6.png legible=false amount=342132 / keyingItem fileURL=myImages/myFile7.png invertedFileURL=myImages/myFileInverted7.png legible=true amount=78400 / /keyingItems /exercise /exercises /functionalarea /data //RECURSIVE FUNCTION: var totalItems:uint = 0; function countItems(xmlNode:XML):void { var xmlChildren:XMLList = xmlNode.children(); if(xmlChildren.length() 0) { for each (var xmlNode:XML in xmlChildren) { totalItems++; countItems(xmlNode); //The recursive call } } } countItems(myXML); //RESULT: trace(totalItems);//Traces 20 - there are 20 nodes in the given XML from the root down. Instead of the root, you could start farther in too if you wanted, i.e.: var exercisesXML:XML = myXML.functionalarea[0].exercises[0]; countItems(exercisesXML); trace(totalItems); //traces 18 - there are 18 nodes from that level down. If that's not exactly what you need, it would seem the general concept could be modified to fit your needs. Hope that helps, Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Saturday, August 13, 2011 5:58 PM To: Flash Coders List Subject: Re: [Flashcoders] Simplify XML Call From: Henrik Andersson he...@henke37.cjb.net To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Saturday, August 13, 2011 3:37 PM Subject: Re: [Flashcoders] Simplify XML Call There is still no eval function. I know there is no eval fn. Jason Merrill earlier wrote: You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. I tried googling [as3 recursive loop xml node] without much luck. Then I think I hit on what Jason was suggesting: var x:*; x = xml.menu.item[whichItems[0
RE: [Flashcoders] Simplify XML Call
And here's another recursive function example for XML, slightly different, with a more complex structure, showing how to get all values from some attributes in an XML file (in this case, firstName and lastName), no matter where or how deep they lie: var peopleXML:XML = people person firstName=Bob lastName=Smith person firstName=Timmy lastName=Smith / person firstName=Jenny lastName=Jones person firstName=Sal lastName=Stephens / /person person firstName=Marcia lastName=Marquez person firstName=Julio lastName=Rogers/ /person /person person firstName=Tom lastName=Williams person firstName=Mary lastName=Jones / person firstName=Albert lastName=Denniston person firstName=Barney lastName=Elmington / person firstName=Campo lastName=Fatigua person firstName=Harpo lastName=Oprah/ /person person firstName=Hugo lastName=Boss person firstName=Benny lastName=Elkins/ person firstName=Sheri lastName=Downing/ /person /person /person person firstName=Marcia lastName=Marquez person firstName=Manny lastName=Peterson/ /person person firstName=Joe lastName=Merritt/ /people; function recurseXML(xml:*):void { var xmlList:XMLList = xml.children(); for each (var currentNode:* in xmlList) { trace(currentNode.@firstName+ +currentNode.@lastName); if(currentNode.children()) recurseXML(currentNode); } } recurseXML(peopleXML); //Traces: Bob Smith Timmy Smith Jenny Jones Sal Stephens Marcia Marquez Julio Rogers Tom Williams Mary Jones Albert Denniston Barney Elmington Campo Fatigua Harpo Oprah Hugo Boss Benny Elkins Sheri Downing Marcia Marquez Manny Peterson Joe Merritt Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Saturday, August 13, 2011 9:58 PM To: Flash Coders List Subject: RE: [Flashcoders] Simplify XML Call Then I think I hit on what Jason was suggesting: Not really. :) I think you're over complicating this. This is all I was suggesting you do from my original suggestion, it's pretty straightforward (this is a test case you could copy paste and run): //DUMMY DATA: var myXML:XML = data functionalarea type=amountKeying backgroundImage=images/background.png exercises exercise type=NoviceRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem fileURL=myImages/myFile5.png invertedFileURL=myImages/myFileInverted5.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile6.png invertedFileURL=myImages/myFileInverted6.png legible=false amount=342132 / keyingItem fileURL=myImages/myFile7.png invertedFileURL=myImages/myFileInverted7.png legible=true amount=78400 / /keyingItems /exercise exercise type=ExpertRDS keyingItems keyingItem fileURL=assets/images/simulations/ATC/atc_701201045.png invertedFileURL=myImages/myFileInverted1.png legible=true amount=78400 / keyingItem fileURL=myImages/myFile2.png invertedFileURL=myImages/myFileInverted2.png legible=false amount=743600 / keyingItem fileURL=myImages/myFile3.png invertedFileURL=myImages/myFileInverted3.png legible=true amount=3213212 / keyingItem fileURL=myImages/amountkeying/myFile4.png invertedFileURL=myImages/myFileInverted4.png legible=true amount=43242323 / keyingItem
Re: [Flashcoders] Simplify XML Call
I appreciate Ktu's efforts here; however, Merrill is right. I've written this: var j:String = xml.menu.item[whichItems[0]]; var k:String = new String(); var l:int = level; while (l--) { k += .item[whichItems[ + String(l) + ]]; } totalItems = (j + k); however this won't work because it's a string. If I were doing this in Python, I'd write something like: totalItems = exec(j + k) and it would execute the string. Does as3 have something comparable? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
ActionScript 3 is a compiled language. There is no such thing as an eval function in as 3. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Simplify XML Call
You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. The function basically checks the XML node to see if it has any children. If it does, it calls itself, passing in the child XML node as an argument, and does the count the node, adding to the _totalItems private class property. The function then does not call itself again if the XML node does not have any children. No switch statement would be needed. Make sense? Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Thursday, August 11, 2011 11:31 AM To: Flash List Subject: [Flashcoders] Simplify XML Call Hi; I have this code: switch (level) { case 2: totalItems = xml.menu.item[whichItem].item.length(); break; case 3: totalItems = xml.menu.item[whichItem].item[whichItem2].item.length(); break; case 4: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item.length(); break; case 5: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item[whichItem4].item.length(); break; } Ugly, I know. How do I write one or two lines that does all that and even better: loops it? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
*UNTESTED*, but this was my thought... var level:int = 5; var xmlItem:* = xml.menu; for (var i:int = 0; i level; i++) { xmlItem = xmlItem.item[this[whichItem + ((i == 0) ? : i)]]; } totalItems = xmlItem.item.length; I am doing this: [whichItem + ((i == 0) ? : i)] because I have no idea where that value comes from or what its for... On Thu, Aug 11, 2011 at 11:48 AM, Merrill, Jason jason.merr...@bankofamerica.com wrote: You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. The function basically checks the XML node to see if it has any children. If it does, it calls itself, passing in the child XML node as an argument, and does the count the node, adding to the _totalItems private class property. The function then does not call itself again if the XML node does not have any children. No switch statement would be needed. Make sense? Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Thursday, August 11, 2011 11:31 AM To: Flash List Subject: [Flashcoders] Simplify XML Call Hi; I have this code: switch (level) { case 2: totalItems = xml.menu.item[whichItem].item.length(); break; case 3: totalItems = xml.menu.item[whichItem].item[whichItem2].item.length(); break; case 4: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item.length(); break; case 5: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item[whichItem4].item.length(); break; } Ugly, I know. How do I write one or two lines that does all that and even better: loops it? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
sorry should have been this: var level:int = 5; var xmlItem:* = xml.menu; for (var i:int = 1; i level; i++) { xmlItem = xmlItem.item[this[whichItem + ((i == 1) ? : i)]]; } totalItems = xmlItem.item.length; On Thu, Aug 11, 2011 at 11:54 AM, Ktu ktu_fl...@cataclysmicrewind.comwrote: *UNTESTED*, but this was my thought... var level:int = 5; var xmlItem:* = xml.menu; for (var i:int = 0; i level; i++) { xmlItem = xmlItem.item[this[whichItem + ((i == 0) ? : i)]]; } totalItems = xmlItem.item.length; I am doing this: [whichItem + ((i == 0) ? : i)] because I have no idea where that value comes from or what its for... On Thu, Aug 11, 2011 at 11:48 AM, Merrill, Jason jason.merr...@bankofamerica.com wrote: You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. The function basically checks the XML node to see if it has any children. If it does, it calls itself, passing in the child XML node as an argument, and does the count the node, adding to the _totalItems private class property. The function then does not call itself again if the XML node does not have any children. No switch statement would be needed. Make sense? Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Thursday, August 11, 2011 11:31 AM To: Flash List Subject: [Flashcoders] Simplify XML Call Hi; I have this code: switch (level) { case 2: totalItems = xml.menu.item[whichItem].item.length(); break; case 3: totalItems = xml.menu.item[whichItem].item[whichItem2].item.length(); break; case 4: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item.length(); break; case 5: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item[whichItem4].item.length(); break; } Ugly, I know. How do I write one or two lines that does all that and even better: loops it? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! -- Ktu;
RE: [Flashcoders] Simplify XML Call
Ingenious idea, but that would be limited to you hard coding the number of levels to go down to. If the XML gets larger and deeper, that function would fail... I think it would be better to check if the node has children, and if so, recursively dig deeper. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ktu Sent: Thursday, August 11, 2011 11:58 AM To: Flash Coders List Subject: Re: [Flashcoders] Simplify XML Call sorry should have been this: var level:int = 5; var xmlItem:* = xml.menu; for (var i:int = 1; i level; i++) { xmlItem = xmlItem.item[this[whichItem + ((i == 1) ? : i)]]; } totalItems = xmlItem.item.length; On Thu, Aug 11, 2011 at 11:54 AM, Ktu ktu_fl...@cataclysmicrewind.comwrote: *UNTESTED*, but this was my thought... var level:int = 5; var xmlItem:* = xml.menu; for (var i:int = 0; i level; i++) { xmlItem = xmlItem.item[this[whichItem + ((i == 0) ? : i)]]; } totalItems = xmlItem.item.length; I am doing this: [whichItem + ((i == 0) ? : i)] because I have no idea where that value comes from or what its for... On Thu, Aug 11, 2011 at 11:48 AM, Merrill, Jason jason.merr...@bankofamerica.com wrote: You just need a recursive loop to do this. So I would write a function that handles each node level individually, adding to a class-level private property called something like, _totalItems. The function basically checks the XML node to see if it has any children. If it does, it calls itself, passing in the child XML node as an argument, and does the count the node, adding to the _totalItems private class property. The function then does not call itself again if the XML node does not have any children. No switch statement would be needed. Make sense? Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of John Polk Sent: Thursday, August 11, 2011 11:31 AM To: Flash List Subject: [Flashcoders] Simplify XML Call Hi; I have this code: switch (level) { case 2: totalItems = xml.menu.item[whichItem].item.length(); break; case 3: totalItems = xml.menu.item[whichItem].item[whichItem2].item.length(); break; case 4: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item.length(); break; case 5: totalItems = xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item[whichItem4].item.length(); break; } Ugly, I know. How do I write one or two lines that does all that and even better: loops it? TIA, John ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders - - This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal
Re: [Flashcoders] Simplify XML Call
While you have the right spirit I think that it would be a better idea to check the length of the array instead. That way you won't accidentally step out of bounds there. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Simplify XML Call
that would be limited to you hard coding the number of levels to go down to - he already had this level var created with whatever number he had intended, I was just giving an example value... If the XML gets larger and deeper, that function would fail... - why would it fail? (assuming that the level var could be whatever you want? it would be a better idea to check the length of the array instead - John didn't indicate that this was a problem of verifying the data, but instead wishing to write the same code in fewer lines. That is what I did. I do agree with you though, that error checking would be good to have. I've changed my code to test creating the string required. This is a TEST to prove that my code would indeed create the referencing desired. var level:int = 5; var str:String = xml.menu for (var i:int = 1; i level; i++) { str += .item[whichItem + ((i == 1) ? : i) + ]; } str += .item.length(); change level to whatever you want and it will produce the same lines of code John reference above. Clearly this doesn't work, but since such little information was given (especially about the 'whichItemX' variables, this was my shot at it. This here is an updated version of it that breaks out a piece to make it a bit cleaner to read: var level:int = n; var xmlItem:* = xml.menu; for (var i:int = 1; i level; i++) { var which:* = this[whichItem + ((i == 1) ? : i)] xmlItem = xmlItem.item[which]; } totalItems = xmlItem.item.length(); John, I think if we are going to be able to help you further we would need more information about how this xml is truly setup, and wher some of these values come from (whichItem, whichItem2..., level) On Thu, Aug 11, 2011 at 12:58 PM, Henrik Andersson he...@henke37.cjb.netwrote: While you have the right spirit I think that it would be a better idea to check the length of the array instead. That way you won't accidentally step out of bounds there. __**_ Flashcoders mailing list Flashcoders@chattyfig.figleaf.**com Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/**mailman/listinfo/flashcodershttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Simplify XML Call
If the XML gets larger and deeper, that function would fail... - why would it fail? (assuming that the level var could be whatever you want? (OK, I am not trying to argue with you here, I promise) Because that's exactly it, if the levels got deeper, you would have to know how deep in order to change the variable - human intervention. Otherwise, if you didn't manually keep the XML in synch with the variable value, it would fail. And how could you know that dynamically without doing a recursive function, which is what I suggested. It gets worse if a system produces the XML. So what would be advantage of your suggestion over mine? Yours would require a manual tweaking of the level variable. A recursive function would not that value to be set at all. And a recursive function could be set to only check down to a certain level if you wanted that, or only check certain specific levels. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ktu Sent: Thursday, August 11, 2011 2:14 PM To: Flash Coders List Subject: Re: [Flashcoders] Simplify XML Call that would be limited to you hard coding the number of levels to go down to - he already had this level var created with whatever number he had intended, I was just giving an example value... If the XML gets larger and deeper, that function would fail... - why would it fail? (assuming that the level var could be whatever you want? it would be a better idea to check the length of the array instead - John didn't indicate that this was a problem of verifying the data, but instead wishing to write the same code in fewer lines. That is what I did. I do agree with you though, that error checking would be good to have. I've changed my code to test creating the string required. This is a TEST to prove that my code would indeed create the referencing desired. var level:int = 5; var str:String = xml.menu for (var i:int = 1; i level; i++) { str += .item[whichItem + ((i == 1) ? : i) + ]; } str += .item.length(); change level to whatever you want and it will produce the same lines of code John reference above. Clearly this doesn't work, but since such little information was given (especially about the 'whichItemX' variables, this was my shot at it. This here is an updated version of it that breaks out a piece to make it a bit cleaner to read: var level:int = n; var xmlItem:* = xml.menu; for (var i:int = 1; i level; i++) { var which:* = this[whichItem + ((i == 1) ? : i)] xmlItem = xmlItem.item[which]; } totalItems = xmlItem.item.length(); John, I think if we are going to be able to help you further we would need more information about how this xml is truly setup, and wher some of these values come from (whichItem, whichItem2..., level) On Thu, Aug 11, 2011 at 12:58 PM, Henrik Andersson he...@henke37.cjb.netwrote: While you have the right spirit I think that it would be a better idea to check the length of the array instead. That way you won't accidentally step out of bounds there. __**_ Flashcoders mailing list Flashcoders@chattyfig.figleaf.**com Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/**mailman/listinfo/flashcodershttp://cha ttyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived
Re: [Flashcoders] Simplify XML Call
Never thought there was an argument here :) I see what you are getting at. Recursive would make it a more robust function. There are a lot of variables that he has not told us about, thus I was only commenting on the fact that a recursive function would do more than what his question asked. (I try not to do more than people ask for. It's easy to get sucked into solving a larger problem than was asked) you would have to know how deep in order to change the variable - apparently he already knows how deep to go. his original post said switch (level) { On Thu, Aug 11, 2011 at 2:31 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: If the XML gets larger and deeper, that function would fail... - why would it fail? (assuming that the level var could be whatever you want? (OK, I am not trying to argue with you here, I promise) Because that's exactly it, if the levels got deeper, you would have to know how deep in order to change the variable - human intervention. Otherwise, if you didn't manually keep the XML in synch with the variable value, it would fail. And how could you know that dynamically without doing a recursive function, which is what I suggested. It gets worse if a system produces the XML. So what would be advantage of your suggestion over mine? Yours would require a manual tweaking of the level variable. A recursive function would not that value to be set at all. And a recursive function could be set to only check down to a certain level if you wanted that, or only check certain specific levels. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto: flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ktu Sent: Thursday, August 11, 2011 2:14 PM To: Flash Coders List Subject: Re: [Flashcoders] Simplify XML Call that would be limited to you hard coding the number of levels to go down to - he already had this level var created with whatever number he had intended, I was just giving an example value... If the XML gets larger and deeper, that function would fail... - why would it fail? (assuming that the level var could be whatever you want? it would be a better idea to check the length of the array instead - John didn't indicate that this was a problem of verifying the data, but instead wishing to write the same code in fewer lines. That is what I did. I do agree with you though, that error checking would be good to have. I've changed my code to test creating the string required. This is a TEST to prove that my code would indeed create the referencing desired. var level:int = 5; var str:String = xml.menu for (var i:int = 1; i level; i++) { str += .item[whichItem + ((i == 1) ? : i) + ]; } str += .item.length(); change level to whatever you want and it will produce the same lines of code John reference above. Clearly this doesn't work, but since such little information was given (especially about the 'whichItemX' variables, this was my shot at it. This here is an updated version of it that breaks out a piece to make it a bit cleaner to read: var level:int = n; var xmlItem:* = xml.menu; for (var i:int = 1; i level; i++) { var which:* = this[whichItem + ((i == 1) ? : i)] xmlItem = xmlItem.item[which]; } totalItems = xmlItem.item.length(); John, I think if we are going to be able to help you further we would need more information about how this xml is truly setup, and wher some of these values come from (whichItem, whichItem2..., level) On Thu, Aug 11, 2011 at 12:58 PM, Henrik Andersson he...@henke37.cjb.net wrote: While you have the right spirit I think that it would be a better idea to check the length of the array instead. That way you won't accidentally step out of bounds there. __**_ Flashcoders mailing list Flashcoders@chattyfig.figleaf.**com Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/**mailman/listinfo/flashcodershttp://cha ttyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination
RE: [Flashcoders] Simplify XML Call
(I try not to do more than people ask for. It's easy to get sucked into solving a larger problem than was asked) Yes, I agree totally, that can be a problem for sure. - apparently he already knows how deep to go. his original post said switch (level) { Yeah, understood. I was just responding to his request for something that does it better. So given that, I think both our approaches satisfy that request. :) Jason Merrill Instructional Technology Architect II Bank of America Global Learning -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders