This content has been marked as final. Show 5 replies
Should not be to hard, to scale a sprite within certain limits:
determine size of castmember
devide targetWidth by castmemberWidth
devide targetHeigh by castmemberHeight
(whichever result is smallest is leading (the scalefactor), whatch out
for Director's automatic rounding! cast castmemberWidth and
castmemberHeight to a float-type variable with the float() function for
then you know what the scalefactor which is needed to scale down to the
desired dimensions. Multiply both width and height by the scalefactor
and you're done.
Whatch it though, when the scalefactor is greater than 1, the image was
actually smaller than the desired dimension. You will be upscaling in
Not really sure if this is the fastest way. You could try and do it with
imaging lingo as well, doubt it'll be faster.
Not sure either if it's wise to convert the width and height values you
calculated back to integers before actually scaling the sprite. Works if
you don't though.
> I've just been told (in the above thread) about how to link a local file
> to a web image.
> After I've imported that external image (while the movie is playing) I
> want to scale it in proportion to fit in a box defined on screen. Is
> that relatively easy?
Hi Manno - Thanks again, for this reply and the one above. I haven't got to
test them out as was doing a few other things but think I understand what I
need to do.
I actually discovered a good behavior resource at Mediamacros.com.Over there,
there's even a 'scale image' custom message.
It's in the format: rescale (member , max width, max height)
I tested it using:
rescale (member("myImage"), 300, 400)
and it did it perfectly.
If that script works, you're done :)
I just wonder, (Dave, you there?) why the loop?
> Hi Manno - Thanks again, for this reply and the one above. I haven't got to
> test them out as was doing a few other things but think I understand what I
> need to do.
> I actually discovered a good behavior resource at Mediamacros.com.Over there,
> there's even a 'scale image' custom message.
> It's in the format: rescale (member , max width, max height)
> I tested it using:
> rescale (member("myImage"), 300, 400)
> and it did it perfectly.
>>Why the loop?
No idea. Not sure what I was thinking with that. I just made this one:
on rescale mRef, maxWide, maxHigh
oWide = mRef.width
oHigh = mRef.height
useRatio = max(maxWide / float(oWide), maxHigh / float(oHigh))
ni = image(oWide * useRatio, oHigh * useRatio, 32)
ni.copyPixels(mRef.image, ni.rect, mRef.rect)
This works just as well, and is a wee shorter. <g> It also returns a new
image, instead of modifying the original. Also, since it keeps the aspect
ratio, I like to typically pass in 0 for one of the arguments so that you
know how the resizing will happen.
For instance, if my original is 744 x 178 and I want to resize it so the
width is 100:
member(new(#bitmap)).image = rescale(member("fullSize"), 100, 0)
The new image will be 100 x 24
Or, if you know you wanted the height to be 24:
member(new(#bitmap)).image = rescale(member("fullSize"), 0, 24)
Adobe Community Expert
DMennenoh **AdobeCommunityExpert** wrote:
>>> Why the loop?
Always nice to look at your own old code ;)