Jump to content
Search Community

Help with simple TweenLite Banner

Guest mlodesigns
Moderator Tag

Recommended Posts

Guest mlodesigns

Hi: Need some desperate help, I am new at this and I've been at it for over a month.

I have this 300x250 banner that I need to loop 3 times then stop, I need it to once it stop to stop at the 1st mc which is slogan_mc. Also I need this banner to be 25kb or less.

So far what I have is 20kb,but my problem is that all the Tweens happens all according to the delay but they all remain there. This results, in having 3 messages slide from the bottom up on top of each other.

What I need is for slogan_mc to slide, stay there for a few seconds to give time to read the fade out or slide out. Once this happens then I need for message1_mc to do the same and then message2_mc to do the same, finally i need this same process to play for 3 times then stop and go back to slogan_mc and stay there until page refresh.

I have tried TweenMax, and is too big file size, I have tried TimelineLite and also too big, I tried TweenNano, good file size but same result as now. Please help me fix my code.

post-8721-133152002565_thumb.png

 

This is my code:

import com.greensock.*;

import com.greensock.easing.*;

 

TweenLite.to(slogan_mc, 1, {y:130});

TweenLite.to(message1_mc, 1, {y:130, delay:1.2});

TweenLite.to(message2_mc, 1, {y:130, delay:2});

 

var paramList:Object = this.root.loaderInfo.parameters;

 

clickbtn.addEventListener(MouseEvent.CLICK, openURL);

 

function openURL(evtObj:MouseEvent):void {

var request:URLRequest = new URLRequest(paramList["clickTag"]);

navigateToURL(request, "_blank");

}

Link to comment
Share on other sites

sequencing tweens can get a little hairy without TimelineLite.

the trick is to keep track of the start time (delay) of all the tweens and keep a tally of the duration and delays of all the previous tweens.

that's what I'm doing with "newDelay" below.

 

I put together a little demo of 3 panels that perform a simple slide sequence that runs 3 times.

after the third time, slogan comes in and the banner stops.

 

the code looks like this:

 

import com.greensock.*;

//http://www.greensock.com/overwritemanager/
OverwriteManager.init(2);


//where everything starts
var startX:int = -300;
var startY:int = 0;

//where everything tweens to
var onX:int = 0;
var offX:int = 300;

var duration:Number = .5;

var delay:Number = 1;

//keeps track of how much time has elapsed in all previous tweens including all durations and delays
var newDelay:Number = 0;

//how many times the sequence has played and needs to play
var playCount:Number = 0;
var maxPlayCount:Number = 3;



//reset starting values of all clips
function init(){
slogan.x = startX;
slogan.y = startY;
message1.x = startX;
message1.y = startY;
message2.x = startX;
message2.y = startY;
playSequence();
}



function playSequence(){
//bring slogan in
TweenLite.to(slogan, duration, {x:onX});


newDelay = duration + delay;

//push slogan out and bring message1 in
TweenLite.to(slogan, duration, {x:offX, delay:newDelay});
TweenLite.to(message1, duration, {x:onX, delay:newDelay});


newDelay += duration + delay;


//push message 1 out and bring message 2 in
//when message 2 is in, check to see if the sequence should restart from beginning
TweenLite.to(message1, duration, {x:offX, delay:newDelay});
TweenLite.to(message2, duration, {x:onX, delay:newDelay, onComplete:checkSequence});

}	

function checkSequence(){
playCount++;


if(playCount 		
//restart the whole thing over	
TweenLite.delayedCall(delay, init);

}else{
	trace("end");

	//custom end sequence to push message2 out and bring slogan in
	TweenLite.to(message2, duration, {x:offX, delay:delay});
	slogan.x = startX;
	TweenLite.to(slogan, duration, {x:onX, delay:delay});


	}



}	

init();

 

it would probably be a bit easier to put all your panels into 1 movieclip and just move that movie clip around, but that wouldn't work so well with fading in/out

Link to comment
Share on other sites

Guest mlodesigns

Carl: You are Awesome!

 

This worked. It took me a couple of tries on the x and y values to get it to tween in the position that I wanted and some thinking on the delay time but it did the job.

I got to admit, I don't know action script, I want to learn it, and I am hoping to save money to take some classes on it, although lots of people keep telling me spending money on that it might not be worth it as some believe flash will be gone, and I am still skeptical.

 

With that being said, I admit there was no way I was going to figure that out on my own.

I owe you big time, please let me know how can I pay back the favor.

You can e-mail me if you want.

 

Thanks a million.

Link to comment
Share on other sites

you are welcome. glad you got it working.

 

I'm confident flash isn't going away, but there may be a slight shift in what it's used for.

As far as online advertising / banners go... I don't think the big companies are anywhere near ditching Flash. its a proven solution that works great and the user-base that has "up to date browsers that support the emerging standards" is way too small.

 

What's happening now with Flash / Air for game development on mobile devices is also very exciting.

 

---

 

I'm happy to help people that are eager to learn.

 

Best,

Carl

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