Page 1 of 1

image boundaries

Posted: Fri May 18, 2007 1:27 am
by revmeup
How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.

Posted: Fri May 18, 2007 2:10 am
by BvG
You need to be more wordy in your question. I can only guess what you actually mean.

To move your image around on your stack with the mouse, put this in your images script:

Code: Select all

on mouseDown
  grab me
end mouseDown

Re: image boundaries

Posted: Sat May 19, 2007 2:46 am
by Mark Smith
revmeup wrote:How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.
Let's say you have a rectangle graphic "tRect" that defines the boundaries,
something like this in the script of the image should work:

Code: Select all

local sRect

on mouseEnter
    put the height of me / 2 into tH
    put the width of me / 2 into tW
    put the rect of grc "tRect" into sRect
    add tW to item 1 of sRect
    subtract tW from item 3 of sRect
    add tH to item 2 of sRect
    subtract tH from item 4 of sRect
end mouseEnter
  

on mouseMove
  if the mouse is down then
    if the mouseLoc is within sRect then set the loc of me to the mouseLoc
  end if
end mouseMove
Best,

Mark