Cached imagesource

J. Landman Gay jacque at hyperactivesw.com
Wed Jan 6 21:51:54 EST 2010


Well, just so the rest of you don't spend two days debugging this like I 
did, it appears that imagesource caches its image and doesn't reload the 
file from disk as long as the file name remains the same.

In my project, a user selects an image to be displayed in a field. I set 
the imagesource of a character in the field to do that. I also copy the 
image to a special project folder and give it a predictable name so I 
can use it later for other things without tracking it. That means that 
every time the user chooses a new image, the file name stays the same 
but the image content changes.

I guess we can't do that. The only time the image appears correctly is 
on first launch. All future references to it load the *old* image, not 
the changed one.

I'll have to rewrite a bunch of scripts to track file names, unless 
someone can figure out how to force Rev to re-load the image from disk 
on demand. That's what I'd prefer.

If you want to try it, make a field and a button. Put this into the 
button script:

on mouseUp
   answer file "Choose an image"
   if it = "" then exit to top
   set the cImg of this stack to it
   put "a Test Header" into fld 1
   set the imagesource of char 1 of fld 1 to ("binfile:"&it)
end mouseUp

Now behind Rev's back, change the image in an image editor so it looks 
different and resave it. Then run this in the message box:

   get the cImg of this stack
   set the imagesource of char 1 of fld 1 to ("binfile:"&it)

No change. Your old image will still be there. If you can figure out how 
to re-load, I'd love to hear it.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list