This content has been marked as final. Show 1 reply
> Hi everyone. I'm building a photo gallery in Flash and I'm
> wodering how to get the stage to resize to exactly fit the
Ah, that's just it. You're thinking about it backwards.
> For example: if I load in an image that is 500x500, I want
> the stage to resize to those dimensions.
The Stage can't be resized via ActionScript -- but keep reading.
> Then if I load in an image that is 800x600, I want the stage
> to resize to those dimensions and so on.
Yup. You can find out all the possible functionality for the Stage by
looking up the "Stage class" entry of the ActionScript Language Reference.
(This is true of any scriptable object in Flash ... movie clips are defined
by the MovieClip class, dynamic text fields by the TextField class, and so
on.) But absent from the functionality is how to actually *set* the Stage
> I've read about the Stage.onResize method but that is triggered
> after the stage has been resized, but I'm confused as to what
> causes the stage to change sizes in the first place.
When you publish your SWF and set the relevant HTML attribute values to
percents -- such as 100% width/height -- the Stage.onResize event fires when
the browser is resized.
> The stage.height and stage.width properties are read-only so I can't
> change the size of the stage using simply Stage.width = widthOfImage
> and Stage.height=heightOfImage. So what's the deal?
Ah, cool. You've already been reading up on the Stage class, then.
This is more than many do. The approach you may want to take is ... oh,
maybe center your loaded images when Stage.onResize fires. Loaded images'
registration points will be their upper left corners, and the Stage's 0,0
point is always upper left, so depending on the width and hight of your
loaded images, you can adjust the _x/_y properties of their container clips
to suit. I could see, too, resizing the images to match your Stage. But
for better or worse, there's simply no resizing of the Stage.
stiller (at) quip (dot) net
Dev essays: http://www.quip.net/blog/
"Luck is the residue of good design."