Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

static and scaleable 1

Status
Not open for further replies.

law78

Technical User
Apr 23, 2004
78
GB
Hi people,

I am creating a layout that relies on loading movies into empty placeholders, no problems there, the problem is that I want some elements to be repositioned when a browser is scaled and some not too...

Take a look a look at a very cool site
Take a look at how some elements are repostioned when you scale your broswer (logo, right hand links) and some elements remain static (navigation links, text boxes).

How can I go about achieving this? At the minute I have a main html file which holds the info for the main.swf settings (which hold all the additional swf files, I have set the HTML publish settings to:

Dimensions: Percent

Width 100 x 100 (%)

Scale (No scale)

Flash alignment:

Horizontal: Center
Vertical: Center


Any help/suggestions would be cool.....

Thanks
Lee
 
You need to use the properties of the Stage() object. Stage.width and Stage.height return the size of the browser in pixels and you can use these values to calculate where you want movieclips to be placed. You also need to set up an object that 'listens' for the the browser being resized and fires a function that does the calculations.

You need to have the movie publish options set to 100% scale rather than a set pixel size for this to work properly.

Here's an example that keeps a movieclip centred on the screen when you resize the browser:

Code:
centre.onResize = function() {
	this._x = Stage.width/2-this.width/2;
	this._y = Stage.height/2-this.height/2;
};
Stage.align = "";
Stage.scaleMode = 'noScale';
Stage.addListener(centre);
 
Wangbar,

thanks for the code and the idea......anit it the coolest.

however, I got a problem. I went throguh a tutorial on how to do this and it works great on my pc here, but when I update the files to a web server, ouch!

it doesn't.....

does the server have to be configure a certain way?

I would think so...it's flash...cleint side...right?

let me know

jef
 
Hey Jef.

Yeah - it's a great thing, I've used it on a couple of sites now and it's a big step up from having a little box of Flash in the middle of the page surrounded by HTML, even if it's just a smooth gradient or something simple right across the screen.

I've had a couple of problems online with certain elements not going where they should but I find it clears if you refresh the browser window, it seems that Flash can miss the first resize call if the screen's already maximised.

So a workaround is to fire the 'resize' function again once the site's completely loaded which sorted the problems out for me. To do this you just need to separate out the actual resize code from the listener object so that you can fire it from the main timeline:

Code:
resizeScreen = function () {
	this._x = Stage.width/2-this.width/2;
	this._y = Stage.height/2-this.height/2;
};
centre.onResize = resizeScreen;
//or call 'manually'
resizeScreen();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top