473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Twitter xml value not loading into FOR loop (AS2)

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


Expand|Select|Wrap|Line Numbers
  1. var loadXML:XML = new XML();
  2. loadXML.ignoreWhite = true;
  3. loadXML.onLoad = processXML;
  4. //loadXML.load("twitter.php"); //used when swf in placed on server
  5. loadXML.load("http://twitter.com/statuses/user_timeline.xml?screen_name=sabctoo");
  6.  
  7. function processXML(loaded:Boolean)
  8. {
  9.     if(loaded)
  10.     {
  11.  
  12.         var node = this.firstChild;
  13.         tweet_1.text = node.childNodes[0].childNodes[2].firstChild;
  14.         tweet_2.text = node.childNodes[1].childNodes[2].firstChild;
  15.         tweet_3.text = node.childNodes[2].childNodes[2].firstChild;
  16.         tweet_4.text = node.childNodes[3].childNodes[2].firstChild;
  17.  
  18.         var follower_count = node.childNodes[9].childNodes[11].childNodes[9].firstChild;// Creates variable
  19.         trace(follower_count); //loads variable into output
  20.  
  21.         follower_count_txt.text = follower_count;// show follower count in text box
  22.  
  23.     }
  24.  
  25.     else 
  26.     {
  27.         error_txt.text = "Error loading XML file";
  28.     }   
  29.  
  30.                 for (i=0; i<follower_count; i++) // <-- problem occurs here
  31.                     {
  32.                     _root.attachMovie("tweep_mc", "tweep"+i+"_mc", i);
  33.                     _root["tweep"+i+"_mc"]._x = 150 + random(500);
  34.                     _root["tweep"+i+"_mc"]._y = 150 + random(500);
  35.                     trace(i); 
  36.                     }
  37.  
  38.                 trace(i);
  39. }
  40.  
  41. follow_btn.onRelease = function()
  42. {
  43.     getURL("http:///twitter.com/sabctoo");
  44. }
Apr 19 '12 #1
0 2010

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris | last post by:
Hi, Where can I find info on using AS2 connection in .net? I need to upload/download EDI files form a trading partner. We already have a program that creates the EDI files. All I have to do now is...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
3
by: Gustavo Randich | last post by:
The following seems to be a bug. The execution returns rows 1,2. It should return 1,1. In fact, if I run the code within a stored procedure alone (not in a trigger), the loop doesn't overwrite the...
3
by: gasturbtec | last post by:
i'm using access 2000 and have a form in which users can select reports with check boxes and click a print button to print out the selected reports. what i want to do now is place a text box on the...
6
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
1
by: sksksk | last post by:
I want to achieve the following process in the smarty for $item one i should be able to get the value using loop.index, but without any luck. any help is appreciated. <?php for ($i = 1; $i...
2
AutumnsDecay
by: AutumnsDecay | last post by:
Hey. New problem. Ugh... As it turns out Flash will not load an XML file located elsewhere (some other websites, network, etc..). It will only load local XML. This causes a problem for me. ...
11
by: uzairmemon | last post by:
Any one Have coding of Reverse stop watch?
1
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I've been using a PHP Twitter library for months now to automatically repost news that I post on my site, to my site's Twitter. Recently though this stopped working, and I get an error back from...
3
Mary Seelye
by: Mary Seelye | last post by:
public void increaseVolume2() { SoundSample sampleArray = this.getSamples(); SoundSample sample = null; int value = 0; //loop through all the samples in the array for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.