Jump to content
Search Community

Help with TweenLite

Spectre90 test
Moderator Tag

Recommended Posts

Hey guys, first of all i just wanna say i love TweenLite and all the other GreenSock stuff.

its made my life a whole lot easier for my flash projects :D

 

But anyway... I was just wondering how i can make a tween i've created with TweenLite only play when it is interacted with by buttons.

So far i've got the following code:

import com.greensock.*;

import com.greensock.easing.*;

import flash.events.MouseEvent;

 

var ADtimeline:TimelineLite = new TimelineLite();

 

ADtimeline.insert(TweenLite.to(MC_ADTHUMBS, 8, {x:"1945"}))

 

 

MC_ADNAV_RIGHT.addEventListener(MouseEvent.ROLL_OVER, PlayRight)

MC_ADNAV_RIGHT.addEventListener(MouseEvent.ROLL_OUT, PauseRight)

 

function PlayRight(event:MouseEvent):void{

ADtimeline.play();

}

 

function PauseRight(event:MouseEvent):void{

ADtimeline.pause();

}

 

 

MC_ADNAV_LEFT.addEventListener(MouseEvent.ROLL_OVER, PlayLeft)

MC_ADNAV_LEFT.addEventListener(MouseEvent.ROLL_OUT, PauseLeft)

 

function PlayLeft(event:MouseEvent):void{

ADtimeline.reverse();

}

 

function PauseLeft(event:MouseEvent):void{

ADtimeline.pause();

}

 

 

All of the buttons work fine, its just that the tween automatically plays at the start and i dont want it to.

This might be a nooby question but i'd really appreciate the help, thanks

:)

Link to comment
Share on other sites

Hi Spectre90,

There's just a small addition you need to set when you instantiate your TimelineLite, you need to set it to 'paused' if you don't want it to play straight away:

var ADtimeline:TimelineLite = new TimelineLite({paused:true});

I hope that helps, let us know if you run into any more problems.

You may also find the documentation a good resource: http://www.greensock.com/as/docs/tween/

 

X10

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