5 Replies Latest reply on Feb 16, 2010 7:14 AM by Ned Murphy

    MovieClip / Browser Alignment




      I'm still learning Flash and cant write AS from scratch yet, so am therefore at the stage where I'm finding pieces of AS online, and then trying to use / edit them as I need.


      I've got the following piece of AS that aligns a movie clip to the right hand side of the browser, and keep it there when the browser is resized.  It works perfectly.


      I'm trying to update this code to make a movieClip alight to the bottom of the browser (not the right side), but its a bit beyond me.  Can anyone help?



      // ***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

      bottomstretch._height = Stage.height;

      rightstretch._height = Stage.height;

      topstretch._width = Stage.width;


      topmenu_mc._x = Stage.width - topmenu_mc._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;

      bottomstretch._height = Stage.height;

      rightstretch._height = Stage.height;

      //*note* 200 is the width of the left column

      topmenu_mc._x = Stage.width - topmenu_mc._width




        • 1. Re: MovieClip / Browser Alignment
          Ned Murphy Adobe Community Professional & MVP

          In this case you want to utilize the Stage.height minus the object height to determine its _y location, assuming the vertical registration of the object is at its top.

          • 2. Re: MovieClip / Browser Alignment
            JOliver77 Level 1

            Hi, thanks for the response.  Apologies if I'm being a little slow but Im not totally understanding what your saying.  Could you be a little clearer?

            • 3. Re: MovieClip / Browser Alignment
              Ned Murphy Adobe Community Professional & MVP

              Not really.  What part of what I described do you not understand? ("all of it" as a response means you need to study what you have working now and learn/understand how it works).

              • 4. Re: MovieClip / Browser Alignment
                JOliver77 Level 1

                I'm trying to study the code, but unfortunately its currently above my level of understanding.  Hence my posting on this forum for some help and guidance.


                I'm sorry, but you're reply didnt make sense to me, most likely because your assumption of my level of AS understanding is higher than it actually is.


                Ideally I'm looking for someone to update the code to perform how I need it to, and then explain to my why they have altered the areas they have, and what these alterations has achieved.  This is not because I am lazy and want the code updating with as little effort as poss - but because I find it easier to understand how something works if I can see the changes made, and understand what the changes have accomplished.


                If this is something you dont have the time to do, then I completely understand and thank you for your time so far.

                • 5. Re: MovieClip / Browser Alignment
                  Ned Murphy Adobe Community Professional & MVP

                  _x and _y are properties of an object that define where it is located relative to the coordinate system of whatever stage/object it exists in.  width and height (or _width and _height for most objects in AS2) are properties of an object that define exactly those properties, width and height.  So if you take the Stage.height and subtract the object._height, you end up with a value that is the height of the object away from the bottom of the stage.


                  If you want to learn/understand this stuff, it is better to start simple and build your own rather than blindly copy other people's code.  Put an object on a stage and adjust these various properties and see what happens to it... learn by doing.


                  As far as rewriting code for you, that's best done by you since you know what object you are trying to align.  You can wait around and someone may do it for you, but this is so basic that you really need to deal with it yourself.  If you don't already understand what makes the object align to the right, then you aren't likely to understand what makes it align to the bottom by having it handed to you.  You should find some online tutorials or sign up for a class in Flash design.  lynda.com offers numerous tutorials that I have heard are very good for beginners.

                  1 person found this helpful