Jump to content
Search Community

Tween Overwrite Not Working... Ever

Nick505 test
Moderator Tag

Recommended Posts

Hi,

 

I am sure this shows up a lot in the forums. I am a complete new guy to FLash, and I love TweenLite! But I am having trouble with the Overwrite manager. I am losing a lot of hair over the matter too.

 

here is the issue: I have a frame (frame_mc) that loads images dynamically from a file into flash. I have placed an awesomely easy to implement TweenLite alpha tween that fades each image in as they appear (all through one frame (frame_mc). Problem is if I click too rapidly, the tweens stack and overwrite, and soon enough I am looking at no images as I click the buttons....

 

Here is my code. I left out all the unnecessary code, as the script itself works fine, it is just the Overwrite manager code that I am having issues with. (don't laugh too hard):

 

import com.greensock.OverwriteManager;

import com.greensock.TweenLite;

 

function thumb1click(event:MouseEvent):void {

big_pic.load(img1Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb2click(event:MouseEvent):void {

big_pic.load(img2Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb3click(event:MouseEvent):void {

big_pic.load(img3Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb4click(event:MouseEvent):void {

big_pic.load(img4Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb5click(event:MouseEvent):void {

big_pic.load(img5Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb6click(event:MouseEvent):void {

big_pic.load(img6Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

function thumb7click(event:MouseEvent):void {

big_pic.load(img7Req);

frame_mc.removeChildAt(1);

frame_mc.addChild(big_pic);

TweenLite.from(frame_mc,1,{alpha:0});

}

 

No matter where I place: OverwriteManager.init(OverwriteManager.AUTO); it never seems to work. I have spent hours trying different combination's (and the other options suggested). I am obviously overlooking something. Please help!

Link to comment
Share on other sites

This isn't an overwriting issue - it's just a logic thing with the way you set up your tweens. Remember, when you do a from() tween, it tweens from the value you define in the tween TO WHATEVER IT IS CURRENTLY. That last part is obviously the key :) So let's say the first time you click the alpha is 1 and you do a from() that takes it from an alpha of 0. Great. But then right in the middle of the tween, when the alpha is 0.5, you click again and start another from() tween. The tween says "okay, start at 0 and go to...let's see...what is the alpha now? 0.5, okay that's the end value". So when your tween is done, it will be 0.5 instead of 1. That's not a bug or overwrite error or anything - it's exactly how from() tweens are supposed to work.

 

The solution is to either do a TweenMax.fromTo() so that you can define both the starting and ending values, or simply set the alpha to 1 manually right before you do the from() tween, or set it to 0 initially and do a to() tween.

 

mc.alpha = 0;
TweenLite.to(mc, 1, {alpha: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.
×
×
  • Create New...