Page 1 of 1

reset/ delete image if exist then create new image

Posted: Thu Aug 16, 2007 12:40 am
by reelstuff
Hi, I have a button I want to use to reset to a new image.

So if there is an image there I want to delete that image and
create new blank image and position it.

I tried several variations and get different errors, for me its usually in the syntax.
err
Chunk: no such object
Object Button
Line if exist (image "iData")
Hint iData

Code: Select all

on mouseUp
  if exist (image iData) then
  delete "iData"
  new image "iData"
 end if
end mouseUp
I know I am missing something, but at the moment it escapes me,

once I get this to work I can then go on to positioning the new image to a certain spot on the screen.

thanks for any suggestions.

Tim

Posted: Thu Aug 16, 2007 8:38 am
by Klaus
Hi reelstuff,

yep, there is missing something in your script:

Code: Select all

on mouseUp 
  if existS (image iData) then 
  delete IMAGE "iData" 
  CREATE image "iData" 
 end if 
end mouseUp 
BUT it is not necessary to delete the old image, you can simply empty it!
That's a lot cheaper than buying a new one ;-)

Code: Select all

on mouseUp 
  if existS (image iData) then 
   put empty into image "iData" 
  end if 
end mouseUp 

Best

Klaus

Posted: Thu Aug 16, 2007 12:38 pm
by reelstuff
Thank you Klaus, that is excellent, I believe I am beginning to see a little better now, that was very helpful.

Posted: Thu Aug 16, 2007 12:43 pm
by Klaus
Hi reelstuff,

glad I could help :-)

Hint:
This will of course only work with imported images.
If you are working with referenced images you can simply:

...
set the filename of img "iData" to empty
...


Best from germany

Klaus

Posted: Thu Aug 16, 2007 5:32 pm
by reelstuff
Even Better, thank you
Klaus wrote:Hi reelstuff,

glad I could help :-)

Hint:
This will of course only work with imported images.
If you are working with referenced images you can simply:

...
set the filename of img "iData" to empty
...


Best from germany

Klaus