# 1009: when referencing stage.stagewidth from the child

**URL:** https://forum.kirupa.com/t/1009-when-referencing-stage-stagewidth-from-the-child/322801
**Category:** flash
**Created:** [June 3, 2011, 3:40pm UTC](https://forum.kirupa.com/t/1009-when-referencing-stage-stagewidth-from-the-child/322801 "2011-06-03T15:40:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mikaelf](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mikaelf](https://forum.kirupa.com/u/mikaelf)
#### Post date: [June 3, 2011, 3:40pm UTC](https://forum.kirupa.com/t/1009-when-referencing-stage-stagewidth-from-the-child/322801/1 "2011-06-03T15:40:42Z")

</div>

[FONT=monospace]Hi, I was hoping you could help me out my hair is getting grey.

I have a main.swf and a slider.swf. I load the slider.swf into main.swf.

In my slider.swf I have this code which adds an image to the stage from the Library:  
[/FONT]

```auto
var photo1_mc:photo1 =new photo1;
addChild(photo1_mc);
photo1_mc.x=stage.stageWidth/2;

```

[FONT=monospace]

The code works fine when compiling slider.swf, but when loading the slider.swf into the main.swf I receive TypeError: Error #1009: Cannot access a property or method of a null object reference.

I assume it has to do with the stage.stageWidth. Is there a another way to reference the stage.

If I load the the image externally via a loader I can use the stage.stage Width.

THANX ALOT

[/FONT]
