# Help in understanding?

**URL:** <https://forum.kirupa.com/t/help-in-understanding/304090>\
**Category:** Uncategorized\
**Created:** [February 1, 2010, 4:00pm UTC](https://forum.kirupa.com/t/help-in-understanding/304090 "2010-02-01T16:00:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![touches](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@touches](https://forum.kirupa.com/u/touches)\
**Post date:** [February 1, 2010, 4:00pm UTC](https://forum.kirupa.com/t/help-in-understanding/304090/1 "2010-02-01T16:00:30Z")

</div>

hi i am learning to create tiles and i am following oos.moxiecode tutorials… Here i am unable to understand the code for the scrolling function  
[http://oos.moxiecode.com/tut\_04/index.html](http://oos.moxiecode.com/tut_04/index.html)

```auto
[FONT=verdana,geneva,arial,helvetica][SIZE=-2][SIZE=2]// scroll-function
function doScroll (dir) {
  // right
  if ( dir == "right" && j <= mapW ) {
    this.scrClip._x -= scrSpeed;
    majorX += scrSpeed;
    if ( majorX >= tileW ) {
      for ( var lasti=(i-visAreaY); lasti < i; ++lasti ) {
        for ( var lastj=j; lastj < (j+1); ++lastj ) {
          this.scrClip.attachMovie("tile", "t_"+lasti+"_"+lastj, ++d);
          this.scrClip["t_"+lasti+"_"+lastj]._x = lastj*tileW;
          this.scrClip["t_"+lasti+"_"+lastj]._y = lasti*tileH;
          this.scrClip["t_"+lasti+"_"+lastj].gotoAndStop ( map1[lasti][lastj][0] );
          removeMovieClip ( this.scrClip["t_"+lasti+"_"+(lastj-visAreaX-1)] );
        }
      }
      ++j;
      majorX -= tileW;
    }
  }
}
[/SIZE][/SIZE][/FONT]

```

I don’t understand how he calculates the variable lasti(the logic too) and lastj in the for loops and incrementing the j variable and also the removeMovieClip code…can anybody explain and help me understand it better…
