View Single Post
Nutrox's Avatar Nutrox Nutrox is online now Super Moderator 17 Creative Assets 2005-09-06 #2 Old  
The first thing you will need to do is create an HTML page, add your Flash movie to it in the normal way, and give the movie a 100% width and 100% height (can be done directly in the HTML page or via CSS). You will probably also want to set the padding and margin of the <body> to 0px.

Create a new Flash movie and add a movieclip to the stage (give the movieclip the instance name "mainContent_mc") then add the following code to the first frame of the main timeline...

ActionScript Code:
  1. stop();
  2.  
  3. Stage.scaleMode = "noscale";
  4. Stage.align = "tl";
  5. Stage.addListener({onResize:reposition});
  6.  
  7. function reposition() {
  8.     var mc = _root.mainContent_mc;
  9.     var newX = Math.floor((Stage.width - mc._width) / 2);
  10.     var newY = Math.floor((Stage.height - mc._height) / 2);
  11.     mc._x = newX;
  12.     mc._y = newY;
  13. };
  14.  
  15. reposition();
If you place all of your site's content inside the "mainContent_mc" movieclip then it will all be centered in the browser, and will adjust itself whenever the browser / flash movie is resized.

That code basically tells Flash to resize the stage instead of rescaling it, and it sets up a listener for the Stage which calls the reposition() function whenever the main movie (HTML object) is resized.

Stage.width and Stage.height will return the actual size of the stage, and they are always available to you use.

Hope that helps.
Reply With Quote