# Problem with delay()

**URL:** <https://discourse.processing.org/t/problem-with-delay/19491>\
**Category:** Beginners\
**Created:** [April 7, 2020, 3:47am UTC](https://discourse.processing.org/t/problem-with-delay/19491 "2020-04-07T03:47:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Velouria](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Velouria](https://discourse.processing.org/u/Velouria)\
**Post date:** [April 7, 2020, 3:47am UTC](https://discourse.processing.org/t/problem-with-delay/19491/1 "2020-04-07T03:47:52Z")

</div>

Hello,  
i’m trying to implement this example: [https://p5js.org/reference/#/p5.Image/delay](https://p5js.org/reference/#/p5.Image/delay) in a sketch, but when I run it i get the message “bg1.delay is not a function”. I believe my code is exactly the same as in the example. Do i need to use a specific library or something?  
Thanks in advance!

```auto

let bg1, bg2;

function preload() {
  bg1 = loadImage("deck/elBueno.gif");
  bg2 = loadImage("deck/elBueno.gif");

}

function setup() {
  createCanvas(480, 720);
  bg1.resize(width / 2, height / 2);
  bg2.resize(width / 2, height / 2);

  bg1.delay(10);
  bg2.delay(100);

}

function draw() {
   
   background(0);
  translate(width / 2, height / 2);
  image(bg1, 0, 0);
  image(bg2, 0, 0, width/2,0);

}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 7, 2020, 4:16am UTC](https://discourse.processing.org/t/problem-with-delay/19491/2 "2020-04-07T04:16:58Z")

</div>

Hello,

It works fine here in the Processing P5.js mode.

I used this animated gif:  
[![](https://media.giphy.com/media/efOy8fi7xaWly/giphy.gif) ](https://media.giphy.com/media/efOy8fi7xaWly/giphy.gif)

`:)`

---

<div class="post-metadata">

**Author:** ![Velouria](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Velouria](https://discourse.processing.org/u/Velouria)\
**Post date:** [April 7, 2020, 5:03am UTC](https://discourse.processing.org/t/problem-with-delay/19491/3 "2020-04-07T05:03:51Z")

</div>

Thanks!!  
I tried with your gif but same error ☹  
did you use the exact same code, just changed the file?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 7, 2020, 1:31pm UTC](https://discourse.processing.org/t/problem-with-delay/19491/4 "2020-04-07T13:31:51Z")

</div>

Hello,

It still works fine here in the Processing P5.js mode and with the P5 Editor.  
I modified code but it worked with original as well.

```auto
let bg1, bg2;

function preload() 
  {
  bg1 = loadImage('giphy.gif');
  bg2 = loadImage('giphy.gif'); 
  }

function setup()
  {
  createCanvas(800, 450);
  //bg1.resize(width / 2, height / 2);
  //bg2.resize(width / 2, height / 2);
  bg1.delay(10);
  bg2.delay(100);
  }

function draw() 
  {
   background(0);
  //translate(width / 2, height / 2);
  image(bg1, 0, 0);
  image(bg2, width/2, 0);
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4babbf7d2521ef80e5caca3be2b992d8fadabb73.png)  
`:)`
