3 Replies Latest reply on Nov 15, 2010 6:09 AM by kglad

    xml driven swf banner rotator

    resolution revolution

      Please help.

       

      I have a banner rotator / slideshow with 30 swf's. I have an xml file driving the slideshow. My problem is that I have video pop-ups in each of the 30 linked swf's and a geturl in each of the swf's. I need to be able to drive this content from the xml file. Is that possible? to read an xml file from a linked swf?

       

       

      Root file AS:

       

      function desc_change(id)


      {


          if (item_array[id].desc != undefined && item_array[id].desc != "")


          {


              description.desc.htmlText = item_array[id].desc;


          }


          // end if                 


      }// End of the function


      _global.vidTitle;


      _global.vidUrl;


      _global.learnUrl;


      function init()


      {


          _global.item_array = mx.xpath.XPathAPI.selectNodeList(feed_xml.firstChild, "/list/item");


          _global.interval = feed_xml.firstChild.attributes.interval;


          _global.startup_slideshow = feed_xml.firstChild.attributes.startup_slideshow;


          for (i = 0; i < item_array.length; i++)


          {


              item_array[i].pic = item_array[i].childNodes[0].firstChild.nodeValue;


              item_array[i].thumb = item_array[i].childNodes[1].firstChild.nodeValue;


              item_array[i].title = item_array[i].childNodes[2].firstChild.nodeValue;


              item_array[i].videotitle = item_array[i].childNodes[3].firstChild.nodeValue;


              item_array[i].videourl = item_array[i].childNodes[4].firstChild.nodeValue;


              item_array[i].learnurl = item_array[i].childNodes[5].firstChild.nodeValue;


              item_array[i].desc = item_array[i].childNodes[6].firstChild.nodeValue;


              item_array[i].id = i;


          }// end of for


          p = 0;

       

          for (i = 0; i < item_array.length; i++)


          {
              it = items_mc.item.duplicateMovieClip("item" + i, i);
              it.pic.loadMovie(item_array[i].thumb);
              it.txt.text = item_array[i].title;
              it.txt2.text = item_array[i].title;

       

              it.id = item_array[i].id;
              vidTitle = item_array[0].videotitle;
              vidUrl = item_array[0].videourl;
              learnUrl = item_array[0].learnurl;

       

              it.bg.onRollOver = function()
              {
                  if (!this._parent._parent._parent.moving)
                  {
                      this.gotoAndStop(2);
                  }
                  // end if                 
              };
              it.bg.onRollOut = function()
              {
                  this.gotoAndStop(1);
              };
              it.bg.onRelease = function()
              {
                  vidTitle = item_array[this._parent.id].videotitle;
                  vidUrl = item_array[this._parent.id].videourl;
                  learnUrl = item_array[this._parent.id].learnurl;
                  //trace(vidTitle);
                  //trace(vidUrl);
                  //trace(learnUrl);

       

                  if (!this._parent._parent._parent.moving && this._parent.id != this._parent._parent._parent.cur_img_id)
                  {
                      this._parent._parent._parent.big_load(this._parent.id);
                  }
                  // end if                 
              };
              if (i % 3 == 0)
              {
                  it._x = p;
              }
              else
              {
                  it._x = p;
              }// end else if
              p = it._x + 275;
          }// end of for
          if (startup_thumbs_hide == "Yes")
          {
              items_mc._alpha = 0;
              items_mc._y = 220;
              items_mc._visible = 0;
          }
          else
          {
              thb_bg._show = true;
              thb_bg.gotoAndStop("show_startup");
              caption._visible = 0;
          }// end else if
          big_load(0);
          if (startup_slideshow == "No")
          {
              clearInterval(timer_update_id);
              timer.ico.gotoAndStop(2);
              timer._show = true;
          }
          // end if                 
      }// End of the function
      function create_blur(flg)
      {
          for (index in items_mc)
          {
              if (flg)
              {
                  items_mc[index].filters = [new flash.filters.BlurFilter(25, 0, 1)];
                  continue;
              }
              // end if                 
              items_mc[index].filters = [null];
          }// end of for...in
      }// End of the function
      function move_right()
      {
          if (items_mc._x <= -246.51 * item_array.length)
          {
              trace(items_mc._width);
          }
          else
          {
              trace(items_mc._x);
              moving = true;
              create_blur(1);
              items_mc.onEnterFrame = function()
              {

       

                  if (this._x > -this._parent.page * 275)
                  {
                      this._x = this._x - 50;
                  }
                  else
                  {
                      this._x = -this._parent.page * 275 + 1;
                      delete this.onEnterFrame;
                      ++this._parent.page;
                      this._parent.create_blur(0);
                      this._parent.moving = false;
                      if (this._parent.page > Math.ceil(item_array.length / 3) - 1)
                      {
                          this._parent.right._visible = 1;
                      }
                      // end if                 
                      if (!showing)
                      {
                          ++cur_img_id;
                          if (cur_img_id > item_array.length - 1)
                          {
                              cur_img_id = 0;
                          }
                          // end if                 
                          big_load(cur_img_id);
                      }
                      // end if                 
                  }// end else if
              };
          }
      }// End of the function
      function move_left()
      {
          if (items_mc._x == 1 || items_mc._x == 1.35)
          {
              trace(items_mc._width);
          }
          else
          {
              trace(items_mc._x);
              moving = true;
              create_blur(1);
              items_mc.onEnterFrame = function()
              {
                  if (this._x < -(this._parent.page - 2) * 275)
                  {
                      this._x = this._x + 50;
                  }
                  else
                  {
                      this._x = -(this._parent.page - 2) * 275 + 1;
                      delete this.onEnterFrame;
                      --this._parent.page;
                      this._parent.create_blur(0);
                      this._parent.moving = false;
                      if (!showing)
                      {
                          --cur_img_id;
                          if (cur_img_id < 0)
                          {
                              cur_img_id = item_array.length - 1;
                          }
                          // end if                 
                          big_load(cur_img_id);
                      }
                      // end if                 
                  }// end else if
              };
          }
      }// End of the function
      function big_load(id)
      {
          if (!showing)
          {
              cur_img_id = id;
              moving = true;
              showing = true;
              clearInterval(timer_update_id);
              image.id = id;
              image.gotoAndPlay("hide");
              desc_change(id);
          }
          // end if                 
      }// End of the function
      var feed_xml = new XML();
      feed_xml.ignoreWhite = true;
      feed_xml.load("data.xml");
      feed_xml.onLoad = function(success)
      {
          init();
      };
      items_mc.setMask(mask1);
      page = 1;
      setInterval(caption_tracking,10);
      caption._visible = 0;
      big_preloader._alpha = 0;
      var big_Listener = new Object();
      var big_mcl = new MovieClipLoader();
      big_mcl.addListener(big_Listener);
      big_Listener.onLoadProgress = function(target_mc, loadedBytes, totalBytes)
      {
          big_preloader._alpha = 100;
          big_preloader._xscale = Math.floor(loadedBytes / totalBytes * 100);
      };
      big_Listener.onLoadInit = function(target_mc)
      {
          image.gotoAndPlay("show");
          big_preloader.onEnterFrame = function()
          {
              if (this._alpha > 0)
              {
                  this._alpha = this._alpha - 10;
              }
              else
              {
                  this._alpha = 0;
                  delete this.onEnterFrame;
              }// end else if
          };
      };

       

       

      XML file:

       

      <list interval="10" startup_thumbs_hide="No" click_thumbs_hide="No" startup_slideshow="Yes">
          <item>
              <pic>banners/1.swf</pic>
              <thumb>thumbs/1.gif</thumb>
              <title>Green Airways</title>
              <videotitle>Green Airways</videotitle>
              <videourl>http://honeywell.feedroom.com/?skin=oneclip&fr_story=f9719091cc3ee7a2f3ffb834ca16c3c7c18fe fdb&rf=ev&autoplay=true</videourl>
              <learnurl>https://commerce.honeywell.com/webapp/wcs/stores/servlet/ECategoryDisplay?catalogId=10101& storeId=10651&categoryId=32429&langId=-1</learnurl>
              <description><![CDATA[<font face="Arial" size="11" color="#666666">1-3 of 30]]></description>
          </item>

       

      </list>

       

       

      Linked swf code for learnurl button:

       

      on (release) {
          var str = _parent._parent._parent.learlUrl;
          getURL(learnurl,"_blank");
      }

       


      this last part is not working. Can anybody help? Thanks in advance, sorry I can't post the files.