jdfinch3 Posted July 31, 2015 Share Posted July 31, 2015 I'm drawing a large shape using an array of points in a for loop and tweenlite as found at http://www.flashperfection.com/tutorials/Animated-line-drawing-using-TweenLite-in-AS3-22013.html for(var i:uint = 0; i < pointsArray.length; i++){ TweenLite.to(dot2, .05, {x:pointsArray[i].x, y:pointsArray[i].y, delay:i*.05, overwrite:false, onUpdate:updateHandler}); } function updateHandler():void{ lineAnim.graphics.lineTo(dot2.x, dot2.y); lineAnim.graphics.moveTo(dot2.x, dot2.y); } I would like the animation to complete before continuing, but I'm unable to find a way to be notified when the full animation is complete. onComplete does not work as it triggers on the first set of coords. I also tried triggering when i == pointsArray.length but the loop finishes multiple seconds before the animation completes. I would like to avoid using a timer. Link to comment Share on other sites More sharing options...
jdfinch3 Posted July 31, 2015 Author Share Posted July 31, 2015 I found a work around by using an if statement that checks for the final coords of dot2, but I'm still curious to find an actual solution as opposed to a work around. Link to comment Share on other sites More sharing options...
Carl Posted July 31, 2015 Share Posted July 31, 2015 For something like this I would recommend that you use your loop to generate tweens that get placed in a timeline. That will make them all play in direct succession. import com.greensock.*; import com.greensock.easing.*; var points:Array = [{x:100, y:100}, {x:200, y:0}, {x:300, y:100}]; var tl:TimelineLite = new TimelineLite(); for (var i:int = 0; i < points.length; i++){ tl.to(mc, 0.5, {x:points[i].x, y:points[i].y}) } Just create an FLA that has a MovieClip with instance name mc to test. Check out the TimelineLite docs for more info: http://greensock.com/asdocs/com/greensock/TimelineLite.html#to() 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