[Tweener] How to get to the Tweener target via onComplete
Zeh Fernando
zehfernando at zeh.com.br
Sun May 18 18:40:27 PDT 2008
Mitchell Hudson wrote:
> I'd like to reference the target of a tween through the call to
> onComplete. Is this possible?
>
> It seems that the onCompleteParams would be one method. Does, this
> provide a single parameter to the onComplete function that is an
> array? For example:
>
> Tweener.addTween( _mc, { alpha:1, time:1, onComplete:test,
> onCompleteParams:[ _mc ] } );
> function test( _array ) {
> trace( _array[0] ); // The object that just completed the tween
> }
>
> Is the idea or am I missing something?
>
> Or is there a better way? I keep thinking there might be a way to
> access the target object of the tween.
You can access the object of the tween with a "this", since it's the
scope from within the function is ran.
function test() {
trace( this );
}
Using onCompleteParams work, but it's passed as an array and received as
*arguments*, so the correct code for your example above to work would be
this:
function test( mc ) {
trace( mc );
}
Zeh
More information about the Tweener
mailing list