Jump to content


How to make banner loop in AS2

Recommended Posts

Hi All,


Does anyone know how to make the banner loop in AS2? Can it be done in TweenNano?

Below is my code so far:





import com.greensock.*;
import com.greensock.easing.*;

//Scene 1

TweenNano.to(bg1, 1, {_x:0, _y:0, _alpha:100, ease:Cubic.easeOut});
TweenNano.to(logo, 1, {_x:13, _y:20, _alpha:100, delay:.5, ease:Fade.easeOut, overwrite:false});
TweenNano.to(text1, 1, {_x:267.35, _y:45, _alpha:100, ease:Cubic.easeOut, delay:1.3, overwrite:false});
TweenNano.to(text2, 1, {_x:378, _y:45, _alpha:100, ease:Cubic.easeOut, delay:3.5, overwrite:false});
TweenNano.to(text3, 1, {_x:475.05, _y:45, _alpha:100, ease:Cubic.easeOut, delay:4.5, overwrite:false});
TweenNano.to(text4, 1, {_x:584.2, _y:45, _alpha:100, ease:Cubic.easeOut, delay:5, overwirte:false});

TweenNano.to(bg1, 1, {_x:0, _y:0, _alpha:0, ease:Cubic.easeOut, delay:7.5, overwrite:false});
TweenNano.to(text1, 1, {_x:267.35, _y:45, _alpha:0, ease:Cubic.easeOut, delay:7.5, overwrite:false});
TweenNano.to(text2, 1, {_x:378, _y:45, _alpha:0, ease:Cubic.easeOut, delay:7.5, overwrite:false});
TweenNano.to(text3, 1, {_x:475.05, _y:45, _alpha:0, ease:Cubic.easeOut, delay:7.5, overwrite:false});
TweenNano.to(text4, 1, {_x:584.2, _y:45, _alpha:0, ease:Cubic.easeOut, delay:7.5, overwirte:false});

TweenNano.to(bg2, 1, {_x:0, _y:0, _alpha:100, ease:Cubic.easeOut, delay:7.8, overwrite:false});
TweenNano.to(text5, 1, {_x:362.3, _y:27.5, _alpha:100, ease:Cubic.easeOut, delay:8, overwrite:false});

TweenNano.to(CTA, 1, {_x:629.45, _y:35.5, _alpha:100, ease:Cubic.easeOut, delay:8.5, overwrite:false});

Many Thanks!

Link to comment
Share on other sites

The trick is you need to reset all your properties of all your objects to their pre-tweened values.


import com.greensock.*;

//record initial values;
var blueStartX = blue._x;
var redStartX = red._x;
var greenStartX = green._x;
var greenStartY = green._y;

//reset props to initial values on repeat
function repeat() {
blue._x = blueStartX;
red._x = redStartX;
green._x = greenStartX;
green._y = greenStartY;
red._alpha = blue._alpha = green._alpha = 100;

function animate() {
TweenNano.to(blue, 1, {_x:200, _alpha:0});
TweenNano.to(red, 1, {_x:300, _alpha:0, delay:1});
TweenNano.to(green, 1, {_x:400, _y:400, delay:2, _alpha:0, onComplete:wait})

//call repeat after 1 second
function wait() {
  TweenNano.delayedCall(1, repeat);


see attached CS5 fla and swf



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