Help with class reuseability problem

Hi I have a class that was working fine on its own but is now running into a problem as I try to restructure it in a way to make it more reusable.

Heres the class:


package 
{
 import flash.display.Sprite;
 import flash.display.DisplayObject;
 import fl.transitions.Tween;
 import fl.transitions.easing.Strong;
 
 public class ImageRotater extends Sprite 
 {
  private var numImages:int;
  private var duration:int;
  private var image:DisplayObject;
  private var tween:Tween;
 
  public function ImageRotater(image:DisplayObject, numImages:int, duration:int) 
  {
   this.image = image;
   this.numImages = numImages;
   this.duration = duration;
   addImages();
   runTweens();
  }
 
  private function addImages():void
  {
   for (var i:int = 0; i < numImages; i++) 
   {
    addChild(image);
   }
  }
 
  private function runTweens():void
  {
   for (var j:int = 1; j < numImages; j++) 
   { 
    tween = new Tween(getChildAt(j), "rotation", Strong.easeOut, 0, ((360/numImages) * j), duration, true);
   }
  }
 }
}

and heres how I’m instantiating it: (Image is an exported movieclip with Image as its class name)


var ir = new ImageRotater(new Image(), 7, 5);

the error im getting is:

RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/getChildAt()
at ImageRotater/runTweens()
at ImageRotater()
at Main

as I said I was having no trouble when I wasnt passing Image to it and instead instantiating Image in the addImages() method as in:


private function addImages():void
  {
   for (var i:int = 0; i < numImages; i++) 
   {
image = new Image();    
addChild(image);
   }
  }

any ideas? thanks