[Tweener] question

Zeh Fernando zehfernando at zeh.com.br
Tue Jun 12 19:02:04 PDT 2007


Hello Brice,

> hello,
> thanx a lot for this class
> i have a little question > how to refer to "this" ?
> example >
> bloc["diapo_"+nom_galerie+"_"+j].onRelease = function() {
>    Tweener.addTween(this, {_x:this.iniX, _y:this.iniY, time:1, 
> transition:"linear"});
> };

Hm.. I'm not sure I understand the question.

Using "this" inside the onRelease would already refer to the 
bloc["diapo_nn_nn"] object, so that line of code is standard practice 
with AS2 and it should work.

If you need to refer to the object that is assigning the onReleases (the 
current scope where the code is located) you could use a separate 
variable. For example:

var mThis = this;
bloc["diapo_"+nom_galerie+"_"+j].onRelease = function() {
    Tweener.addTween(mThis, {_x:mThis.iniX, _y:mThis.iniY, time:1, 
transition:"linear"});
};

On the above case, the tween would be ran on the MASTER object, not the 
button.

Usually using "this._parent" or something would also work, but it 
depends on how your movie is structured.

But again, I'm not sure that's what you're asking.


Zeh


More information about the tweener mailing list