Pass image path into loadimage

I am having the problem where I want to pass a variable with image path into loadImage(). However, I am getting the error:

image

This must be possible but I don’t see anything in docs or online demonstrating this.

please link to your project at
https://editor.p5js.org so we can see the file, the code,
( also check the p5.js revision )
and can play


example:
https://editor.p5js.org/kll/sketches/L4da3ypJO

Hey there, here’s the link: https://editor.p5js.org/kickstv/sketches/IG2wCeLwz

Im not working in the editor btw. The error I am getting now is different.

hm

display() {
      var loadedImage = loadImage(this.imgPath);  

you should not load that image every time draw() // .display() runs

see
https://editor.p5js.org/kll/sketches/4JIok7ZaH

Thanks, I didnt want to load the image and save it as an attribute because i wanted to save an instance of a computer as json, but i was getting this error because of loading an image as an attribute. Do you know a work around for this?

https://editor.p5js.org/kickstv/sketches/EBMBi0o3G

Thanks for the help

no idea what you want to save?


function draw() {
  background(220);
  comp.display();
  comp.move(mouseX, mouseY);

  json = JSON.stringify(comp);

  saveJSON(json, 'comp.json');

}

but that would give you about 50 download windows per sec!