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

Hello

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,
Cris
Stage.scaleMode = "noScale";
Stage.align = "TL";
var stageListener:Object = new Object();
stageListener.onResize = positionContent;
Stage.addListener(stageListener);
 
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

cristobal_nyAsked:
Who is Participating?
 
wal_toorConnect With a Mentor Commented:
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.

greetz,
walter
// when all items that need rescaling/repositioning are on the stage call
positionContent();

Open in new window

0
 
cristobal_nyAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.