9 Replies Latest reply on Sep 28, 2010 10:22 AM by Ron Colmen

    Loop after 9?

    Ron Colmen Level 2

      This doesn't loop after photo9. After photo9 the trace shows 'undefined'. How can I fix it so it keeps on lopping?

       

      var swfArray = new Array()

      var urls:Array = new Array();

      var captions:Array = new Array();

      var whoIsOn:Number;

       

      x.onLoad = function(success) {

      var photos:Array = this.firstChild.childNodes;

      for(i=0;i<=9; i++) {

      urls.push(photos[i].attributes.url);

      captions.push(photos[i].attributes.caption);

      }

      holder.loadMovie(urls[0]);

      caption.text = captions[0];

      whoIsOn = 0;

      }

       

      x.load("imgldr.xml");

       

      var Totalphotos = urls.length;

      var RundomphotoID = Math.floor(Totalphotos *Math.random());

      holder.loadMovie(urls[RundomphotoID]);

       

      Loadphoto();

      function Loadphoto() {

          trace("Array Index: "+whoIsOn+" photo: "+urls[whoIsOn]);

          holder.loadMovie(urls[whoIsOn]);

          if(whoIsOn < urls.length-1) {

      whoIsOn++;

          holder.loadMovie(urls[whoIsOn]);

          caption.text = captions[whoIsOn];

      }  

      }

      var IntervalID = setInterval(Loadphoto, 1000);

       

       

      Trace:

      trace.JPG