shiftless
07-02-2008, 09:53 PM
I have a crossfading slideshow in CS3 (using AS2) that has one little problem I can't figure out. When you click any of the navigation buttons (labeled 1-4) it does switch out to the proper photo, but you always see a glimpse of the first photo (of the array) before it quickly tweens to the correct photo, and I can't figure out why. I've put the file here:
http://www.aftermath-creative.com/mw2.2.fla
and here's the code, it's basically crossfading 2 empty movie clips in the crossfade function. I think I need to add code to the 4 buttons but I can't figure it out. HELP!:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 7;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
Button.prototype.enabled = false;
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
Button.prototype.enabled = true;
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
Button.prototype.enabled = false;
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
Button.prototype.enabled = true;
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onPress = function() {
buttons.gotoAndStop('pic0');
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.secondButton.onPress = function() {
buttons.gotoAndStop('pic1');
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.thirdButton.onPress = function() {
buttons.gotoAndStop('pic2');
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.fourthButton.onPress = function() {
buttons.gotoAndStop('pic3');
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
http://www.aftermath-creative.com/mw2.2.fla
and here's the code, it's basically crossfading 2 empty movie clips in the crossfade function. I think I need to add code to the 4 buttons but I can't figure it out. HELP!:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 7;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
Button.prototype.enabled = false;
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
Button.prototype.enabled = true;
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
Button.prototype.enabled = false;
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
Button.prototype.enabled = true;
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onPress = function() {
buttons.gotoAndStop('pic0');
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.secondButton.onPress = function() {
buttons.gotoAndStop('pic1');
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.thirdButton.onPress = function() {
buttons.gotoAndStop('pic2');
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};
buttons.fourthButton.onPress = function() {
buttons.gotoAndStop('pic3');
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
picInt = setInterval(crossfade,showpicTime*1000);
crossfade();
};