Timing animation in a script?

138 views
Skip to first unread message

javagirl

unread,
Jun 3, 2009, 11:23:12 AM6/3/09
to E-Prime
Hi

I would like to show animation I created in a Do..While loop for about
600 ms. Does anyone know the best way to do this?

Thanks

Cindy

Michiel Spape

unread,
Jun 4, 2009, 11:05:31 AM6/4/09
to e-p...@googlegroups.com
Hi,
What do you mean by 'show animation I created in..'? Are you trying to show an avi file, for example, or alternatively, move a picture across the screen in 600 ms (say, 1 pixel each 20 ms)? For the latter, I typically set start and end points, and check every time whether the 600 ms have passed. If one would, for example, have an imagedisplay, myDisplay, showing a picture at x,y = 300,400, then moving it, this would be possible:

Dim starttime as long
Starttime = clock.read
While (clock.read - starttime) < 600 do
myDisplay.x = myDisplay.x + 1
myDisplay.y = myDisplay.y + 1
myDisplay.run
Wend

With the image being in the unreferenced objects ('deleted', which makes a mess of your experiment, but using goto loops isn't that transparent either).

For the former, I do not see why one would want to use a while...loop. Isn't the duration/offset enough to time it properly (though i have never used avi files, I wouldn't be surprised if this would be the case)

Best,
Michiel



Michiel Spapé
Research Fellow
Perception & Action group
University of Nottingham
School of Psychology
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

javagirl

unread,
Jun 25, 2009, 3:58:48 PM6/25/09
to E-Prime
Thanks for responding, I wound up doing something like what you
suggested.

Cindy

On Jun 4, 11:05 am, Michiel Spape <Michiel.Sp...@nottingham.ac.uk>
wrote:

David McFarlane

unread,
Jul 9, 2009, 4:50:34 PM7/9/09
to e-p...@googlegroups.com
I know this got answered well enough already, but
I wanted to build on Michiel's answer and add
that to the record. I have done animation like
this without any Do... While loop at all, just
using a List object to do the looping. I set the
List selection to Sequential, Exit List After,
e.g., 60 seconds (must use seconds here, not ms),
and have a single row (level) with my
Procedure. Now the List will take care of all the timing.

Then in the list procedure I could put inline script as above, e.g.,

myDisplay.x = myDisplay.x + 1
myDisplay.y = myDisplay.y + 1
myDisplay.run

Alternatively, I could put a display object
(myDisplay in our example) directly into the
procedure right after the script, and set its
Duration to 0 (so that the loop simply runs as
fast as it can). Now the display object shows up
directly in the structure instead of staying
hidden in the script, and the script simplifies to

myDisplay.x = myDisplay.x + 1
myDisplay.y = myDisplay.y + 1

This is actually rather clean and elegant,
although I rather prefer not to manipulate
properties directly in script and instead use
attribute references. So, I could use attribute
references in the Postition X and Y properties of
the display object or sub-object, e.g., [myX] and
[myY]. I might also create global variables in
the User Area to hold values for myX and myY
between loop iterations, and as before advance
the position in script before the display object,
and my script might come out like

myX = myX + 1
myY = myY + 1
c.SetAttrib "myX", myX
c.SetAttrib "myY", myY

(Note that although the variables myX and myY
have the same names as the context attributes
"myX" and "myY", these are all distinct objects!)

Admittedly this may seem more troublesome than
using the direct property manipulation as above,
so you have to use your judgment according to the
particular circumstances. And of course, some
time before my List I would have to initialize
myX and myY, but you would have to do that for any of these approaches.

One final issue on using a List to do the loop
instead of Do... While -- by default the List
will create a line in the .edat log for every
loop, which could get messy. You could prevent
that by opening up the Properties dialog for the
list procedure (Edit > Properties... after
selecting the procedure, or right-click anywhere
in the procedure window) and then unchecking Log
Data. Admittedly this is a very obscure feature
and will likely confound anyone who later works
with your program, so perhaps that is reason
enough to stick with the Do... While approach.

-- David McFarlane, Professional Faultfinder

javagirl

unread,
Jul 10, 2009, 11:15:06 AM7/10/09
to E-Prime
Thanks David. I'll look into whether this would work for me, though I
am presenting things on the millisecond range

Cindy
Reply all
Reply to author
Forward
0 new messages