I’m doing a photo slideshow and I have 4 photos. I have them displaying randomly with TweenLite, however I have 2 more things I’d like to do with it but I really don’t know how to do them. I’d like for the photos to display randomly forever, as if the script would never end. Also, I’m curious as to why only 3 of the 4 photos are displayed when I run the swf.
Here is my script thus far:
import gs.TweenLite;
import gs.easing.*;
var photoNums:Array = new Array(photo_1,photo_2,photo_3,photo_4);
var randPhotos:Array;
var currentPhoto:uint = 0;
function shuffle(a:Array):Array
{
var len:Number = a.length-1;
for (var ivar:Number = len; ivar>=0; ivar--)
{
var p:Number = Math.floor(Math.random()*(ivar+1));
var t = a[ivar];
a[ivar] = a[p];
a[p] = t;
}
return a;
}
randPhotos = shuffle(photoNums);
var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void
{
if (currentPhoto > 0)
{
TweenLite.to(this.randPhotos[currentPhoto], .75, {x:140, y:0, alpha:0, ease:Back.easeInOut});
}
TweenLite.to(this.randPhotos[currentPhoto+1], .75, {x:600, y:0, alpha:1, ease:Back.easeInOut});
currentPhoto += 1;
}
trace(photoNums);
Any help would be extremely appreciated.