# \[Q\] AddChild/Loader aren't working inside a LOOP?

**URL:** <https://forum.kirupa.com/t/q-addchild-loader-arent-working-inside-a-loop/232592>\
**Category:** Uncategorized\
**Created:** [July 16, 2007, 9:17am UTC](https://forum.kirupa.com/t/q-addchild-loader-arent-working-inside-a-loop/232592 "2007-07-16T09:17:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfree](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@manfree](https://forum.kirupa.com/u/manfree)\
**Post date:** [July 16, 2007, 9:17am UTC](https://forum.kirupa.com/t/q-addchild-loader-arent-working-inside-a-loop/232592/1 "2007-07-16T09:17:44Z")

</div>

Dear all,

I am trying to create 10 Balls (MovieClip), and each ball will load/insert an IMAGE (JPG)  
However, the result is …

- only ball (b9) works(that can load the image in it.)
- ball (b0 - b8) not working (all are empty -NO IMAGE in it)

Could any body help me please ???  
What’s going on with me script ???  
Thanks

main.fla

```auto
 
var loader:Loader = new Loader();
var vPic:URLRequest = new URLRequest("http://www.abc.com/image1.jpg");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.load(vPic);
for (var i=0; i<10; i++) {
 var b:Ball = new Ball();
 b.name = "b"+i;
 b.setHolder(picLoader);
 addChild(b);
}

```

Ball.as

```auto
 
package {
 import flash.display.MovieClip;
 import flash.events.MouseEvent;
 import flash.display.Loader;
 public class Ball extends MovieClip {
  private var ox:Number, oy:Number;
  private var holder:MovieClip = new MovieClip(); // create a MovieClip to place the IMAGE
 
  public function Ball() {
   this.buttonMode = true;
   this.ox = this.x = 200;
   this.oy = this.y = 200;
   this.addChild(holder); // create a MovieClip to place the IMAGE
   this.addEventListener(MouseEvent.MOUSE_DOWN, onDragHandler);
   this.addEventListener(MouseEvent.MOUSE_UP, onDropHandler);
  }
  function onDragHandler(e:MouseEvent):void {
   this.startDrag();
  }
  function onDropHandler(e:MouseEvent):void {
   this.stopDrag();
  }
  public function setHolder(obj:Loader):void {
   this.holder.addChild(obj); // add IMAGE to the MoiceClip
  }
 }
}

```
