# addChildAt() problem

**URL:** <https://forum.kirupa.com/t/addchildat-problem/268906>\
**Category:** flash\
**Created:** [August 20, 2008, 7:44am UTC](https://forum.kirupa.com/t/addchildat-problem/268906 "2008-08-20T07:44:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evil\_twin](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Evil\_twin](https://forum.kirupa.com/u/Evil_twin)\
**Post date:** [August 20, 2008, 7:44am UTC](https://forum.kirupa.com/t/addchildat-problem/268906/1 "2008-08-20T07:44:31Z")

</div>

I’ve got a series of swf files that load when you select a button (example 1.swf, 2.swf, 3.swf etc…). I load 1.swf, then use addChildAt() to unload 1.swf and load in 2.swf etc.

This works fine, but when I try to load 3.swf, 1.swf loads, and without prompting then 2.swf loads. I can never get past the second .swf file. Here’s my code for 1.swf:

```auto

var imageRequest:URLRequest = new URLRequest("2.swf");
var imageLoader:Loader = new Loader();

next_mc.addEventListener(MouseEvent.CLICK, nextButton);

function nextButton(event:MouseEvent):void {
    imageLoader.load(imageRequest);
    this.addChildAt(imageLoader, 1);
}

next_mc.buttonMode = true;

```

the code used in 2.swf:

```auto

var imageRequest:URLRequest = new URLRequest("3.swf");
var imageLoader:Loader = new Loader();

next_mc.addEventListener(MouseEvent.CLICK, nextButton);

function nextButton(event:MouseEvent):void {
    imageLoader.load(imageRequest);
    this.addChildAt(imageLoader, 1);
}

next_mc.buttonMode = true;

```

Can anybody see what I’m doing wrong to get the results I’m getting? I’d appreciate any help.
