1
votes

As a homework I have to code a simple gallery; we've been working with GreenSock effects also. Here's my code so far:

import com.greensock.easing.*;
import com.greensock.TweenLite;

for (var i:Number = 0 ; i<5 ; i++){
    _root["a"+i].onRollOver=function(){
        TweenLite.to(this,.5,{_xscale:130,_yscale:130,
                     _alpha:90,
                     ease:Elastic.easeOut});
    }
    _root["a"+i].onRollOut=function(){
        TweenLite.to(this,.5,{_xscale:100,_yscale:100,
                     _alpha:50,
                     ease:Elastic.easeOut});
    }
    _root["a"+i].onPress=function(){
        var ix=this._name.substr(1);
        TweenLite.to(_root["z"+ix],1,{_y:199.95,
                     ease:Quart.easeOut});
        for(i=0 ; i<5 ; i++){
            _root["a"+i].enabled=false;
    }
    }
    _root["z"+i].cer.onPress=function(){
        var ix=this._parent.name.substr(1);
        TweenLite.to(_root["z"+ix],1,{_y:-190.15,
                     ease:Quart.easeIn});
        for(i=0 ; i<5 ; i++){
            _root["a"+i].enabled=true;
            _root["a"+i]._xscale=100;
            _root["a"+i]._yscale=100;
            _root["a"+i]._alpha=50;
    }
}
}

I know there are many ways to do a gallery but that's pretty much the structure we worked with in class so I can't really change much. The thing is, everything works great but once I get to the point where the Content (z) is shown and you click on the Movieclip inside it which closes it ("cer"), although it does return the, lets say, Select-image button (a) to it's original state (slightly pops-up when selected), it seems to simply ignore the TweenLite.

    _root["z"+i].cer.onPress=function(){
        var ix=this._parent.name.substr(1);
        TweenLite.to(_root["z"+ix],1,{_y:-190.15,
         ease:Quart.easeIn});

display

As I understand, here we're basically saying: Of the symbol named "z" + the current number of the var "i", the symbol "cer" it has inside will have the following function when clicked - Again we define the var "ix", a son of the previous one; the result of the substraction of one character from the name of the symbol selected (so we get the mere number of the symbol, as there could be tons of them and we're using a for to simplify) - the function, using the TweenLite library effects, would be returning to it's position outside the display the symbol "z" + the number we get from the var "ix" just defined

Now, I can't find a reason why this instruction would be ignored, when a simple trace seems to work pretty well with the onPress; so this leads me to believe it has something to do with the TweenLite. Also I belive it could have something to do with the enable=false/true, but I've tried placing it at different moments on the function and not much seems to happen. I don't think it has something to do with the calling of the symbol -sorry, I'm just learning about all this so that's the way I can describe that-, because pretty much the very same code is used just before when the Content (z) is drawn into display and it works just fine.

Is it a structure problem? I found this on the Adobe Help site:

"NOTE If a movie clip that contains _root is loaded into another movie clip, _root refers to the Timeline of the loading movie clip, not the Timeline that contains _root. If you want to ensure that _root refers to the Timeline of the loaded movie clip even if it is loaded into another movie clip, use MovieClip._lockroot."

Since my close-button MovieClip is located inside the content MovieClip, would I need to use lockroot? If so, how?

I would really apreciate some advice.. Thank you for your time!

1

1 Answers

0
votes

You should try to avoid using absolute paths. Use relative instead. Just use this instead of _root