Hi,
I'm trying to load some content into flash from an XML rss feed.
I took the original code from gotoandlearn, and all I added was some buttons
to make this content change.
that is, when I click on a button, the xml has to be replaced for another one.
It works except that instead of replacing the content, it ADDs to the XML
list, everytime I click on the buttons.
I tried removing children but it doesn't work, cause it leaves no place to put
the new content.
HAve to say I'm kinda lost :)
thanks a lot!!!
Code:
import flash.display.Loader;
import flash.net.URLRequestMethod;
import flash.net.URLLoader;
import flash.display.LoaderInfo;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
lb.addEventListener(Event.CHANGE, itemChange);
function itemChange(e:Event):void
{
ta.text = lb.selectedItem.data;
}
var xml:XML;
var arr:Array = new Array();
var il:XMLList;
function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
il = xml.channel.item;
for(var i:uint=0; i<il.length(); i++)
{
lb.addItem({data:il.description.text()[i],
label:il.title.text()[i]});
}
}
loader.load(new URLRequest("http://localhost/indira/category/txt/?feed=rss"));
this.bt_foto.addEventListener(MouseEvent.CLICK,ClicFoto);
function ClicFoto(e:Event):void
{
xml = new XML
//il = 0;
loader.load(new URLRequest("http://localhost/indira/category/foto/?feed=rss"));
//il.removeItem();
//il = xml.channel.item;
//delete(xml);
trace(lb.numChildren);
}
this.bt_web.addEventListener(MouseEvent.CLICK,onClickweb);
function onClickweb(e:Event):void
{
trace(loader.data);
loader.load(new
URLRequest("http://localhost/indira/category/netweb/?feed=rss"));
}
indiramm - 06 Aug 2008 17:19 GMT
Finally, it was pretty easy, at least now that it works:
I just had to remove all:
lb.removeAll();
:)