Jump to content
Search Community
dev-kp test
Moderator Tag

Recommended Posts

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

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() + "%"
}
  • Like 1
Link to comment
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.
×
×
  • Create New...