dev-kp Posted February 10, 2015 Share Posted February 10, 2015 Hi, Hope someone can help me with with this. I am trying to find a way to create a "wind effect / drift". A movie clip will be constantly be pushed back -x but clicking the stage will make it move forward +x the more you click the faster it moves. If the clicks stop it will slowly slowdown and start to drift backwards. Any support is much appreciated! Thx Link to comment Share on other sites More sharing options...
dev-kp Posted February 10, 2015 Author Share Posted February 10, 2015 Got it working: import com.greensock.*; import com.greensock.easing.*; mc.meter.text = "0%" var push = 2 var strain = .7 // 1 normal .5 moderate .3 hard var speedCounter = 0 var tween = TweenLite.to(this, strain, {push: 1,ease: Back.easeInOut,onUpdate: showScore, paused:true}) var tl = TweenLite.to(mc, 20, {x: stage.stageWidth-mc.width/2,ease: Linear.easeNone,paused: true, onUpdate: showProgress, onComplete:done}) stage.addEventListener(MouseEvent.CLICK, changeScore); function showScore() { if (push == 1) { tl.reverse(); speedCounter = 0 tl.timeScale(.5); } else { tl.play(); if(speedCounter == 0){ tl.timeScale(1); } } } function changeScore(e: MouseEvent): void { push = 2 speedCounter+=.1 tl.timeScale(1+speedCounter); tween.restart(); } function done():void{ tl.kill(); tween.kill(); } function showProgress():void{ mc.meter.text = (int(tl.totalProgress()*100)).toString() + "%" } 1 Link to comment Share on other sites More sharing options...
Carl Posted February 10, 2015 Share Posted February 10, 2015 Cool! thanks for letting us know. 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