• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

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

0
cristobal_ny
Asked:
cristobal_ny
1 Solution
 
wal_toorCommented:
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

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now