3 Replies Latest reply on May 13, 2009 3:42 PM by Greg Dove

    Scale one MC but not another?

    atgilleland

      Hi, It's been awhile since I've worked in as2 but I think I'm close to accomplishing this. I've got one mc to center itself in the browser and move with the browser size without scaling. What I'm trying to do now is get my background video to scale with the browser without affecting the centered mc. I've grabbed this code and altered from another source. Any ideas?

       

      // ***Stage aligned top left
      Stage.align = "TL";
      // *** Stop the stage from scaling with the browser window.
      Stage.scaleMode = "noScale";
      stop ();
      // initiate postitions and scaling values for objects
      fluid._x = Stage.width/2
      fluid._y = Stage.height/2
      bottomstretch._height = Stage.height;
      rightstretch._height = Stage.height;
      topstretch._width = Stage.width;
      rightstretch._x=201;
      vid._x = Stage.width - vid._width
      // end initial position setting


      //create a listner that checks to see if the browser window is resized
      sizeListener = new Object();
      sizeListener.onResize = function() {
          // change movieclip properties when the window is resized.
          topstretch._width = Stage.width;
          fluid._y = Stage.height/2;
          fluid._x = Stage.width/2;
          bottomstretch._height = Stage.height;
          rightstretch._height = Stage.height;
          //*note* 200 is the width of the left column
          vid._x = Stage.width - vid._width
      };
      Stage.addListener(sizeListener);

        • 1. Re: Scale one MC but not another?
          Greg Dove Level 4

          Your video isn't full stage?

           

          If so it really depends what your layout rule is.

           

          if your video is always a fixed percentage of the stage width and height, right aligned, and centered vetically it might be something like this.

           

          sizeListener.onResize = function() {
              // change movieclip properties when the window is resized.
              topstretch._width = Stage.width;
              fluid._y = Stage.height/2;
              fluid._x = Stage.width/2;
              bottomstretch._height = Stage.height;
              rightstretch._height = Stage.height;
              //*note* 200 is the width of the left column

             vid._width=Stage.width*.4; //40%

            vid._height=Stage.height*.25;//or whatever;


              vid._x = Stage.width - vid._width

          vid._y=Stage.height/2-vid._height/2;//vertical center
          };

           

           

          This code is not tested... but hopefully its relevant and will give you an idea for what you want.

          • 2. Re: Scale one MC but not another?
            atgilleland Level 1

            Thanks for the help but I think it has something to do with this line of code:

             

            Stage.scaleMode = "noScale";
            stop ();

             

            Which is great b/c it's keeping my logo in the center from scaling but if there was a way to override that code for my video background MC

            • 3. Re: Scale one MC but not another?
              Greg Dove Level 4

              Stage.scaleMode = "noScale";

               

              you need to keep that to avoid having your other movieclip (which is being centered) not scale.

               

               

              So if your vid clip is supposed to be full stage, then you just need to set its width and height to the Stage.width and Stage.height in your sizeListener.onResize handler (assuming it's positioned at 0,0 which it doesn't seem to be)

               

              Otherwise if it's not full stage, then you need to size and position it with a bit of math like I showed earlier (which as I mentioned was untested code).