ImageView not updating in loop. Only display last imaged processed

I’ve been using this tutorial to have an image placeholder in a window.
http://www.peachpit.com/articles/article.aspx?p=1959674&seqNum=3

Now it shows an image however it does not display an image until it gets to the end of the script.

I have it within a handler,

then use it like this

 set theImage to initWithContentsOfFile_(POSIX path of thefile) of alloc() of class "NSImage" of current application
    setPhotoPath_(thefile as string)
    setImage_(theImage) of imageView

I’ve looked around the net and there are others who have similar problems, but as yet I haven’t got them to work.

Any suggestions please?

I’ve added a delay in of 0.1 and this helps it, but rather not be stopping the script.

A delay is only working by accident. Try using something like:

theWindow's displayIfNeeded()

where theWindow is an outlet for the window.

Longer term, you need to try to understand the event loop works, and why updates normally happen after an event has been handled fully. It’s a bit complicated, but important to understand – it’s covered in chapter 13 of my book.