Jump to content
Search Community

Calculating a property of a always changing one.

dutzzzu test
Moderator Tag

Recommended Posts

Hello :)

 

I'm trying to do something and it seems i'm missing something;

 

i have a mc that i'm rotation according to it's own position on the stage, so i have an equation from which i get the actual rotation. I've tried something like

TweenLite.to(myMC,1,{x:500,rotation:myMc.x * 0.5});

But that doesn't work. It stops, and everytime the function if called makes another step. Can you please help me ?

 

Thanks, D.

Link to comment
Share on other sites

your code:

 

TweenLite.to(myMC,1,{x:500,rotation:myMc.x * 0.5});

 

is basing its END rotation off of the x valye of myMC when the tween starts.

Let's say you are starting at an x of 0, your end rotation will be 0*0.5 which will be 0.

 

I would suggest 2 things to try:

 

1: since you know the end x value is going to be 500 just use that value when you provide the end rotation:

TweenLite.to(myMC,1,{x:500,rotation:500 * 0.5});

 

2: you can apply your rotation calculation every time the tween is updated

TweenLite.to(myMC,1,{x:500, onUpdate:calculateRotation});

function calculateRotation(){
myMc.rotation = myMyc.x *.5;
}

 

both methods will most likely give you the same end result.

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.
×
×
  • Create New...