Flash · Align to Window

  • Started
  • Last post
  • 2 Responses
  • autonoma

    What's the easiest way to go about having an MC align to the window's bottom right instead of the stage's bottom right?

    Say the flash movie stage is 400px by 400px and centered, but the viewer is maximized to 1280 by 1024. How can I go about aligning something to the top left or bottom right of the the viewer window?

    I've messed with the Align component at www.flashcomponents.net, but don't find it to really work properly.

    Any other ideas?

  • unfittoprint0

    //on a blank HTML page
    //make your swf 100% width % height

    //in a _root actionscript layer
    //make an align function

    //use to align your MC
    alignMC=function(align){
    if(align=="top left"){
    myMC._x=0;
    myMC._y=0;
    } else if (align == "center"){
    myMC._x=(Stage.width-myMC._width...
    myMC._y=(Stage.height-myMC._heig...
    } else if (align == "bottom right"){
    myMC._x=Stage.width- myMC._width;
    myMC._y=Stage.height - myMC._height;
    }
    }

    //create the stage listener
    Stage.align = "LT";
    Stage.scaleMode = "noScale";
    Reziser = new Object();
    Stage.addListener(Reziser);
    Reziser.onResize = function() {
    alignMC("bottom right");
    };

  • autonoma0

    Thanks, unfit. I actually knew all of that, but for some reason Stage.width and Stage.height was not working for me at all a while back, so I didn't even try it this time around.

    Thanks a million.