Dynamically instantiated components at runtime

I can’t get this to work. What am I doing wrong? Do I need to use the UIObject? How do I attach a component to a movie clip?

Thanks in advance.


import mx.controls.Loader;
class Slide 
{
    public var imageLoader:Loader;
    public var image_loc;
    
    public function Slide(loc:String){
        image_loc = loc;
        imageLoader = _root.createClassObject(Loader, image_loc, _root.getNextHighestDepth());
        imageLoader.scaleContent = false;
        imageLoader.load(image_loc);
    }
    public function getWidth():Number{
        return imageLoader._width;
    }
    public function getHeight():Number{
        return imageLoader._height;
    }
    public function getLoaded():Number{
        return imageLoader.percentLoaded;
    }
    public function shrink():Boolean{
        return true;
    }
    public function grow():Boolean{
        return true;
    }
}