Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 Twitter Feed Error 1010

New Here ,
Mar 14, 2013 Mar 14, 2013

Hi

I'm trying to create a simple Twitter feed for a Flash website.  When I run the flash movie however I get the following messages appear in the Output window:

TypeError: Error #1010: A term is undefined and has no properties.

at Cinema_fla::MainTimeline/processXML()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()

I am using Flash CS6 and the AS3 code for my Twitter feed is shown below:

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=YahooMoviesUK"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);

txtTweet1.text = myXML.status[0].text;
txtTweet2.text = myXML.status[1].text;
txtTweet3.text = myXML.status[2].text;
}

I would be grateful if anyone could give me some advice as to why this error is occurring.  If you need any more info please let me know.

Thanks

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 14, 2013 Mar 14, 2013

From what I remember, the text of the xml is extracted as a method rather than as a property...

myXML.item.title[0].text(); <-----  put () after text

Continue using the trace if things remain errant.

Translate
LEGEND ,
Mar 14, 2013 Mar 14, 2013

Go into your Flash Publish Settings and select the option to Permit Debugging.  This can often help by adding a line number to the error message to help narrow down where the problem is.

Beyond that, try using the trace command within the processXML function to see if you can identify which element is undefined.

Note: You should always assign the load complete listener before you initiate the loading process.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 14, 2013 Mar 14, 2013

Thanks for the quick reply!  I turned on debugging and the resulting output pointed to the following line in the code:

txtTweet1.text = myXML.status[0].text;

However, I can't see any problem with this?  The txtTweet1 is a dynamic text field in my flash application and I've double checked the name which is correct.

I'm a novice user of AS3 so I'm afraid I'm not sure what you mean by: You should always assign the load complete listener before you initiate the loading process.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2013 Mar 14, 2013

As I already mentioned, trace all of the elements in that line of code to see which one is coming up as undefned.

As for the ordering of things...  move the complete listener ahead of the load command...

myXMLLoader.addEventListener(Event.COMPLETE, processXML);

myXMLLoader.load(new URLRequest("https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=Yahoo MoviesUK"));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 14, 2013 Mar 14, 2013

Ok I just tried doing the trace like you said and the output showed me that the twitter XML was using different tag names than I thought.  However, after changing the AS code to reflect this (see below) I'm still getting the same error on the same line.  I also changed the order of the complete listener and load command:

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
myXMLLoader.load(new URLRequest("https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=YahooMoviesUK"));

function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);

txtTweet1.text = myXML.item.title[0].text;
txtTweet2.text = myXML.item.title[1].text;
txtTweet3.text = myXML.item.title[2].text;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2013 Mar 14, 2013

From what I remember, the text of the xml is extracted as a method rather than as a property...

myXML.item.title[0].text(); <-----  put () after text

Continue using the trace if things remain errant.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 14, 2013 Mar 14, 2013

Thanks so much for all your help!  After rearranging the code it now works like a dream.

Thanks again for your speedy responses.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2013 Mar 14, 2013
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines