center loaded swf in container
starting on AS3 and liking some of it but going out of my mind with trying to center a loaded swf.
here is my code:
PHP Code:
// SETUP CONTAINER
var container:MovieClip = new MovieClip();
this.addChild(container);
container.x = ((stage.stageWidth/2) - (container.width/2));
container.y = ((stage.stageHeight/2) - (container.height/2));
// CENTER CONTAINER
function centreContainer(evt:Event):void {
container.x = ((stage.stageWidth/2) - (container.width /2));
container.y = ((stage.stageHeight/2) - (container.height /2));
trace("c.w = " + container.width);
trace("c.x = " + container.x);
}
function loadComplete(evt:Event) {
stage.addEventListener(Event.RESIZE, centreContainer);
}
// CREATE LOADER
var loader:Loader = new Loader();
var loadProgress:Number;
var sectionToLoad:String;
// LOADER FUNCTION
function loadSection(sectionPath:String):void {
var loaderURLReq:URLRequest = new URLRequest(sectionPath);
loader.load(loaderURLReq);
loader.contentLoaderInfo.addEventListener(Event.OPEN, loadBegin);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadDuring);
container.addChild(loader);
//trace("clicked");
}
a similar resize function for a movieclip on the stage works perfectly, it only seems to have trouble with loaded swfs. it seems that it isn't subtracting the proper width.
any help is greatly greatly greatly appreciated!