Switching between images...

Jeanne A. E. DeVoto jeanne at runrev.com
Fri Aug 23 10:57:00 EDT 2002

At 4:30 AM -0700 8/23/2002, Peter Lundh wrote:
>Could someone please recommend a simple way to switch between two versions
>of the same image. The images are stacked on top of each other on a card and
>I would like the user to be able to toggle/switch between the two by either,
>clicking on them, or by doing a "mouseOver"/"rollover".

Klaus has made some suggestions that assume you have the two images both

One alternative that's often handy is to use a button instead of an image,
and set the button's icon property to the ID of the image you want to use.
Since an icon can be any image of any size, you can use it for things other
than conventional icons. And since only one object (the button) is actually
shown, it's a little more convenient if you have to move the image on the
card (no need to worry about moving both image objects, just move the

Here you might create/import the two versions of the image, and either hide
them or place them in a substack. Get their IDs (let's say they're 2001 and
2002). Then create a blank button of the correct size, and put this in the
button script:

  on mouseUp -- switch from one image to the other
    if the ID of me is 2001 then set the ID of me to 2002
    else set the ID of me to 2001
  end mouseUp

or else

  on mouseEnter
    set the icon of me to 2002 -- the "rollover" image
  end mouseEnter

  on mouseLeave
    set the icon of me to 2001 -- the "default" image
  end mouseLeave

Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development

More information about the Use-livecode mailing list