preload()

I have my sketch running just fine when I preview it out of p5 (other than my lack of splice() at the moment), but when I run my .html out of my root folder the browser window only loads my html while my .js sits on "Loading ... ". why is this?

var izzms = [];
var imgs = [];
var j = 0;

function preload() {
  for (var i = 0; i < 3; i++) {
    imgs[i] = loadImage('assets/proj' + i + '.jpg');
 }
}

function setup() {
  createCanvas(640, 480);
  image(imgs[j], 0, 0);
}

function draw() {
    for (var i = izzms.length - 1; i >= 0; i--) {
    izzms[i].display();
 }
}

function mousePressed() {
  // var r = floor(random(imgs.length));
  var b = new Izzm(0, 0, imgs[j]);
  izzms.push(b);
  j++;
  if (j > 2) {
    j = 0;
  }
}


//object
function Izzm(x, y) {
  this.x = x;
  this.y = y;

  this.display = function() {
    image(imgs[j], this.x, this.y);
 }
}

Answers

Sign In or Register to comment.