| Reference | Downloads | Github

addChild undefined message

URL of experiment:

Description of the problem:
Hi, I have an experiment in builder view that works fine in both builder view and on Pavlovia. However when I want to edit some of the text displayed in the experiment that is written in a code component on builder view it will not run on Pavlovia and the following error message pops up;

TypeError: Cannot read property ‘addChild’ undefined

why is there? I have checked the changes and all appear to be fine and matching and the python has converted to javascript just fine so i am confused. Could you please help?

Please could you show the code component you are editing?

Are you trying to use advanced formatting?

this version works fine

however this new version of the script makes the error occur. Both created in exactly the same way but one works and the other doesn’t so super confused. Thank you advance!

Don’t use .draw() in Builder.
continueRoutine = True does nothing since it is set to True when the routine starts.

I think you should have a single sticker component and then update the image with award.setImage(‘images/…’) rather than having such complicated code. The addChild error might be when it tries to create a new component with the same name as an existing one.

You could also simplify your if statement at the top by using

if trialsDone > 0 and trialsDone % 10 == 0:

Best wishes,


Ok thank you, it was translated from Matlab and I am still learning different ways to code. Thanks so much for the advice :slight_smile: