Jump to content
Search Community

vairable MovieClip speed based on button press

BabaBlackSheep test
Moderator Tag

Recommended Posts

Hi and welcome to the GreenSock forums.

 

Every tween has a timeScale() that can be adjusted.

When you increase the timeScale() of a tween it will play faster.

 

You can create a tween using our FramePlugin (enabled by default in TweenMax) that will scrub the playhead of a movie clip forward over time (demo)

 

The code below will make a movie clip animation play faster each time the stage is clicked:

 

import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;


//prevent mc from playing on its own
mc.stop();


//create a tween using frame plugin to move playhead of mc to frame 60 over the course of 1 second
var tween:TweenMax = TweenMax.to(mc, 1, {frame:60, repeat:200, ease:Linear.easeNone}); //use Linear ease for best results


//click the stage to increase the speed of the tween that controls mc
stage.addEventListener(MouseEvent.CLICK, goFaster);


function goFaster(e:MouseEvent):void {
tween.timeScale(tween.timeScale() + 0.1) 
trace(tween.timeScale())
}
Flash CC Fla and swf attached.

framePlugin_clickFaster.zip

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...