2 Replies Latest reply on Jun 27, 2007 10:26 AM by NoRefund17

    Clip the sides of swf and center

      Hey, been having a problem figuring this one out. This is what i got. I have a main large flash file that loades another external flash file into the center of it. The main large flash file is basicly just background eye candy. (like little animated bleeps and flashes and stuff like that). But the main content of the site, the important part is in the center of it. Now, when the viewr is viewing my website at the same resolution i made it in there is no problem, but if it is larger or smaller, then either the main content is off center, or cut off the screen to the right. What i'm wondering is, how would you go about making it so that the movie will clip (not shrink but get clipped) equally from both sides as the screen resoluation gets smaller, or expands to show more of it if it gets larger (doesnt make it larger, but just reveiles more of the swf that would have been clipped if the screen was smaller res). Also, i dont want a bottom scroll bar when the movie file is clipped, i want the movie to just automaticly center in the viewable region and clip the two sides. Ty :). (obviously i'm not asking you to do the work for me, lol. That wouldnt be fair :P. But if somebody could point me in the right direction that would be great. ty :).

      EDIT: O yeah almost forgot :P, preferebly if possible would like it to update dynamicly if the window is resized after the site is loaded also, to where the main content would continue staying in the center.
        • 1. Re: Clip the sides of swf and center
          Devdoc Level 1
          It sounds like you might want to make something like a liquid interface. It’s not to tricky to keep something centered, just follow these steps. On the first frame of your movie, set these properties:

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

          scaleMove is set to noScale which will stop the flash movie from rescaling as the size of the window is changed. Align is set to TL (Top Left) aligns the flash movie from the top left corner (instead of the center which is the default setting).

          So now the flash movie is relative to the top left of the window and won’t scale itself. Now we just make sure that the movie clip that you load on screen will stay in the center at all times. Do this by adding your clip as a listener to the Stage (so it will know when the window is resized).


          And just define the onResize function on the clip or the associated class that will be called:

          function onResize() {
          movieclip._x = Math.floor( (Stage.width/2) - (movieclip._width/2) );
          movieclip._y = Math.floor( (Stage.height/2) - (movieclip._height/2) );

          The width of the stage divided by two is the exact center of the screen and taking away half of the width of the movie clip should place the clip at the center if the registration point is at the top left corner of the clip. Math.floor will even out the number to the closest pixel value so that any text in the clip won’t get anti-aliased.

          This should result in the movieclip getting clipped rather than scaled if it is larger than the screen.

          Good luck!
          • 2. Re: Clip the sides of swf and center
            NoRefund17 Level 1
            awsome man ty for the help :).