Pavlovia error code TypeError:psychoJS.window.flip is not a function

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?

Thank you so much for your time!

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],

and under end routine I reset that counter to 0

going_diag = 0

Hello jak328,

from wakecarter’s crib sheet:

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.

Best wishes Jens

2 Likes

Hi There,

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.

Becca

Hi Becca,

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.

How do the animations work locally? Is there code in an Each Frame tab or variable image positions that update every frame in the image component?

Hi Wakecarter,

the code I have written as follows:

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

#reset counter
End routine:
going_diag = 0

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

Hi There,

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!

Becca