This is my first post on your site, so let me begin by thanking all you geniuses who so thoughtfully and effectively answer frequently asked questions that until now I have been able to find solutions to my Actionscript quarries without having needed to ask a question myself. Kudos! The problem I’m having is quite specific to my context but I will try to make it as general as I can to make it relevant to other users scenarios as well. Right of the bat, my project makes use of Actionscript 2 and works with XML, Twitter API, and a FOR loop. The basic thing in which I am trying to achieve is to create a flash widget for my website that captures my last four tweets from the online XML using Twitter API and outputs it into my dynamic text boxes on stage. This all works fine. The next step I plan to take is to pull all the profile pictures of all my followers and display them tiled (or randomly placed) on stage. Before I get into that I’m trying something a little simpler with the follower count. Basically I access my follower count from the online Twitter XML and trace it to make sure I have the number. Then, using the follower count number - in the form of a variable called “follower_count”- I try to load that many instances of a movie-clip (from my library) onto stage using a FOR loop. Everything seems to be working fine including the loop; however, the variable “follower_count” is returning a value of “0” when placed in the loop instead of my actual follower count from the XML. I’ve tested this exact code with any specific number representing the condition instead of “follower_count” and it works just as I expect it to. But now I am confused as to why the “follower_count” is not working even though when I trace it, it returns the correct number of followers I have. I am really drawing a blank on this one and I feel as though I have tried just about everything. Please if any of you have any advice to offer me I would greatly appreciate it.
Many Thanks
-
var loadXML:XML = new XML();
-
loadXML.ignoreWhite = true;
-
loadXML.onLoad = processXML;
-
//loadXML.load("twitter.php"); //used when swf in placed on server
-
loadXML.load("http://twitter.com/statuses/user_timeline.xml?screen_name=sabctoo");
-
-
function processXML(loaded:Boolean)
-
{
-
if(loaded)
-
{
-
-
var node = this.firstChild;
-
tweet_1.text = node.childNodes[0].childNodes[2].firstChild;
-
tweet_2.text = node.childNodes[1].childNodes[2].firstChild;
-
tweet_3.text = node.childNodes[2].childNodes[2].firstChild;
-
tweet_4.text = node.childNodes[3].childNodes[2].firstChild;
-
-
var follower_count = node.childNodes[9].childNodes[11].childNodes[9].firstChild;// Creates variable
-
trace(follower_count); //loads variable into output
-
-
follower_count_txt.text = follower_count;// show follower count in text box
-
-
}
-
-
else
-
{
-
error_txt.text = "Error loading XML file";
-
}
-
-
for (i=0; i<follower_count; i++) // <-- problem occurs here
-
{
-
_root.attachMovie("tweep_mc", "tweep"+i+"_mc", i);
-
_root["tweep"+i+"_mc"]._x = 150 + random(500);
-
_root["tweep"+i+"_mc"]._y = 150 + random(500);
-
trace(i);
-
}
-
-
trace(i);
-
}
-
-
follow_btn.onRelease = function()
-
{
-
getURL("http:///twitter.com/sabctoo");
-
}