Set empty image in JavaScript

URL of experiment: https://run.pavlovia.org/Am8302/multipleoutcomes2/html/

Description of the problem: I am trying to set the value of an image to none. This works ok in builder/python but not in JS.

The python code is:
if stimA:
stimL = stimList[int(stimA)-1]
else:
stimL = None

if stimB:
stimR = stimList[int(stimB)-1]
else:
stimR = None

and the JS:

if (stimA!=undefined) {
stimL = stimList[(stimA)-1]
}
else {
stimL = None}

if (stimB!=undefined){
stimR = stimList[(stimB)-1]
}
else{
stimR = None}

I’m also having the issue that the experiment will currently only run on Chrome and freezes on Safari - not sure if this is related.

Thanks,
Alice

I have a similar problem - in python empty xlsx cells read as image names give None and as a result - empty image. This is frequently very convenient. However, on pavlovia it does not work - I get unknown resource error (if I remember correctly).

I tend to use a small transparent square as a none image but you can try changing None to undefined on the JS side.

I was thinking about creating such square, but I’m currently using just size = (0, 0). Its not very elegant but it works. :slight_smile:

Here’s an invisible image you can use. I call it transparent.png and it’s native size is 1x1 pixels.

Right-click below here to save:
transparent

While this is an old post, I want to update it to note that transparent.png should be 2x2 pixels, not 1x1 pixels. I’ve finally discovered by I’ve been getting ERROR Only 2D textures are supported at the moment in my Stdout for some experiments. Right-click below to save.

transparent 2x2 png