# Making things happen sequentially within an array

**URL:** https://discourse.processing.org/t/making-things-happen-sequentially-within-an-array/11749
**Category:** Coding Questions
**Created:** [May 31, 2019, 9:19pm UTC](https://discourse.processing.org/t/making-things-happen-sequentially-within-an-array/11749 "2019-05-31T21:19:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hetoft](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@Hetoft](https://discourse.processing.org/u/Hetoft)
#### Post date: [May 31, 2019, 9:19pm UTC](https://discourse.processing.org/t/making-things-happen-sequentially-within-an-array/11749/1 "2019-05-31T21:19:12Z")

</div>

Hi there,

I’m trying to display all the objects in an array, not all at once, but one after the other.

Basically, what my code does is to load sequences of SVGs and then display them as one fluent animation. What I want is for the sequences to only appear and start animating when the last one is done. As it is currently, they (all the objects in the array) all appear simultaneously.

Here’s my code so far:

```auto
Tegn[] tegnArray;
int numTegn = 6;

void setup() {
  size(560, 500);
  frameRate(60);
  smooth(4);

  tegnArray = new Tegn[numTegn];
  for (int i = 0; i < tegnArray.length; i++) {
    tegnArray[i] = new Tegn(int(random(1, 4)));
  }
}

void draw() { 
  background(200);

  for (int i = 0; i < tegnArray.length; i++) {
    tegnArray[i].display();
  }
}

class Tegn { 

  int numFrames = 240;
  int currentFrame = 0;
  PShape[] seq = new PShape[numFrames];
  int tegnNo;

  Tegn(int tegnNoTemp) {

    tegnNo = tegnNoTemp;

    for (int i = 0; i < seq.length; i++) {
      String tegnFile = "svgs/tegn"+nf(tegnNo, 1)+"/svg" + nf(i, 1) + ".svg";
      seq[i] = loadShape(tegnFile);
      seq[i].disableStyle();
    }
  }

  void display() {

    noFill();
    strokeWeight(40);

    for (int i = 0; i < numFrames; i += seq[0].width) {
      shape(seq[(currentFrame) % numFrames], 0, 0);
      currentFrame ++;
    }
  }
}

```

Really appreciate your help. Thank you!

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 31, 2019, 10:59pm UTC](https://discourse.processing.org/t/making-things-happen-sequentially-within-an-array/11749/2 "2019-05-31T22:59:41Z")

</div>

> [@Hetoft](#):
>
> tegnArray.length

replace this in the for loop `for (int i = 0; i < tegnArray.length; i++) {` by a new variable upperBorder

increase upperBorder every time draw() runs (or every 2nd time draw runs)
