Here is a modification of some code I use to resize windows. I use send in time combined with a wait message and it works pretty well. I use Malte Debrill's Animation Engine to make the resize less abrupt.
If you don't have Animation Engine then you could try the trial. Otherwise you will have to take out aeEaseInOUt, aeEaseIn, etc. They can be found in _easeThePropertySetting.
Code: Select all
## card script
on preOpenCard
put the width of this card + 100 into theWidth
put the height of this card + 100 into theHeight
put "ease in" into theEase
SetStackWidthAndHeight the long id of this stack, theWidth, theHeight, theEase, 200
wait until the width of this stack is theWidth and the height of this stack is theHeight with messages
end on preOpenCard
Code: Select all
## library script
local sAnims
command SetStackWidthAndHeight pStack, pWidth, pHeight, pEase, pDuration
put the rect of pStack into theRect
if pEase is not empty then
put theRect into theNewRect
put item 1 of theNewRect + pWidth into item 3 of theNewRect
put item 2 of theNewRect + pHeight into item 4 of theNewRect
_InitializeAnimationForControl pStack, "rect", pEase, pDuration, theRect, theNewRect
else
put item 1 of theRect + pWidth into item 3 of theRect
put item 2 of theRect + pHeight into item 4 of theRect
set the rect of pStack to theRect
end if
end SetStackWidthAndHeight
private command _InitializeAnimationForControl pControl, pProperty, pEase, pDuration, pStartValue, pEndValue
put the long id of pControl into pControl
cancel sAnims[pControl, "send id"] ## cancel existing animation
if pEase is not among the items of "ease in,ease out, ease in out" then put "ease out" into pEase
if pDuration is not an integer then put "250" into pDuration
put pProperty into sAnims[pControl, "property"]
put pStartValue into sAnims[pControl, "start value"]
put pEndValue into sAnims[pControl, "end value"]
put pEase into sAnims[pControl, "ease"]
put pDuration into sAnims[pControl, "duration"]
put the milliseconds into sAnims[pControl, "start time"]
_easeThePropertySetting pControl
end _InitializeAnimationForControl
command _easeThePropertySetting pControl
put the milliseconds - sAnims[pControl, "start time"] into theElapsedTime
repeat with i = 1 to the number of items of sAnims[pControl, "start value"]
put item i of sAnims[pControl, "start value"] into theStart
put item i of sAnims[pControl, "end value"] into theEnd
switch sAnims[pControl, "ease"]
case "ease in"
put round(aeEaseIn(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
break
case "ease in out"
case "ease in and out"
put round(aeEaseInOUt(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
break
default
put round(aeEaseOut(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
end switch
end repeat
## check before so we know if we need to coerce values to min/max
if theElapsedTime >= sAnims[pControl, "duration"] then
put sAnims[pControl, "end value"] into theValue
end if
## set property
switch sAnims[pControl, "property"]
case "loc"
set the loc of pControl to theValue
break
case "left"
set the left of pControl to theValue
break
case "topleft"
set the topleft of pControl to theValue
break
case "top"
set the top of pControl to theValue
break
case "topright"
set the topright of pControl to theValue
break
case "right"
set the right of pControl to theValue
break
case "bottomright"
set the bottomright of pControl to theValue
break
case "bottom"
set the bottom of pControl to theValue
break
case "bottomleft"
set the bottomleft of pControl to theValue
break
case "vscroll"
set the vscroll of pControl to theValue
break
case "hscroll"
set the hscroll of pControl to theValue
break
case "height"
if word 1 of pControl is "stack" then
lock screen
end if
put the rect of pControl into theRect
put item 2 of theRect + theValue into item 4 of theRect
set the rect of pControl to theRect
if word 1 of pControl is "stack" then
unlock screen
end if
break
case "width"
put the rect of pControl into theRect
put item 1 of theRect + theValue into item 3 of theRect
set the rect of pControl to theRect
break
case "rect"
if word 1 of pControl is "stack" then
lock screen
end if
set the rect of pControl to theValue
if word 1 of pControl is "stack" then
unlock screen
end if
break
end switch