Jump to content
GreenSock

chrisatflash

Tweenlight, how to remove listener when using: onUpdate

Recommended Posts

Hello,

When you initialise a tween :

TweenLite.to(this, .7, { rotation:45, ease:Quad.easeIn, onUpdate:onUpdateCheck});

 

Can you remove the onUpdate listener of a Tweenlight too, like the adobe tween?

 

function onTweenUpdate(e:TweenEvent):void {

if(some condition) {

e.currentTarget.removeEventListener(TweenEvent.MOTION_CHANGE,onUpdateCheck);

}

}

Link to comment
Share on other sites

Hey ChristaFlash,

 

Yeah you can remove an eventListener. To my understanding proper eventListeners and the callBack functions that add as tween properties are a little different.

To implement an eventListener on a tween that is removable the following approach will work:

 

import com.greensock.*

import com.greensock.events.TweenEvent;

 

var tweenMc:TweenMax = TweenMax.to(mc, 5, {x:600});

 

tweenMc.addEventListener(TweenEvent.UPDATE, updateFunc)

 

function updateFunc(e:TweenEvent):void{

trace("update " + mc.x);

if(mc.x>300){

trace("update done");

tweenMc.removeEventListener(TweenEvent.UPDATE, updateFunc);

}

}

Link to comment
Share on other sites

Thanks Carl! This is exactly what i was looking for! :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×