PDA

View Full Version : Reacting to Stage Size



Medyman
03-10-2007, 03:30 PM
Hi...

I'm creating a flash website which I want to have react to the size of the stage. So, I the following set of questions:

(1) Can flash detect the stage size (say, after a browser resize) and increase the width of a particular movie clip in reaction? What about a mask?

(2) Is there a way to position certain items on a particular frame in this same manner. (for example, if I want the header of my site to always be 30 px from the left border, how would I do that?)

I imagine this can be done using Stage.width and Stage.height but I'm not quite sure how exactly. Notice that I only want it to change in the horizontal direction. Vertically, it should stay the same size.

Thanks for the help.

BLiZZaRD
03-10-2007, 04:00 PM
Stage.width and Stage.height are read only, and once you publish, the stage itself doesn't ever change sizes. The browser window does, so you can scale the movie accordingly, but this is rough.

You may want to look into scaleMode and align...



Stage.scaleMode = "noScale";
Stage.align = "LT";


You can also add a listner and make a resize function:



Stage.scaleMode = "noScale";
var myListener:Object = new Object ();
myListener.onResize = function ()
{
mytext.text = "Stage size is now " + Stage.width + " by " + Stage.height;
};
Stage.addListener (myListener);


For the positioning try something like the following:



Stage.align = "LT";
Stage.scaleMode = "noScale";
stageListener = {};
stageListener.onResize = function(){
header._y = Stage.height - header._height;
header._x = Stage.width - header._width;
}
Stage.addListener(stageListener);

Medyman
03-11-2007, 09:27 PM
Thanks Blizzard

I saw this same tutorial as well and it works beautifully.

It's a basic intutive manipulation of the "_x", "_y", "_width" and "_height" properties.

Why do you say its rough?
It looks pretty good and it adds a lot more flexiblity to my design.


Thanks though :)

BLiZZaRD
03-12-2007, 10:33 PM
You are welcome. It's rough because I prefer to use external means to do my resizing. Usually in html and CSS, it just helps me with productivity and speed.

Medyman
03-12-2007, 10:41 PM
You are welcome. It's rough because I prefer to use external means to do my resizing. Usually in html and CSS, it just helps me with productivity and speed.

Is there any way to do this with html and css??

You'd bascially have to put each design element into a seperate flash file wouldn't you??

BLiZZaRD
03-12-2007, 10:45 PM
No. between html, css, and javascript you can do anything in Flash. Depends on how hard and long you want to work on it.

If you have what you are after and it works smooth I say stick with it. I just meant I prefer to go the other way with the design, but then again I don't do "whole sites" in Flash, just pieces, and my "expertise" (if there is such a thing) is more geared towards gaming. :)

Buckley
02-22-2008, 05:23 PM
Is there a way I can have the...

Stage.scaleMode = "exactFit";
Stage.align = "LT";

...follow the movie as it is loaded into another movie? Is it a pathing problem?

MOVIE 1 is loaded into MOVIE 2 which is loaded into MOVIE 3; MOVIE 1 is the one I want to keep the stage cropped to Exact Fit.

See "Los Beer Bros. animation" at the following URL:

http://parliamentbooks.com/

BLiZZaRD
02-22-2008, 06:53 PM
Okay I see it. Which of the 3 movies is the animation?

Buckley
02-22-2008, 07:15 PM
Okay I see it. Which of the 3 movies is the animation?

Thanks for the quick response. The animation is MOVIE 1.swf, loaded into MOVIE 2.swf , which is in turn loaded into MOVIE 3.swf

In the animation, you'll notice that the barstools are "hanging" below the movie's dimension, because the barstools extend out onto the stage. And similarly, when I enlarged the art for a closeup shot, the need for cropping is even more obvious.

Can't I --in MOVIE 3.swf--simply path to MOVIE1.swf loaded inside MOVIE2.swf and tell MOVIE1.swf's stage what to do?

Medyman
02-25-2008, 01:53 PM
Just use a mask within Movie2 that is the size you want it to be

Create a MC that is the exact size that you want Movie1 to be (for example purposes, let's call it "mask").
Then in Movie2, add:

movie1_mc.setMask("mask");

As long as there are no other alignment issues, that will work.