View Full Version : scaling using as
jimw00d
February 16th, 2003, 10:01 AM
Hey,
If I drew a rectangle on stage using the api drawing methods and say the box was 100x50 in size, what method could I use to increase the size of the box over a period of time so that it appears to grow in size, or indeed shrink in size.
I understand I could simply use a for loop and then increase the width and height accordingly but how would I set the size of the rectangle that I would like the scaling to stop at.
cheers
Any help would be great.
kode
February 16th, 2003, 10:40 AM
scale = function (instance, amount, endscale) {
if (instance._xscale != endscale) {
instance._xscale = instance._yscale += amount
updateAfterEvent ()
} else {
clearInterval (scaleInterval)
}
}
scaleInterval = setInterval (scale, milliseconds, instance, amount, endscale)
milliseconds number of milliseconds to wait between every execution
instance instance name of the movie clip to scale
amount percentage to scale the movie clip in each execution
endscale final xscale and yscale value
example:
if your movie clip instance name is rectangle. you want to increase its scale by 10% each second and the final scale is 200%
scaleInterval = setInterval (scale, 1000, rectangle, 10, 200)
hope it helps :)
pom
February 16th, 2003, 06:25 PM
Careful with this because you won't necessarily have instance._xscale == endscale at some point so it might not stop at all :)
kode
February 16th, 2003, 06:35 PM
scale = function (instance, amount, endscale) {
if (instance._xscale < endscale) {
instance._xscale = instance._yscale += amount
updateAfterEvent ()
} else {
clearInterval (scaleInterval)
}
}
scaleInterval = setInterval (scale, milliseconds, instance, amount, endscale)
happy ?? =)
pom
February 16th, 2003, 07:13 PM
No: what if you want the clip to shrink? :beam: :beam:
kode
February 16th, 2003, 07:25 PM
you add a new variable to tell the function what to do :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.