How to Position Movie Clips Based on Browser Resizing, WITH initial loading

Posted on 2008-11-15
Last Modified: 2013-11-12

I'm using a code to have a movieclip (capitulo) center on the right side of the browser window, no matter what size window. My problem is that the script requires the window to be resized, ca it be done on initial load?
thank you,
Stage.scaleMode = "noScale";

Stage.align = "TL";

var stageListener:Object = new Object();

stageListener.onResize = positionContent;


function positionContent():Void {

	imageholder._width = Stage.width;

	imageholder._yscale = imageholder._xscale;

	if (imageholder._height>Stage.height) {

		imageholder._height = Stage.height;

		imageholder._xscale = imageholder._yscale;


	imageholder._x = Stage.width/2-imageholder._width/2;

	imageholder._y = Stage.height/2-imageholder._height/2;


	  capitulo._x = Stage.width - capitulo._width;

  capitulo._x = Stage.width - capitulo._width;

capitulo._y = Stage.height / 2 - capitulo._height / 2;


Open in new window

Question by:cristobal_ny
    LVL 8

    Accepted Solution

    Hello chris,

    When the browser resizes a function is called by the resize listener. To solve your problem just call the function when all items that need to resize or reposition are on the stage.

    Hope this works for you.

    // when all items that need rescaling/repositioning are on the stage call

    Open in new window


    Author Closing Comment

    Thank you for your answer. It works perfect!
    I placed it into the first frame. For the next time can you please specify how to integrate it into the code or project. Thank you again.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now