591 posts It's just life. Just live it.
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a competition
  • Has sold $250,000+ on Envato Market
  • Sells items exclusively on Envato Market
+8 more
Themes-Dojo says

Hi!

I’m creating a small widget for a client which will read different rss feeds. It works for first feed but when I click for another one it doesn’t load. I traced and it shows me only 2 loops even there are 10 or 12 news. Any kind of help or clues will be appreciated. Thank you!

Below is the script.

Alex

P.S: Sorry for my poor English.

import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;

Stage.align = "TL";
Stage.scaleMode = "noscale";
Stage.showMenu = false;

var newsID = 0;
var position = 0;
var positionNew = 20;
var lastBttn = 0;
var j = 0;

button_up.button_up.enabled = false;
button_up.gotoAndStop(3);

// Load Rss Feed
feed = new XML();
feed.ignoreWhite = true;
feed.onLoad = function(success) {
   if (success) {

      xmlNode = this.firstChild;

      rssTitle = [];
      link = [];
      rssSource = [];

      var total = xmlNode.childNodes.length;
      for (var i = 0; i<total; i++) {

         rssTitle[i] = xmlNode.childNodes[i].attributes.title;
         link[i] = xmlNode.childNodes[i].attributes.path;
         rssSource[i] = xmlNode.childNodes[i].attributes.source;

         holder_rss.attachMovie("rssList","rss_list"+i,i+999);
         holder_rss["rss_list"+i].id = i;
         holder_rss["rss_list"+i]._y = 0;
         holder_rss["rss_list"+i].title_txt.text = rssTitle[i];
         holder_rss["rss_list"+i].title_txt.autoSize = true;
         holder_rss["rss_list"+i].bkg_mc.bkg_mc._width = holder_rss["rss_list"+i].title_txt._width+12;
         holder_rss["rss_list"+0]._x = 0;
         holder_rss["rss_list"+i]._x = holder_rss["rss_list"+[i-1]]._x+holder_rss["rss_list"+[i-1]]._width;

         holder_rss["rss_list"+lastBttn].enabled = false;
         holder_rss["rss_list"+lastBttn].gotoAndStop(2);

         holder_rss["rss_list"+i].onRollOver = function() {
            thisID = this.id;

            holder_rss["rss_list"+thisID].gotoAndStop(2);
         };
         holder_rss["rss_list"+i].onRollOut = function() {
            thisID = this.id;

            holder_rss["rss_list"+thisID].gotoAndStop(1);
         };
         holder_rss["rss_list"+i].onRelease = function() {
            this_ID = this.id;

            holder_text._x = 20;
            newsID = 0;
            position = 0;
            positionNew = 20;

            for (var i = 0; i<_global.total; i++) {
               removeMovieClip(holder_text["text"+i]);
            }

            _global.total = 0;
            title_mc.title_txt.text = " ";
            total_news_txt.text = "News -/-";

            holder_rss["rss_list"+lastBttn].enabled = true;
            holder_rss["rss_list"+lastBttn].gotoAndStop(1);
            lastBttn = this_ID;
            holder_rss["rss_list"+lastBttn].enabled = false;
            holder_rss["rss_list"+lastBttn].gotoAndStop(2);

            if (rssSource[this_ID] == "local") {
               rss.load(link[this_ID]);
            } else {
               senderObj = new LoadVars();
               senderObj.rss = link[this_ID];
               senderObj.sendAndLoad("rssProxy.php",rss,"GET");
            }
         };

         if (rssSource[0] == "local") {
            rss.load(link[0]);
         } else {
            senderObj = new LoadVars();
            senderObj.rss = link[0];
            senderObj.sendAndLoad("rssProxy.php",rss,"GET");
         }
      }
   }
};
feed.load("news/rss.xml");

// Load Rss Data
rss = new XML();
rss.ignoreWhite = true;
rss.onLoad = function(success) {
   if (success) {

      var loop = rss.firstChild.firstChild.childNodes;
      _global.lastTotal = loop.length;

      itemTitle = [];
      Title = [];
      date = [];
      BigNews = [];
      link = [];
      j = 0;

      for (var i = 0; i<loop.length; i++) {
         total_news_txt.text = _global.lastTotal;
         if (loop[i].nodeName == "item") {

            itemTitle[j] = extractContent(loop[i], "title");
            date[j] = extractContent(loop[i], "pubDate");
            BigNews[j] = extractContent(loop[i], "description");
            link[j] = extractContent(loop[i], "link");

            holder_text.attachMovie("text","text"+j,j+999);
            holder_text["text"+j].id = j;
            holder_text["text"+j]._y = 0;
            holder_text["text"+j]._x = j*220;
            holder_text["text"+j].textHolder.text_txt.htmlText = BigNews[j];
            holder_text["text"+j].textHolder.text_txt.autoSize = true;

            holder_text["text"+j].onRelease = function() {

               getURL(link[this.id], "_blank");

            };

            title_mc.title_txt.text = itemTitle[0];
            title_mc.title_txt.autoSize = true;
            title_mc.title_txt._y = Math.round(18-(title_mc.title_txt.textHeight/2));

            _global.ID = 0;

            j++;
            _global.total = j;

            total_news_txt.text = "News 1/"+_global.total;

         }
      }
   }
};

function extractContent(source:XMLNode, name:String):String {
   var nodeTxt:String = "";
   var c:XMLNode = source.firstChild;

   while (c) {
      if (c.nodeType != 3) {
         if (c.nodeName == name) {
            nodeTxt = c.firstChild.nodeValue;
         }
         nodeTxt += extractContent(c, name);
      }
      c = c.nextSibling;
   }
   return nodeTxt;
}
// End //

///////////  next/prev buttons  ////////////
nextNews_mc.onPress = function() {
   timer = setInterval(buttonNext, 500);
};

nextNews_mc.onRelease = function() {
   clearInterval(timer);
   buttonNext();
};

function buttonNext() {

   if (position == _global.total-1) {

      clearInterval(timer);

   } else {

      position++;
      positionNew = (-position*220)+20;

   }
   MoveNav = new Tween(holder_text, "_x", Strong.easeOut, holder_text._x, positionNew, 1, true);

   total_news_txt.text = "News "+(position+1)+"/"+_global.total;

   title_mc.title_txt.text = itemTitle[position];
   title_mc.title_txt.autoSize = true;
   title_mc.title_txt._y = Math.round(18-(title_mc.title_txt.textHeight/2));

}

prevNews_mc.onPress = function() {
   timer1 = setInterval(buttonPrev, 500);
};

prevNews_mc.onRelease = function() {
   clearInterval(timer1);
   buttonPrev();
};

function buttonPrev() {

   if (position == 0) {

      clearInterval(timer1);

   } else {

      position--;
      positionNew = (-position*220)+20;

   }
   MoveNav = new Tween(holder_text, "_x", Strong.easeOut, holder_text._x, positionNew, 1, true);

   total_news_txt.text = "News "+(position+1)+"/"+_global.total;

   title_mc.title_txt.text = itemTitle[position];
   title_mc.title_txt.autoSize = true;
   title_mc.title_txt._y = Math.round(18-(title_mc.title_txt.textHeight/2));

}

stop();

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by