|
|
Dragging and Magnifying a Sprite
Added on 6/30/1999
|
Here is a handler similar to what you describe. It doesn"t use a separate window or scroll bars but it may be a piece of your puzzle. Be sure to call it from a cast script "on MouseDown" instead of "on MouseUp" or it won"t work properly. The user is able to move the sprite by clicking and dragging, magnify by double clicking, and reduce by option-double clicking.
on pictureView
-- Lingo by Kelly Stewart, NewOrder Media, Nashville
global vMAGNIFICATION --set this initially to zero in your startMovie
put the clickOn into theSprite
puppetSprite theSprite, true
put the locH of sprite theSprite - the mouseH into offH
put the locV of sprite theSprite - the mouseV into offV
--The following repeat gives you the movement when the mouse is down.
--This first "if then" within the repeat checks for the mouse location so
--the user can"t drag the sprite out of a custom-sized window.
--Change the numbers to fit your needs or just delete it entirely.
repeat while the mouseDown
if the mouseH < 22 or the mouseH > 401 or the mouseV < 106 or the mouseV > 481 then
set the cursor of sprite theSprite = 0
exit
end if
set the cursor of sprite theSprite = 1005 --grabber hand
set the locH of sprite theSprite = the mouseH + offH
set the locV of sprite theSprite = the mouseV + offV
updateStage
end repeat
set the cursor of sprite theSprite = 0
if the doubleclick = false then exit
set the stretch of sprite theSprite to true
if the optiondown and the doubleclick and vMAGNIFICATION > -4 then
--Can"t reduce it more than 4 times.
set the cursor of sprite theSprite = 1007 --zoom out
set the height of sprite theSprite to (integer(.666667 * the height of sprite theSprite))
set the width of sprite theSprite to (integer(.666667 * the width of sprite theSprite))
set vMAGNIFICATION = vMAGNIFICATION - 1
updatestage
set the cursor of sprite theSprite = 0
exit
end if
if not the optiondown and vMAGNIFICATION < 4 then
--Can"t magnify it more than 4 times.
set the cursor of sprite theSprite = 1006 --zoom in
set the height of sprite theSprite to (integer(1.5 * the height of sprite theSprite))
set the width of sprite theSprite to (integer(1.5 * the width of sprite theSprite))
set vMAGNIFICATION = vMAGNIFICATION + 1
updatestage
end if
set the cursor of sprite theSprite = 0
--Be sure to turn off all puppetsprites (set to false) later when you leave
--this area of your movie. Make "theSprite" global if you want to track the
--sprite number the user clicked on outside of this handler.
end pictureView
|
|