Skip to main content
April 14, 2010
Question

Infinate scroller

  • April 14, 2010
  • 1 reply
  • 492 views

does anyone know how I can make this image scroller inifate, so its one big loop, and also how to slow it down?

Thanks

stop();

//Build gallery
for (i = 0; i < total; i++){
     
     contentMC.attachMovie("attachMC", "images" + i, i);
     path                                 = contentMC["images" + i];
     path._x                            = contentLength * i;
     path.title_txt.htmlText        = Title;
     path.caption_txt.htmlText     = Caption;
     path.caption_txt.autoSize     = true;
     contentLength                       = Space;
     path.linkButton._link             = Link;
     loadMovie(Image, path.holderMC);
     
     // linkButton setting [ Active & Pasif ]
     if (Link != null && Link != " " && Link != undefined){
        path.linkButton._visible = true;
        }else{
        path.linkButton._visible = false;
        }
}//end for

scrollTSpeed          = 0.1; //slider control move
var speedY:Number      = 10;

//setMask
contentMC.setMask(maskMC);

// Scroll slide function
function slideFunction() {
     if(this._ymouse>0 && this._ymouse<maskMC._height) {
               if(this._ymouse>0 && this._ymouse<maskMC._width) {
                    speedY = -this._xmouse/maskMC._width*(contentMC._width-maskMC._width);
          }
     }
contentMC._x +=( speedY-contentMC._x )* scrollTSpeed;
}
onEnterFrame = function() {
     slideFunction();
};

// Resize objects of stage
Stage.align = "TL";
Stage.scaleMode = "noscale";
stageListener = new Object();
Stage.addListener(stageListener);

resizeObjects = function () {
     backgroundMC._x           = 0;
     backgroundMC._y           = 0;
     backgroundMC._width  = Stage.width;
     backgroundMC._height = Stage.height;
     maskMC._x                 = 0;
     maskMC._y                  = 0;
     maskMC._width          = 1000; //Stage.width;
     maskMC._height        = Stage.height;
     contentMC._x            = 0;
     contentMC._y            = Stage.height / 2 - contentMC._height / 2;
}
stageListener.onResize = function() {
     resizeObjects();
}
     resizeObjects();

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 14, 2010

to control speed adjust scrollTSpeed.  to make it infinite, add enough to contentMC so the left side of contentMC is also on the right side of contentMC.  you need maskMC._width's worth of duplicates.  when contentMC's left edge is aligned with maskMC's left edge reposition contentMC so the left-edge of the duplicates on the right side are at the maskMC's left edge.  likewise, for when the right edge of the right side of contentMC is at the right-edge of maskMC.

April 14, 2010

I'm sorry to say I'm a little confused?!

Am I to do this on the stage or within the AS panel?

I am very new to all this, would you be able to show me in code?

Thanks

for your help

Phil

kglad
Community Expert
Community Expert
April 14, 2010

use google to search for:  flash as2 infinite scroller