Skip to main content
February 11, 2011
Question

using onChange function with TweenLite

  • February 11, 2011
  • 1 reply
  • 2122 views

Does TweenLite or TweenMax support the onChange function?

I would like to re-code using TweenLite/TweenMax to get my textbox to numerically display the constantly changing x position of my tween.

I did have this code before:

I tried some variations with the following to no avail:

nextTween1.addEventListener(TweenEvent.MOTION_CHANGE, onChange);
function onChange(evt:TweenEvent):void {
mph_digital.mph_counter.text = int((dial_graphics_mph.x * .20528)*10)/10;
}

also how do i define tweens as variables now with TweenLite / TweenMax?

Thanks!

This topic has been closed for replies.

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
February 11, 2011

Use "onUpdate" property

somascope
Inspiring
February 13, 2011

kennethkawamoto2 has it correct. Here is what I came up with for an example:

I have a Movieclip on the stage named 'myClip'

I have a TextField on the stage named 'myText'

import com.greensock.*;

import com.greensock.easing.*;

TweenLite.to(myClip, 5, { x:500, onUpdate:showUpdateStuff, onUpdateParams:[myClip] } );

function showUpdateStuff(obj:DisplayObject):void{

   myText.text = String(obj.x);

   // Or, if you don't use onUpdateParams to pass a reference of the object:

   // (doing so keeps this function more reusable)

   // myText.text = String(myClipbj.x);

}