Skip to main content
Inspiring
March 29, 2012
Answered

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

  • March 29, 2012
  • 2 replies
  • 9281 views

Displaying of twitter status in flash via twitter with URLLoader.

Line 394:


Note: xml.status[num].user.statuses_count is equals to 21, however when flash tried to retrieve the last status, which is number 21, it crashes with Error #1010. Why it doesnt want to retrieve the last status?? But when xml.status[num].user.statuses_count is equals to 20, it will retrieve all of the 20 status, including the last status with no Error. This is very weird, I have no idea what is happening Is there any Error Event Listener I can use to catch this kind of error so that my flash will still be operational when it happens again?


for (var i = 0; i <xml.status[num].user.statuses_count; i++)

{

     post_array = ContentCount;

     ContentCount++;

     content_string += getContent(post_array);

}

Line 450:

private function getContent(num:Number) {

     //show just month, day and hour

     var posted:String = xml.status[num].created_at;

     var content:String = "<font color='#00000'><a href=" + '"http://twitter.com/' + USERNAME + "/statuses/" + xml.status[num].id + '" target="_blank">' +      xml.status[num].text + "</a></font><br/><font size='9' color='#333333'>" +"Posted on: " + posted.substr(0, posted.length - 11) + "; " + "From: " +      xml.status[num].source + "</font><br/><br/>";

     //return all info

     return content;

}

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

          at fladev.twitter::MainClass/getContent()

          at fladev.twitter::MainClass/displayInfo()

          at flash.events::EventDispatcher/dispatchEventFunction()

          at flash.events::EventDispatcher/dispatchEvent()

          at flash.net::URLLoader/onComplete()

This topic has been closed for replies.
Correct answer sinious

I tried to do some simple debug and found out that any number between 0-19 inside

content_string = getContent(0-19); //no error

content_string = getContent(20); //error

content_string = getContent(21); //error

content_string = getContent(22); //error

content_string = getContent(23); //error

content_string = getContent(24); //error

...

..

..

does not give me any 1010error. But when I put in a number more than 19, it will have the error. Does this means twitter wont allow me to get any twitter status ?


Like I said, your results can be limited from such sites. For instance wordpress RSS feeds typically only send 10 feeds. The fact that you get exactly 20 feeds (0-19 = 20) tells me Twitter is probably limiting what it sends you.

You can always look in the twitter API for an argument to send to twitter when requesting feeds to send more then the default amount.

2 replies

sinious
Legend
March 30, 2012

Just do a little sniffing to make sure you don't pop a compiler error. Check if (xmLstatus[num] == undefined) { break; } or something that will help you exit the loop safely without erroring so at least the valid results are returned.

Also many RSS/etc feeds only return a certain number of results and require arguments in the query to change that. You just may only be getting 20 results total, not 21.

ZainuuAuthor
Inspiring
March 30, 2012

I have never use a break statement before. I have an error.

Line 4611038: Target of break statement was not found.

private function getContent(num:Number) {

                              trace("num="+num);

                              trace("xml.status[num]="+xml.status[num]);

                              trace("xml.status[num].created_at="+xml.status[num].created_at);

                              if(xmLstatus[num] == undefined){

                                        break;

                              }

 

                                        //show just month, day and hour

                                        var posted:String = xml.status[num].created_at;

                                        var content:String = "<font color='#00000'><a href=" + '"http://twitter.com/' + USERNAME + "/statuses/" + xml.status[num].id + '" target="_blank">' + xml.status[num].text + "</a></font><br/><font size='9' color='#333333'>" +"Posted on: " + posted.substr(0, posted.length - 11) + "; " + "From: " + xml.status[num].source + "</font><br/><br/>";

                                        //return all info

                                        return content; (Line 461)

                    }

As for code I used to retrieve twitter status:



private static const USERNAME:String = "twitter username";


private static const URL:String = "http://myserverwebsite/proxy.php?url=";




private static const REQUEST:String = URL + USERNAME;

urlLoader = new URLLoader();

urlLoader.load(new URLRequest(REQUEST));

<?php

header('Content-Type: text/html; charset=utf-8');

$name = $_GET['url'];

$url = 'http://twitter.com/statuses/user_timeline.xml?screen_name=';

$url .= $name;

$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HEADER, 0);

ob_start();

curl_exec ($ch);

curl_close ($ch);

$string = ob_get_contents();

$content = ob_end_clean();

echo $string;

?>

I tried using other twitter username for retrieving but the weird thing is the error1010 pops out at num=19, no longer pops out at num=20. This is so confussing

sinious
Legend
March 30, 2012

Oh if it's just in a function don't break, do a return instead. So:

if(xmLstatus[num] == undefined){

   return;

}

kglad
Community Expert
Community Expert
March 29, 2012

line 394 is one line.  which one is that?

line 450 is one line.  which one is that?

it is helpful to post those lines in context (with surrounding code), but highlight (eg, bold) the problematic lines.

ZainuuAuthor
Inspiring
March 29, 2012

Hello, sorry about that. The line numbers are:

line 394:

content_string += getContent(post_array);

line 450:

var posted:String = xml.status[num].created_at;

kglad
Community Expert
Community Expert
March 29, 2012

use the trace function to see what's undefined (or NaN), then work backwards.

private function getContent(num:Number) {

trace(num)

trace(xml.status[num]);

trace(xm.status[num].created_at);

     //show just month, day and hour

     var posted:String = xml.status[num].created_at;

     var content:String = "<font color='#00000'><a href=" + '"http://twitter.com/' + USERNAME + "/statuses/" + xml.status[num].id + '" target="_blank">' +      xml.status[num].text + "</a></font><br/><font size='9' color='#333333'>" +"Posted on: " + posted.substr(0, posted.length - 11) + "; " + "From: " +      xml.status[num].source + "</font><br/><br/>";

     //return all info

     return content;

}