FORUMS: list search recent posts

AS3 tweens

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Neil Bradley
AS3 tweens
on May 24, 2009 at 2:39:45 am

Here is a link to a image viewer I am developing using Flash CS3 and AS3

I have activated three buttons to illustrate the task (marked by the text active over the button).

The viewer is simple enough and works nicely apart from one thing. The scrolling movement when activated by a button does not start from its current position (it starts from the very first value so it jumps then scrolls rather than scrolling from its last location).

I have set a variable to try and accommodate this but I cant get it to pick up on a new value of x (this value changes depending on which button was last clicked.
I have attached a code snipped showing my script.
Help much appreciated.

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

// the variable I need to set here should be the new starting point for the tween.
var boxMovieHome:Point = new Point();

// Three buttons that trigger the move.
btn1.addEventListener(MouseEvent.CLICK, slidePanel);
function slidePanel(mevt:MouseEvent):void {
// boxMovieHome.x is the key point here, as this point changes depending on which button was last clicked.
var myTween:Tween = new Tween(timeline, "x", Strong.easeOut, boxMovieHome.x, 478.2, 5, true);

btn5.addEventListener(MouseEvent.CLICK, slidePane5);
function slidePane5(mevt:MouseEvent):void {

var myTween:Tween = new Tween(timeline, "x", Strong.easeOut, boxMovieHome.x, -754.8, 5, true);

btn20.addEventListener(MouseEvent.CLICK, slidePane20);
function slidePane20(mevt:MouseEvent):void {
var myTween20:Tween = new Tween(timeline, "x", Strong.easeOut, boxMovieHome.x, -5238.9, 5, true);

Return to posts index

Pieter Helsen
Re: AS3 tweens
on May 24, 2009 at 11:15:32 am

Do not use Flash's built-in Tween class. As soon as you want a somewhat more advanced tween, it will let you down.

Instead, use TweenLite (also has a bigger brother, called TweenMax, but since you'll only be doing motion tweens, you won't need it, and it saves you in size.)

One benefit is that TweenLite has a .to() function. This means that you don't have to specify a starting parameter, it will just start tweening from where it is at that precise moment.

The code would look something like this:, duration, {parameters});
or in your case:, 5.0, {x:-755, ease:Quad.easeOut});

Have a look at the TweenLite homepage to see what other parameters there are (there's a wholllle bunch)

Kind regards,

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.

Return to posts index

Neil Bradley
Re: AS3 tweens
on Jun 3, 2009 at 8:14:46 am

Thanks for the tip. I will follow it up.

Return to posts index

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