PDA

View Full Version : images not looping


chichi2
10-01-2010, 10:50 AM
Hello Everyone,

I have this code and it works quite well except for the fact that I would like it to loop continuously. Does any one have any small suggestions to help me out?

import mx.transitions.Tween;
import mx.transitions.easing.*;

var tweenIn:Tween;
var tweenOut:Tween;
var easeFunc:Function = None.easeIn;
var time:Number = 3;
var clipArray:Array = new Array(mc1, mc2, mc3);
var currentClip:MovieClip;
var iterator:Number = 0;


setNextClip();

function setNextClip():Void
{
currentClip = clipArray[iterator];
iterator++;
fadeIn();
}

function fadeIn():Void
{
tweenIn = new Tween(currentClip, "_alpha", easeFunc, 0, 100, time, true);
tweenIn.onMotionFinished = fadeOut;
}

function fadeOut():Void
{
tweenOut = new Tween(currentClip, "_alpha", easeFunc, 100, 0, time, true);
tweenOut.onMotionFinished = setNextClip;


}

Thank you very much,

chichi

eryx
10-01-2010, 07:12 PM
setting the iterator to 0 if it is the same size as the array.

this should work

function setNextClip():Void
{
if(iterator => clipArray.lenght){
iterator = 0;
}
currentClip = clipArray[iterator];
iterator++;
fadeIn();
}


you can also add of images to the array and it will loop through those as well.

chichi2
10-04-2010, 09:07 AM
Thanks for the tip, tried it, tried to adjust it and still doesnt seem to work quite well. Any other suggestions?

chichi