AS3 error from Twitter search xml file
I am simply trying to trace search results from twitter.
When I look up a person's timeline, it works perfect:
this is my code:
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("http://twitter.com/statuses/user_timeline.xml? screen_name=docceng"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void{
var myXML:XML开发者_StackOverflow社区 = new XML(e.target.data);
myXML.ignoreWhite = true;
trace(myXML.status[0].id);
trace(myXML.status[0].text);
trace(myXML.status[0].user.name);
}
When I try to pull the search results for example:
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("http://search.twitter.com/search.atom?q=mobile%20ads"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);
myXML.ignoreWhite = true;
trace(myXML.entry[0].content);
}
I get an error:
TypeError: Error #1010: A term is undefined and has no properties. at test_fla::MainTimeline/processXML() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
Any help for the newbie appreciated.
THanks in advance
dg
The URL is invalid. it should be http://search.twitter.com/search.atom?q=mobile%20ads
(no space)
Also entry is an array so you have to write: trace(myXML.entry[0].content);
instead of trace(myXML.entry.[0].content);
(mind the extra dot)
精彩评论