1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| // USER CONFIG SETTINGS =====
var autoStart:Boolean = false; //true, false
var secondsDelay:Number = 1; // 1-60
// END USER CONFIG SETTINGS
// EVENTS =====
playPauseToggle_mc.addEventListener(MouseEvent.CLICK, fl_togglePlayPause);
function fl_togglePlayPause(evt:MouseEvent):void
{
if(playPauseToggle_mc.currentLabel == "play")
{
fl_startSlideShow();
playPauseToggle_mc.gotoAndStop("pause");
}
else if(playPauseToggle_mc.currentLabel == "pause")
{
fl_pauseSlideShow();
playPauseToggle_mc.gotoAndStop("play");
}
}
next_btn.addEventListener(MouseEvent.CLICK, fl_nextButtonClick);
prev_btn.addEventListener(MouseEvent.CLICK, fl_prevButtonClick);
function fl_nextButtonClick(evt:MouseEvent):void
{
fl_nextSlide();
}
function fl_prevButtonClick(evt:MouseEvent):void
{
fl_prevSlide();
}
var currentImageID:Number;
var slideshowTimer:Timer;
var appInit:Boolean;
function fl_slideShowNext(evt:TimerEvent):void
{
fl_nextSlide();
}
// END EVENTS
// FUNCTIONS AND LOGIC =====
function fl_pauseSlideShow():void
{
slideshowTimer.stop();
}
function fl_startSlideShow():void
{
slideshowTimer.start();
}
function fl_nextSlide():void
{
currentImageID++;
if(currentImageID >= totalFrames)
{
currentImageID = 0;
}
gotoAndStop(currentImageID+1);
}
function fl_prevSlide():void
{
currentImageID--;
if(currentImageID < 0)
{
currentImageID = totalFrames+1;
}
gotoAndStop(currentImageID-1);
}
if(autoStart == true)
{
fl_startSlideShow();
playPauseToggle_mc.gotoAndStop("pause");
} else {
gotoAndStop(1);
}
function initApp(){
currentImageID = 0;
slideshowTimer = new Timer((secondsDelay*1000), 0);
slideshowTimer.addEventListener(TimerEvent.TIMER, fl_slideShowNext);
}
if(appInit != true){
initApp();
appInit = true;
}
// END FUNCTIONS AND LOGIC
----------------------------------------------- |