Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto scroll Gallery AS3 CODE

New Here ,
Feb 03, 2015 Feb 03, 2015

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

TOPICS
ActionScript
433
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 04, 2015 Feb 04, 2015

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.

Translate
Community Expert ,
Feb 04, 2015 Feb 04, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 04, 2015 Feb 04, 2015

Thank you sooo much! That worked perfectly!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2015 Feb 04, 2015
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines