Pavlovia -- Checkbox code generates a Type Error Cannot read properties of undefined (reading 'status')

I have created a routine where a participant has to check a box, then press a key to move to the next screen.

I have put the following code :

Begin routine : checkboxes = [polygon] clicked = []

Each Frame for polygon in checkboxes: if mouse.isPressedIn(polygon) and polygon.name not in clicked: polygon.color = "black" clicked.append(polygon.name)

And added a start condition to the key component : mouse.isPressedIn(polygon)

This works fine locally but when I upload the experiment to Pavlovia I get the following error :

Type Error Cannot read properties of undefined (reading ‘status’)

Would be grateful for help on this issue.

All the best,

Cameron

It sounds like polygon isn’t defined by the time its status is checked - what’s the line number of the error? If you use the :compile_js: button to view the JavaScript for the experiment, where is the line which looks roughly like this:

var polygon = visual.Polygon(win, 
    ....etc.

and is the function it’s in called before the error line / is it called outside a function?

1 Like