# Center

**URL:** <https://forum.kirupa.com/t/center/236863>\
**Category:** Uncategorized\
**Created:** [August 24, 2007, 12:39pm UTC](https://forum.kirupa.com/t/center/236863 "2007-08-24T12:39:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmb](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@bmb](https://forum.kirupa.com/u/bmb)\
**Post date:** [August 24, 2007, 12:39pm UTC](https://forum.kirupa.com/t/center/236863/1 "2007-08-24T12:39:36Z")

</div>

I have a swf that call another swf, i use addchildAt after the preload. The first swf is center using the size of the stage, but i can do the same to the second swf. give me a error "

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at swf2\_fla::MainTimeline/swf2\_fla::frame1()"

I have the flas here: [http://www.digisource.pt/test/flas.zip](http://www.digisource.pt/test/flas.zip)

* * *

swf1.test

I creat a mc call cub1

```php
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

stage.align=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
addEventListener(Event.ENTER_FRAME, resizeHandler);
var aCarregar:Loader = new Loader();
carregarSwf("swf2");
function resizeHandler(event:Event):void {
 
 cub1.x = (stage.stageWidth/2);
}
function carregarSwf(teste:String) {
 var swfACarregar:String=teste;
 var swfQueCarrega:URLRequest = new URLRequest(swfACarregar+".swf");
 aCarregar.load(swfQueCarrega);
 aCarregar.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
 aCarregar.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
 
}
function showPreloader(evt:Event):void {
//code to control preload
}
function showProgress(evt:ProgressEvent):void {
//math of the preload bar
}
function showLoadResult(evt:Event):void {
 addChildAt(aCarregar,0);
}

```

* * *

in swf2.fla - i creat mc call cub2

* * *

import flash.events.Event;  
import flash.display.StageAlign;  
import flash.display.StageScaleMode;

## stage.align=StageAlign.TOP\_LEFT; stage.scaleMode=StageScaleMode.NO\_SCALE; stage.addEventListener(Event.RESIZE, resizeHandler); addEventListener(Event.ENTER\_FRAME, resizeHandler); function resizeHandler(event:Event):void { cub2.x = (stage.stageWidth/2); }

Please help me understand the problem  
Thanks
