Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Guest docTorbin

Is it possible to change y value using onUpdate

Recommended Posts

We are using tweenlite to move an item that has the potential to be animating when the user also clicks full screen. If left unchecked, this could result in a malformed animation. I see that we can check each state with onUpdate but how would we go about changing the value of y? For example, here is our call:


TweenLite.to(mySprite, .5, {y:totalHeight - 43, ease:Back.easeOut, easeParams:[.75], onUpdate:checkTotalHeight, onUpdateParams:[ ? ]});


What could we pass via onUpdateParams that would allow us to change y?



Share this post

Link to post
Share on other sites

in the onUpdateParams you would include any paramaters that your checkTotalHeight function needs to operate. I don't know exactly what checkTotalHeight() does so I can't recommend what the params should be. in some situations you would pass in the target of the tween, so you may do something like




but i don't think that is necessary for what you are doing.




Ultimately you are probably going to want to use TweenMax's updateTo() method which will allow you to set a new x value for the destination.


consider the following example:


var tween:TweenMax = TweenMax.to(mc, 4, {x:400});

stage.addEventListener(MouseEvent.CLICK, updateTween);

function updateTween(e:MouseEvent):void{


using the above code, the tween will start moving mc to an x of 100, when you click anywhere on the stage the tween will proceed to move mc back to an x of 0.


also, it is totally reasonable that when you detect that the height of the stage has resized you can just recreate the tween as well.


so basically you need checkTotalHeight() to determine whether or not the tween needs to be changed. When that condition is true, either use updateTo() to set a new x value or create a new tween. updateTo() has the advantage of honoring the tween's current timing.


keep in mind that if you use updateTo() you may also want to enforce that the onUpdate callback isn't still firing after the tween has been given a new x value. You can null it out like so


tween.updateTo({x:0, onUpdate:null});

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.