Centering Box in middle of site

Won't open in center, you have to resize your Browser window first

Page 1 of 1

2 Replies - 717 Views - Last Post: 10 February 2010 - 03:09 PM

#1 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Centering Box in middle of site

Posted 10 February 2010 - 02:23 PM

Hi,

I'm making a site where I load content from my menu into a centerBox_mc

The thing is when you first launch the swf the box isn't centered, you need to resize the box first for it to center.

Here is the code I used.

this.mcContent.loadMovie("events.swf", 1);

myListener = new Object();

myListener.onresize = centercontent;
Stage.align = "TL";
Stage.scaleMode = "noScale";
Stage.addListener(myListener);
function centercontent() {
	mcContent._x = Math.ceil(Stage.width/2-mcContent._width/2);
	mcContent._y = Math.ceil(Stage.height/2-mcContent._height/2);
}
centercontent();




Does anyone know why it has to resized before it actually works?

Thanks,
Bmcc81

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Centering Box in middle of site

#2 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: Centering Box in middle of site

Posted 10 February 2010 - 02:54 PM

yes, when you loadMovie, mcContent doesn't have any dimensions yet.
normally you would listen for the loader to Event.COMPLETE (in as3) and then center it using it's width and height now that it is available.

your workaround seems to work.
Was This Post Helpful? 0
  • +
  • -

#3 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Centering Box in middle of site

Posted 10 February 2010 - 03:09 PM

Thanks for responding. getting a little nervous....

The thing is that I'm still having problems with it.

It doesn't seem to load in the right spot at firt.

& when I load a swf into it, it doesn't stop looping.

I've tried changing the CENTERING CODE, but doesn't seem to work.

If you open it up you can see what I mean. I am also now doing this in AS3.

I'd really appreciate this help.

Thanks,

Attached File(s)


This post has been edited by bmcc81: 10 February 2010 - 03:18 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1