0 Replies Latest reply on Aug 28, 2007 7:27 AM by 0belix

    Problem with XML

    0belix Level 1
      Hello,

      I'm having trouble fetching data from a XML file to populate a dynamic slide-show. Below is the code:

      stop();

      ///////////////////////////////
      // Class dos botões //
      ///////////////////////////////

      botaoClass = function () {
      //trace("teste");
      };
      botaoClass.prototype = new MovieClip();
      Object.registerClass("mc_imgBot",botaoClass);
      botaoClass.prototype.onLoad = function() {
      this.onLoad = function(){
      this.mc_imageHolder.loadMovie(this.img);
      };
      this.onRollOver = function(){

      };
      this.onRollOut = function(){

      };
      this.onRelease = function(){
      getURL(this.urlLink);
      };
      };


      ///////////////////////////////
      // Funções //
      ///////////////////////////////

      function criarSlideShow() {
      //--- Posição inicial do slideShow
      var posicaoX:Number = new Number;
      var posicaoY:Number = new Number;
      posicaoX = 0;
      posicaoY = 0;
      //--- Introduzir os botões do mainMenu
      for (i=0; i<_root.images.length; i++) {
      _root.mc_btns.attachMovie("mc_imgBot", "imgBot"+i, i+1);
      //--- Definir o URL a chamar pelo botão
      set("_root.mc_btns.mc_imgBot" + i + ".urlLink", _root.images .urlLink);
      //--- Definir a imagem para o botão
      set("_root.mc_btns.mc_imgBot" + i * ".img", _root.images
      .Url);
      setProperty("_root.mc_btns.mc_imgBot" + i, _x, posicaoX);
      setProperty("_root.mc_btns.mc_imgBot" + i, _y, posicaoY);
      posicaoX += getProperty(eval("_root.mc_btns.mc_imgBot" + i), _width)+20;
      trace("teste2 - " + i);
      }
      trace("teste3");
      }

      function processMenu(xmlDoc_xml) {
      trace("inProcess = " + xmlDoc_xml.firstChild.firstChild.attributes.jpgURL);
      _root.images = new Array();
      var imagesNode = xmlDoc_xml.firstChild.firstChild;
      trace("teste 123 = " + imagesNode.attributes.textTitle);
      while (imagesNode) {
      var infoTemp:Array = new Array();
      var attribArray = imagesNode.attributes;
      infoTemp.legenda = attribArray.textTitle;
      infoTemp.Url = attribArray.jpgURL;
      infoTemp.urlLink = attribArray.linkUrl;
      trace("conteudo do tempArray = " + infoTemp.toString());
      _root.images.push(infoTemp);
      i++;
      imagesNode = imagesNode.nextSibling;
      }
      //--- chamar função para criar o slideShow
      trace("conteudo do array = " + _root.images.toString());
      trace("teste2");
      criarSlideShow();
      }

      ///////////////////////////////
      // Chamada do XML //
      ///////////////////////////////

      var XMLFile:String = new String;
      XMLFile = "xml/slideshow.xml";
      var XMLContent:XML = new XML();

      XMLContent.ignoreWhite = true;
      XMLContent.onLoad = function(success){

      trace("miniteste = " + this.toString());
      if (success) {
      processMenu(XMLContent);
      }
      trace("teste");

      }
      XMLContent.load(XMLFile);


      XMLfile:

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <images>
      <image jpgURL="img/img1.gif" textTitle="Clube 1" linkUrl="javascript:alert('Chamar clube 1');" />
      <image jpgURL="img/img2.gif" textTitle="Clube 2" linkUrl="javascript:alert('Chamar clube 2');" />
      <image jpgURL="img/img3.gif" textTitle="Clube 3" linkUrl="javascript:alert('Chamar clube 3');" />
      <image jpgURL="img/img4.gif" textTitle="Clube 4" linkUrl="javascript:alert('Chamar clube 4');" />
      <image jpgURL="img/img5.gif" textTitle="Clube 5" linkUrl="javascript:alert('Chamar clube 5');" />
      <image jpgURL="img/img6.gif" textTitle="Clube 6" linkUrl="javascript:alert('Chamar clube 6');" />
      <image jpgURL="img/img7.gif" textTitle="Clube 7" linkUrl="javascript:alert('Chamar clube 7');" />
      </images>


      The problem seems to be happening in the processMenu function, when i try to get the attributes of each node, and place them inside an Array to later populate the slide-show. I cant get each attribute alone, when I trace it before assigning it to the array. Once I try to do it (inside the While loop), it returns no values at all.

      Can someone please help me figure out what the problem is?

      Tthank you