Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Henry

I wish roundProps would work here

Recommended Posts

Hello

 

I'm trying to tween a value of an object like this:

 

var _obj = {v:0};
TweenMax.to(_obj, 1, {v:100, ease: Linear.easeNone, onUpdate:onTweenUpdate})
}

function onTweenUpdate ()
{
 console.log(_obj.v)
}

 

This works fine but what it actually needs are rounded values. I thought "roundProps" would come in handy but the following change causes an error in TweenMax.js:

 

TweenMax.to(_obj, 1, {v:100, roundProps:"v", ease: Linear.easeNone, onUpdate:onTweenUpdate})

 

Is this code wrong or does "roundProps" not work that way?

 

What I actually would like to do with it is tweening the "currentAnimationFrame" of an EaselJS BitmapAnimation.

 

I used the "onTweenUpdate" function from the example above together with Math.round() as a workaround. But it would be much nicer to tween the currentAnimationFrame directly.

 

Any ideas anyone?

 

Cheers

 

 

Henry

Link to post
Share on other sites

It sounds like maybe you forgot to load the RoundPropsPlugin JavaScript file. Right?

Link to post
Share on other sites

Hello and thanks for your quick reply.

 

I used TweenMax.js. According to the documentation the plugin would be included. I just run a test with RoundPropsPlugin.js loaded as well. But it makes no difference. Well - a small difference: The error comes from RoundPropsPlugin.js now. ( Uncaught ReferenceError: _tween is not defined, line:56, Tested in Firefox and Chrome )

 

Your answer sounds like it should work? I reduced my code to the following copy/paste example. Perhaps it helps to find out what I'm doing wrong:

 

<!doctype html>
<html>
 <head>
<title>RoundProps Test</title>
<meta charset="utf-8" />
<script type="text/javascript" src="http://www.greensock.com/js/src/TweenMax.min.js"></script>
<script type="text/javascript">
  //<![CDATA[
var _obj = {v:0};
 TweenMax.to(_obj, 1, {v:100, roundProps:"v", ease: Linear.easeNone, onUpdate:onTweenUpdate})
 function onTweenUpdate ()
 {
console.log(_obj.v)
 }
//]]>
</script>
 </head>
 <body>
 </body>
</html>

 

 

 

Greetings

 

 

Henry

Link to post
Share on other sites

Ah yes, the code was missing a "this." - good catch. Sorry about that - it should be fixed in the latest version.

Link to post
Share on other sites

Hello Jack

 

It perfectly works now.

Thanks for fixing this so quickly.

 

Henry

Link to post
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.

×