Page 1 of 1

Hot and throbbing.

Posted: Mon May 25, 2015 11:10 am
by richmond62
One of the kids I teach asked how to make an image resize when the mouse was over it.

So I went, inevitably, for the easiest solution I could think of with this script
inside the image:

on mouseEnter
set the width of me to 150
set the height of me to 150
end mouseEnter
on mouseLeave
set the width of me to 120
set the height of me to 120
end mouseLeave

The kid was perfectly happy with that.

HOWEVER . . .

I noticed something interesting:

If the image is UNLOCKED it expands and contracts from it centre, while

if the image is LOCKED it expands and contracts from its top-left hand corner.

I don't know if this is documented anywhere (???) .

AND, I wonder if there is a way to force the image to expand and contract from another of its corners?

Re: Hot and throbbing.

Posted: Mon May 25, 2015 11:15 am
by Thierry
richmond62 wrote: AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
You can play with
the rect of image
Then you can change 1 to 4 of any corners..

Best,

Thierry

Re: Hot and throbbing.

Posted: Mon May 25, 2015 11:27 am
by richmond62
"set the rectangle of object to left,top,right,bottom"

Thanks, that's super.

Re: Hot and throbbing.

Posted: Mon May 25, 2015 11:47 am
by SparkOut
Although unlikely in this particular situation, watch out for esoteric changes to the rect that brings the edge to the other side of the mouse position, triggering another mouseEnter or mouseLeave which changes the rect again, which ... etc etc. Temporarily locking messages might be needed.

Re: Hot and throbbing.

Posted: Mon May 25, 2015 2:06 pm
by MaxV
Using the rect needs to make some calculations. I prefer this: :wink:

########CODE#######
on mouseEnter
lock screen
put the loc of me into temp
set the width of me to 150
set the height of me to 150
set the loc of me to temp
unlock screen
end mouseEnter

on mouseLeave
lock screen
put the loc of me into temp
set the width of me to 120
set the height of me to 120
set the loc of me to temp
unlock screen
end mouseLeave
#####END OF CODE#####

Re: Hot and throbbing.

Posted: Mon May 25, 2015 6:45 pm
by Klaus
Using the rect needs to make some calculations. I prefer this:
Yep :D

Re: Hot and throbbing.

Posted: Mon May 25, 2015 7:51 pm
by SparkOut
And what's more, this way you can also choose the direction of expansion by setting (say) the bottomRight to temp. Given the difference between the points, that will jump a little further, so put (say) the bottomRight into temp first.