Replace line 8 with myImages.push(loadImage('images/img' + i +'.jpg'));. @koogs I think that it would be wiser to leave it as an array, as it will allow him to add more elements without any much extra work, and I'm pretty sure he plans on doing that (I think he's trying to teach Hindi alphabets to someone).
@koogs: you were right that I should have treat the array as an array (it happened by mistake). But even though I fixed that and I also considered @Lord_of_the_Galaxy 's advice which I think was not that necessary because I was adding elements using index variable.
I think you both are getting the same error because you are, perhaps, trying to access the image directly and since you are not logged in with my email id and password. But I tried this link again and again I have never got this error.
See here I have tried it in incognito mode with the same link.
P.S: I also think that there must be any problem with the web-based software. My desktop version works fine with the same code but it does not render my Hindi letters properly that is why I wanted to try it in web-based version.
@shiffman: You are absolutely right. The major problem is that Atom and Brackets also produce the same error. It does not recognize loadImage() function.
Answers
Line 8. Do you need to treat that as an array there?
Replace line 8 with
myImages.push(loadImage('images/img' + i +'.jpg'));
.@koogs I think that it would be wiser to leave it as an array, as it will allow him to add more elements without any much extra work, and I'm pretty sure he plans on doing that (I think he's trying to teach Hindi alphabets to someone).
That was my point. The var was an array, he needed to treat it as one.
Thanks to both of you @Koogs and @Lord_of_the_Galaxy for your comments.
@koogs: you were right that I should have treat the array as an array (it happened by mistake). But even though I fixed that and I also considered @Lord_of_the_Galaxy 's advice which I think was not that necessary because I was adding elements using index variable.
Anyway, I made some modifications to the code but I am still stuck. Please follow the link for the modified version of the code. https://alpha.editor.p5js.org/hacback17/sketches/rk8xNLave
@Lord_of_the_Galaxy: Absolutely right that I want to teach Hindi to one of my foreign friends.
My thanks to both of you:)
None of your uploaded images seem to exist in the p5.js Web Editor: :-SS
(Failed to load resource: the server responded with a status of 404 (Not Found))
http://alpha.Editor.p5js.org/hacback17/sketches/rk8xNLave/images/img7.png
How about some other web editor like?: B-)
https://OpenProcessing.org/sketch/create
@GoToLoop: Thanks for your comment. Did you try this link https://alpha.editor.p5js.org/hacback17/sketches/rk8xNLave ?
This is an updated version of the code.
If you pay attention, the missing image link I've posted belongs to the same path as your updated sketch version. L-)
@GoToLoop: But img7.png happens to be there, as you can see in the screenshot.
Unfortunately for me, when I click at any of their URLs, I've got:
(Failed to load resource: the server responded with a status of 404 (Not Found))
I'm also getting 404 from the direct image link above (on mobile).
I think you both are getting the same error because you are, perhaps, trying to access the image directly and since you are not logged in with my email id and password. But I tried this link again and again I have never got this error.
See here I have tried it in incognito mode with the same link.
P.S: I also think that there must be any problem with the web-based software. My desktop version works fine with the same code but it does not render my Hindi letters properly that is why I wanted to try it in web-based version.
Oh...I get it. There are many people who have faced this problem. See here This has to be resolved by the software team.
Anyway, thank you everyone for bearing with me.
If only the logged in owner of the sketch can see the images, it's kinda useless for others to help out! :-&
That's why I've advised you to change web editor for: https://OpenProcessing.org O:-)
@GoToLoop: That's why I've advised you to change web editor for: https://OpenProcessing.org
You are right. I should use this one. Thanks for the advice
So you changed yet?
Coming to your code, you need to draw the image in draw(), not setup().
@Lord_of_the_Galaxy: I have done that. Thank you!
So question solved?
Yes, but it does not still work in web based p5.js editor. Possibly, they would resolve this problem sometime.
x
This is the issue: https://github.com/processing/p5.js-web-editor/issues/212
The web editor isn't publicly released yet and is very much in the alpha stages. So there are lots of things still to be resolved.
@shiffman: You are absolutely right. The major problem is that Atom and Brackets also produce the same error. It does not recognize loadImage() function.
Really? How come?