Description of the problem:
Hi everyone. I noticed that some other people have gotten this error but that it doesn’t seem to be a problem with a uniform solution? It seems that the error results from a code component in your experiment ( I assume the result of the automatic JS conversion). I am not good at writing code at all- but I have used it to create animations to reward kids as they play though my experiment ‘game’. The error code I’m getting is as follows:
![Screen Shot 2022-01-30 at 4.33.29 PM|529x296](upload://gTLajX48oyP4SCOivQcIB2ZBGte.png)
Unfortunately we have encountered the following error:
TypeError: psychoJS.window.flip is not a function
Try to run the experiment again. If the error persists contact the experiment designer
I have attached images of my code component with # indicating what each part of the code does. It essentially makes a picture move across the screen diagonally. Can anyone see what is going wrong?
It will only let me put two pictures in. So I have two pieces of code one at begin routine which creates a counter for my going_diag variable and sets it to 0. It also gives each image a starting position:
#set counter to 0 for going diag
going_diag = 0
image.pos = [-0.9,-0.9],
win.flip() Just don’t (in Python or JavaScript) if you are using Builder. There is an implicit win.flip() at the end of the Each Frame tab and additional flips or halting the process with waitKeys or while will confuse the Builder code.
Yes really don’t use win.flip() in builder - it will really mess up your timing.
I suggest in the Begin Routine tab use
image.setAutoDraw(True)
and in the End Routine use:
image.setAutoDraw(False)
If you need a series of images each drawing for 100ms (which is what it looks like - I suggest a single routine with an image stim that lasts 100 ms and loops through the series of images you want to present.
Thanks so much for the help. I tried your suggestion and my experiment now works in Pavlovia- but the animations don’t. I know essentially nothing about coding- but what I’m trying to do is have an image move across the screen diagonally. Then after one routine is complete a new image does this so it is pulling from a spreadsheet. I have routines like this with images moving in different directions throughout.
begin routine: #set counter to 0 for going diag
going_diag = 0
each frame:
move image component diagonally across the screen from it’s set position
while going_diag <= 15: #runs this code until counter = 15
image.pos += (0.1) #moves the image by 0.1 (norm)
image.draw() #I don’t really know what these commands do
win.flip()
core.wait(0.1)
going_diag += 1 #adds 1 to counter each time
Try having an image (imageName) with coordinates (xPos,yPos) which update every frame
Begin routine
#set counter to 0 for going diag
going_diag = 0
xPos = 0
yPos = 0
imageName.setPos([xPos,yPos])
frameCount = 6 # Move every sixth frame
Each frame:
# move image component diagonally across the screen from it’s set position
if going_diag <= 15 and frameN%frameCount == (frameCount-1) #runs this code until counter = 15 but not every frame
xPos += 0.1 #moves the image by 0.1 (norm)
yPos += 0.1
going_diag += 1 #adds 1 to counter each time
#reset counter not needed because it is reset in Begin Routine End routine:
going_diag = 0
If you are looking to make animations without code this Youtube video might also help! Dynamic stimuli in PsychoPy with no code and no movies: Typing effects - YouTube if it is just changing the position of something then you can do the same thing, but your changing position on each row of your spreadsheet - hope this helps!