Friday, June 19, 2009

Cool Flash Tip of the Week 4

I know last week I said we will be learning about a custom class, but I think I'll hold that one for next week. This week we are going to check out a quick and useful tip that I didn't even know about until a couple of days ago for selecting XML and XMLList nodes. This won't be as in depth as the last, but I still think its a great quick tip.













We will be testing on this XML file.







Maria
Jason


Jason


Chris
Jack
Maria





I recently found out this cool way to select XML nodes. You can actually test attributes to filter out which ones you want. Check out the example for a better idea of what I mean.





var l:URLLoader = new URLLoader();
l.addEventlistener(Event.COMPLETE, xmlLoaded);
l.load(new URLRequest("ourXML.xml"));

function xmlLoaded(e:Event):void
{
var myXML:XML = XML(l.data);
trace(myXML.family.(@lastName == "Travis").member); // Outputs Maria , John
}



Using this method you can easily filter out a selection of nodes based on an evaluation. I find this a better way to the alternative of using array indices to select a particular tree. This is a pretty quick tip that I thought would be helpful. Next week, we are back to the in depth tips like usual. Again, if you like the post, subscribe to the RSS Feed.

8 comments:

  1. Awesome tip man! Keep posting!

    ReplyDelete
  2. [...] Cool Flash Tip of the Week 4 | kreativeKING - Interactive Developer Posted in PHP, Web Design | Tags: and-, and-furthering, css, design, development, [...]

    ReplyDelete
  3. Pretty nice post. I just came across your blog and wanted to say
    that I have really enjoyed reading your posts. Any way
    I'll be subscribing to your feed and I hope you post again soon!

    ReplyDelete
  4. Do you know of a way to do a deep node select? Like this example:

    http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=25695

    ReplyDelete
  5. I think i've seen this somewhere before…but it's not bad at all

    ReplyDelete
  6. Great post… good suggestions…thanks!

    ReplyDelete