Copy link to clipboard
Copied
Hello!
Hopefully maybe someone can help me with this. I have created a gallery with scroll buttons that works perfectly. However, I would like to have this auto scroll (maybe 2 seconds on each image) and I am not sure how to do this. My guess is I am completely over complicating it. I would love a second pair of eyes to give me an idea how I can achieve this.
Thank you so much for your help in advance.
AS3 CODE
stop();
Arrows.LA.addEventListener(MouseEvent.CLICK, backFrame);
Arrows.RA.addEventListener(MouseEvent.CLICK, forwardFrame);
import fl.transitions.Tween;
import fl.transitions.easing.*;
var nFrame:Number=1;
//ARROW FUNCTIONS
function backFrame(evt:MouseEvent):void
{
if(nFrame>1) {
nFrame--;
} else {
nFrame=5
}
Arrows.gotoAndStop(nFrame);
var nX:Number=0-((nFrame-1)*379)
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, nX, .5, true);
}
function forwardFrame(evt:MouseEvent):void
{
if(nFrame<5) {
nFrame++;
} else {
nFrame=1;
}
Arrows.gotoAndStop(nFrame);
var nX:Number=0-((nFrame-1)*379)
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, nX, .5, true);
}
//FRAME BUILD FUNCTIONS
function frameA(evt:MouseEvent):void
{
nFrame=1;
Arrows.gotoAndStop(1);
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, 0, .5, true);
}
function frameB(evt:MouseEvent):void
{
nFrame=2;
Arrows.gotoAndStop(2);
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, 0, .5, true);
}
function frameC(evt:MouseEvent):void
{
nFrame=3;
Arrows.gotoAndStop(3);
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, 0, .5, true);
}
function frameD(evt:MouseEvent):void
{
nFrame=4;
Arrows.gotoAndStop(4);
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, 0, .5, true);
}
function frameE(evt:MouseEvent):void
{
nFrame=5;
Arrows.gotoAndStop(5);
var myTween:Tween = new Tween(Gallery, "x", Strong.easeOut, Gallery.x, 0, .5, true);
}
Best,
Mel
call the function that scrolls using a timer with a 2 second delay. reset your timer if a button is clicked. change the scroll function's argument to an Event instead of MouseEvent or TimerEvent so both work.
Copy link to clipboard
Copied
call the function that scrolls using a timer with a 2 second delay. reset your timer if a button is clicked. change the scroll function's argument to an Event instead of MouseEvent or TimerEvent so both work.
Copy link to clipboard
Copied
Thank you sooo much! That worked perfectly!
Copy link to clipboard
Copied
you're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more