FORUMS: list search recent posts

Tween Class starts by itself

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bryan Myhr
Tween Class starts by itself
on Dec 21, 2009 at 7:39:37 am

I'm trying to use a tween class to bring in an object in Actionscript 3.0. For some reason the Tween Class always starts on it's own. I want it to start when I click a button. Here's what I've got.

var cont_tw:Tween = new Tween(thmb, "y", Strong.easeIn, 700, 0, 5, true);

cont_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent){cont_tw.start();}

I know I'm missing something simple, but it's driving me crazy, thanks!

Return to posts index

Peter Mackay
Re: Tween Class starts by itself
on Dec 21, 2009 at 6:24:27 pm

Try writing it exactly like this:

import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;

var cont_twTween = new Tween (thmb, "y", strong.easeIn, 700, 0, 5, true);

//handle events for buttons...
this.cont_btn.addEventListener (MouseEvent.CLICK, startTween);

function startTween (evtObj:MouseEvent)

//trace shows what is happening.. in the output window
trace("The cont button was clicked!")


There was a semicolon in there that I don't think should be.

Return to posts index

Marcus Geduld
Re: Tween Class starts by itself
on Dec 22, 2009 at 3:00:37 pm

Due to the stupid way Adobe wrote their Tween class, tweens are triggered by the class's constructor. In other words, wrting new Tween(...) causes a tween to happen. So you either need to use a third-party tween engine (e.g. gtween) or delay running the constructor until within the button code:

button.addEventListener( MouseEvent.CLICK, clickHandler );

function clickHandler( event : MouseEvent ) : void
new Tween( ... );

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer,

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved