2 Replies Latest reply on Jun 7, 2011 10:48 AM by Kumidan

    Problem assigning a tween

    Kumidan

      I have a gallery where passing over the image a rectangle drops down showing the caption for the image.

      The informations are read from an XML file and some of my images don't have a caption, for those emails I want to avoid the tween.

       

      The XML file has this structure:

      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <images>
           <pic>
              <image>gallery/certificato.jpg</image>
              <thumbnail>gallery/certificato_s.jpg</thumbnail>
              <caption>none</caption>
              <desc>none</desc>
          </pic>

      </images>

       

      The code where the tween are associated to the images is this

      function initGallery()
      {
          function loadXML(loaded)
          {
              if (loaded)
              {
                  xmlNode = this.firstChild;
                  total = xmlNode.childNodes.length;
                  for (i = 0; i < total; i++)
                  {
                      _root.small_image[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
                      _root.big_image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                      _root.description[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue
                      _root.testo[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
                      if (i == 0)
                      {
                          /* added the last parameter accordingly to the modified loadGImage */
                          _root.loadGImage(_root.description[i], _root.big_image[i], _root.testo[i], i);
                      } // end if

       

                      if(_root.testo[i] != "none") { //shadowbox tween in
                          _root.bigImage.onRollOver = function() {
                              var shadowboxIn:Tween = new Tween (shadowbox_mc, "_y", Strong.easeOut, -49, 0, .5, true);
                          }
                      }
                     
                      if(_root.testo[i] != "none") { //shadowbox tween out
                          _root.bigImage.onRollOut = function() {
                              var shadowboxOut:Tween = new Tween (shadowbox_mc, "_y", Strong.easeOut, shadowbox_mc._y, -49, .5, true);
                          }
                      }
                     
                      ++_root.total_images;
                  } // end of for
                  createSmall();
              }
              else
              {
                  content = "file not loaded!";
              } // end else if
          } // End of the function

       

          xmlData = new XML();
          xmlData.ignoreWhite = true;
          xmlData.onLoad = loadXML;
          if (_root.xml_file == undefined)
          {
              _root.xml_file = "images.xml";
          } // end if
          xmlData.load(xml_file);
      } // End of the function

       

      I try to avoid the tween checking whether the caption value is "none" or not, but that doesn't work, the tween is always applied.

      How can I do?

        • 1. Re: Problem assigning a tween
          Ned Murphy Adobe Community Professional & MVP

          While everything else in your loop appears to be based on assigned values relative to the loop variable " i ", _root.bigImage is what you assign the rollover/out code to but there appears to be only one of them.... what is that?  If there is only one, then that is probably why it activates for any of them... assigning it once is enough to have it do it for all.

          1 person found this helpful
          • 2. Re: Problem assigning a tween
            Kumidan Level 1

            Thanks, I've modified the code adding in this way

             

            if(_root.testo[i] != "none") {
                  _root.bigImage[i].onRollOver = function() {
                      var shadowboxIn:Tween = new Tween (shadowbox_mc, "_y", Strong.easeOut, -49, 0, .5, true);
                 }
            }
                           
            if(_root.testo[i] != "none") {
                 _root.bigImage[i].onRollOut = function() {
                      var shadowboxOut:Tween = new Tween (shadowbox_mc, "_y", Strong.easeOut, shadowbox_mc._y, -49, .5, true);
                 }
            }

             

            but it yet doesn't work, any other suggestion?