PDA

View Full Version : Matching the results of an XML in AS3



tezzutezzu
October 12th, 2007, 10:16 AM
Hey guys, I just wanted to share this:
I wondered how to create arrays for categories automatically from my blog (wordpress) rss feed and it was quite easy thanks to the filter array method.

here's the code:


private function createItems():void {
for each (var cat:XML in _items.category) {
if (_categories.length>0) {
if (_categories.filter(checkThis)==false) {
_categories.push(cat);
}
} else {
_categories.push(cat);
}
}
function checkThis(element:*, index:int, arr:Array):Boolean {
if (element.text()==cat.text()) {
return true;
} else {
return false;
}
}
trace("categories are:"+_categories);
}_items is an XMLList created by XML..items method

don't know if it was already posted (maybe in the AS3 tip of the day) if so i apologize :)

minthu
October 16th, 2007, 12:38 AM
Any preview file available online?

tezzutezzu
October 16th, 2007, 06:11 AM
Hi Mintu, you can find an example where I used this snippet in the RSS viewer on my homepage:
www.tezzutezzu.com (http://www.tezzutezzu.com)