Skip to main content
Participant
June 3, 2011
Question

Problem assigning a tween

  • June 3, 2011
  • 1 reply
  • 279 views

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 = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
                _root.big_image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
                _root.description = xmlNode.childNodes.childNodes[2].firstChild.nodeValue
                _root.testo = xmlNode.childNodes.childNodes[3].firstChild.nodeValue;
                if (i == 0)
                {
                    /* added the last parameter accordingly to the modified loadGImage */
                    _root.loadGImage(_root.description, _root.big_image, _root.testo, i);
                } // end if

                if(_root.testo != "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 != "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?

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
June 4, 2011

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.

KumidanAuthor
Participant
June 7, 2011

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

if(_root.testo != "none") {
      _root.bigImage.onRollOver = function() {
          var shadowboxIn:Tween = new Tween (shadowbox_mc, "_y", Strong.easeOut, -49, 0, .5, true);
     }
}
               
if(_root.testo != "none") {
     _root.bigImage.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?