Search code examples
actionscript-3flashactionscriptgsap

greensock tween find end rotation of bezier curve


Let me tell you a scenario which am facing right now , I have a movieclip which will move along the bezier curve and a button which will start the play(movie clip will move along the curve) and bezier points , am using greensock which have an autorotate option where you will rotate the movie clip along the path.

so i need to know what rotation will the movieclip will be at the end of play , because when auto rotate is enabled my rotation at start time will be 0 but by the end time of the play what will it be ???? I need to know that value before the tween happens , please help!


Solution

  • There is, of course, math that you could do to figure it all out, but it's probably easier to just let the tween handle it and simply jump to the end, read the value, and rewind again. No need to create a separate tween that lasts 0.0001 seconds and wait for an onComplete or anything like that - just use the original tween:

    var tween:TweenMax = TweenMax.to(...); //your bezier tween
    tween.progress(1); //jump to the end
    var endRotation:Number = mc.rotation; //read the final rotation
    tween.progress(0); //rewind back to the beginning