var currentImage = 0; this.directionLeft.addEventListener("click", shiftCarouselLeft); this.directionRight.addEventListener("click", shiftCarouselRight); function shiftCarouselLeft() { root.carouselContainer.gotoAndPlay("transitionLeft"); if(currentImage != 0){ currentImage--; } else { currentImage = carouselItems.length-1; } } function shiftCarouselRight() { root.carouselContainer.gotoAndPlay("transitionRight"); if(currentImage != carouselItems.length-1){ currentImage++; } else { currentImage = 0; } }