all groups > flash actionscript > september 2005 >
You're in the

flash actionscript

group:

I should know this, but ...



I should know this, but ... keithb
9/28/2005 10:08:00 PM
flash actionscript: How can I dyamically resize the stage?

Thanks,

Keith

Re: I should know this, but ... keithb
9/29/2005 8:09:47 AM
Thanks for the explanation. It was very helpful. The 'movie' I am working on
runs in a web page and contains a list of items provided by the web server
and placed at x-y coordiates using actionscript. Sometimes the list
'overflows' the stage. Is there some way to use scrollbars in Flash so that
when the list overflows the stage area the scroll bars appear and allow the
user to scroll the list? If scrollbars are not available, there another way
to handle stage overflow, other than making the stage ridiculously large?

Thanks again,

Keith
[quoted text, click to view]

Re: I should know this, but ... bobbysojitra
9/29/2005 10:01:10 AM
Not sure if this will work. havent tried it, but maybe :

Stage.width = yourWidthValue;
Stage.height = yourHeightValue;

Re: I should know this, but ... David Stiller
9/29/2005 10:38:53 AM
[quoted text, click to view]

Heh, why offer sample code that you A) haven't tried and/or B) have
little confidence in? Potentially not very helpful, right? Keith may have
tried that himself (it won't work) ... so now where are we? ;)

Okay, I'm a fan of the documentation. Fire it up. Hit that F1 key. :)
Let's step through this.

Here's an important term: "class". It means all sorts of things in
English, if you stop to really think about it, but here it refers to a "blue
print" that defines an object in ActionScript. Movie clips, text fields,
numbers, strings, even the Stage, can all be described -- defined, rather --
by their namesake classes. For a real eye-opener, look up the "MovieClip
class" entry in the ActionScript Language Reference. You'll see everything
you can do with a movie clip (its methods), all its characteristics (its
properties), and all the things it can react to (its events). Powerful,
powerful, powerful information! Plus sample code.

In this case, we're interested in resizing the Stage, so look up the
"Stage class" entry. You'll see Stage doesn't have any methods, so it
doesn't really *do* anything, but it does have properties, including
Stage.height and Stage.width -- which you'll see right away are read-only
(you can't set them), so the suggested code above doesn't do anything.
You'll also see that Stage has an event, which is what solves the issue
here.

Note that the onResize event is fired (that is, occurs) on two
conditions: A) when the Stage's scaleMode property is set to "noScale" and
B) when the SWF is resized.

So, Keith, to answer your question ... no, the Stage cannot be resized
via ActionScript, but *when* the Stage is resized (such as when your HTML
specifies 100% height and width and the browser is resized), you'll know it,
and then you can use the Stage.height and Stage.width properties to acount
for the new size in your other code.

See this Moock blog entry for details.

http://www.moock.org/blog/archives/000021.html


David
stiller (at) quip (dot) net
Tackling the ActionScript Language Reference
http://www.quip.net/tutorials/

Re: I should know this, but ... David Stiller
9/29/2005 11:46:45 AM
Keith,

[quoted text, click to view]

You can note the Stage dimensions onResize and re-adjust all those
items' _x and _y properties. Or you can use the ScrollPane UI Component and
use its setSize() method onResize. You'll have to load all the items you're
talking about into a movie clip and set that movie clip as the content
property of your ScrollPane instance, but that'll do it.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

AddThis Social Bookmark Button