Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
flash08

FadeIn/fadeOut works for 12 steps, then fails!

Recommended Posts

De-lurking here. I have a little script I use for small photo displays that just run through an array of images, fading each one out as the next fades in.

If I try to increase the size of the array beyond 12 MC's (each one holds a single symbol = photo), instead of continuing the fadeIn/fadeOut, the transition just jumps to the next item in the array. I have tried all sorts of different symbols, and the result is that same: more than 12 MC's, and the fading fails. When the array has been run through, it starts again at the beginning, as it should, and the fading returns to normal until it hits p_thirteen, which jumps in, and after the delay, jumps again back to p_one. Any idea of what's going on here? TIA for your collective wisdom!

 

Here's the code:

import gs.TweenLite;

 

var pixArray:Array = [p_one, p_two, p_three, p_four, p_five, p_six, p_seven, p_eight, p_nine, p_ten, p_eleven, p_twelve, p_thirteen];

var pic:MovieClip;

var index:Number = 0;

 

doFadeIn(pixArray[0]);

 

function doFadeIn(mc:MovieClip):Void {

TweenLite.to(mc,5,{_alpha:100, onComplete:nextImage, onCompleteParams:[mc]});

}

 

function nextImage(mc:MovieClip) {

doFadeOut(mc);

index++;

if(index > pixArray.length - 1) {

index = 0;

}

doFadeIn(pixArray[index]);

}

 

function doFadeOut(mc:MovieClip):Void {

TweenLite.to(mc,3,{_alpha:0});

Link to comment
Share on other sites

Hey there- I've attached a working example. One thing i did notice is that you are using _alpha, which is as2, my example works in as3 as it uses alpha. For example:

 

import gs.TweenLite;

var pixArray:Array = [p_1,p_2,p_3,p_4,p_5,p_6,p_7,p_8,p_9,p_10,p_11,p_12,p_13,p_14,p_15];
var pic:MovieClip;
var index:Number = 0;

//start with first item in array
doFadeIn(pixArray[0]);

function doFadeIn(mc:MovieClip):void {
TweenLite.to(mc,.1,{alpha:1, onComplete:nextImage, onCompleteParams:[mc]});
}

function nextImage(mc:MovieClip):void {
doFadeOut(mc);
index++;
if (index > pixArray.length - 1) {
	//sets index back to 0 when finished, looping the animation
	index = 0;
}
doFadeIn(pixArray[index]);
}

function doFadeOut(mc:MovieClip):void {
TweenLite.to(mc,3,{alpha:0});
}

Link to comment
Share on other sites

Thanks. Unforunately, I'm stuck with AS2, as I don't do much Flash development, and my current version is MX2004.

 

I changed the alpha's back to _alpha, but the script won't run. I've got to check the syntax differences, as I think the basic idea is pretty simple. I just can't figure out why the action on the array should fail after the 12th array item in my original AS. Could be related to Flash having to render all of those picture files - whose alpha and visibility should be set to zero before any of the fading happens.

Link to comment
Share on other sites

Another example attached, but in as2, created in cs3. Is working just fine for me...

 

import com.greensock.TweenLite;

var pixArray:Array = [p_1,p_2,p_3,p_4,p_5,p_6,p_7,p_8,p_9,p_10,p_11,p_12,p_13,p_14,p_15];
var pic:MovieClip;
var index:Number = 0;

//start with first item in array
doFadeIn(pixArray[0]);

function doFadeIn(mc:MovieClip) {
  TweenLite.to(mc,.1,{_alpha:100, onComplete:nextImage, onCompleteParams:[mc]});
}

function nextImage(mc:MovieClip) {
  doFadeOut(mc);
  index++;
  if (index > pixArray.length - 1) {
     //sets index back to 0 when finished, looping the animation
     index = 0;
  }
  doFadeIn(pixArray[index]);
}

function doFadeOut(mc:MovieClip) {
  TweenLite.to(mc,3,{_alpha:0});
}

Link to comment
Share on other sites

Thank you! There are some strange things going on with this script, too.

 

The fades work until the script gets to the next to last image in the array. On the first playback, that image just appears, no fade in. Then the last image loads the same way - just jumps in. When it's time to start the array again, it jumps to the first image, and all proceeds normally until the same stuff happens again at the next to last image.

 

Except on the next playback, there is time when there is no image shown, then one jumps in, jumps out, more blank screen, then the jump to the beginning of the array!

 

Wasn't there something about AS2 not properly "trashing" images once they had appeared on screen? It seems to me as if there is some sort of image caching that's breaking down as the number of images increases. There is never any funny stuff in the first 10 or so array images on any playback.

 

Ideas? NB: I'm getting the feeling I need to go out and get the CS4 upgrade...

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