# Infinite for loop

**URL:** <https://forum.kirupa.com/t/infinite-for-loop/309410>\
**Category:** Uncategorized\
**Created:** [May 14, 2010, 9:13am UTC](https://forum.kirupa.com/t/infinite-for-loop/309410 "2010-05-14T09:13:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aldus](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aldus](https://forum.kirupa.com/u/Aldus)\
**Post date:** [May 14, 2010, 9:13am UTC](https://forum.kirupa.com/t/infinite-for-loop/309410/1 "2010-05-14T09:13:43Z")

</div>

Hello

I have a class with 3 object from a library

```auto

public class Car extends BaseCars {

```

In the class I made a for-loop because i want for each car a dot on my screen.

```auto

private var point:Sprite
....

    for (var i:uint=0; i < this.numChildren; i++){
                
                var dsp:DisplayObject = this.getChildAt(i);
                point = new Sprite;
                point.graphics.beginFill(0x0FAB905,1);
                point.graphics.drawCircle(dsp.x/5, dsp.y/5, 30);
                point.graphics.endFill();
                addChild(point);
                
                //trace(i);
            }

```

Yet, the library contains 3 cars.  
If I trace (i) is says in my output:

```auto

0
1
2

```

Same with the trace of ‘dsp’, also 3 x [object MovieClip]  
But if I do ‘addChild(point);’  
My browser crashes cause I’m in an infinite loop.

Thanks
