Switching between images...
Klaus Major
klaus.major at metascape.org
Fri Aug 23 11:14:01 EDT 2002
Hi Peter,
> 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
> visible.
>
> 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
> button).
>
> 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
in this case you can have it even shorter (said the big TIMESAVER ;-)
without any if...then...else...
Just set the icon of the btn to the id of the first image and the
hiliteicon
of the button to the id of the other image.
Then script:
on mouseup
set the hilite of me to (not the hilite of me)
end mouseup
or
on mouseenter
set the hilite of me to (not the hilite of me)
end mouseenter
and other variations...
You get the picture...
So you just need one line.
If the images are not TOO big (screensize maybe) the performance
will be as fast as ever :-)
Regards
(timesaving) Klaus Major
klaus.major at metascape.org
More information about the use-livecode
mailing list