perloe Posted July 15, 2011 Share Posted July 15, 2011 I know this is probably a very basic question but I can't figure out how to simply increase the value of a variable over time. So for example, if I have: var counter:int = 0; and I want to increase it to a new value of 10 over 5 seconds, how would I do that? Thanks! Link to comment Share on other sites More sharing options...
Carl Posted July 16, 2011 Share Posted July 16, 2011 Tweening a variable is no different than tweening the x property of a movie clip. I understand how the concept can sound weird at first. I have a tutorial and source files here: http://www.snorkl.tv/2010/09/how-to-twe ... tweenlite/ an important thing to note is that while you are tweening the variable, you most likely want to display it somehow. by using an onUpdate callback you can run a trace or update a textfield. here is some sample code: import com.greensock.*; import com.greensock.easing.*; var score:Number = 0; var targetScore:Number = 20; TweenLite.to(this, 1, {score:targetScore, onUpdate:showScore, ease:Linear.easeNone}); function showScore(){ trace(score); score_mc.score_txt.text = int(score); } Link to comment Share on other sites More sharing options...
perloe Posted July 16, 2011 Author Share Posted July 16, 2011 Thanks! This helps a lot. Link to comment Share on other sites More sharing options...
algro Posted July 23, 2011 Share Posted July 23, 2011 When I use the example before I get the error #1069: Property score not found for "ClassX" What am I doing wrong ? Here my Code: package { import com.greensock.TweenLite; import flash.display.Sprite; public class TweenTest extends Sprite { private var _test:Number = 10; public function TweenTest() { TweenLite.to(this,1,{_test:200}); } } } Link to comment Share on other sites More sharing options...
Carl Posted July 23, 2011 Share Posted July 23, 2011 are you posting all of your code? I don't see a ClassX nor do I see a score referenced anywhere. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now