getchildIndex help

I have a function called addRoom. A scroll pane with thumbnails of rooms, each thumbnail is a button. The viewport is empty by default. When I click a button the function is called, it adds a room to my viewport. If I click another button a new room is added but the first room still remains. How do I get the first room to be removed? I assume there is something wrong with my index.


// add room image to the viewport
function addRoom(event:MouseEvent):void {
    //trace(rmPictures[event.currentTarget]);
    var rmloader:Loader = new Loader();
    rmloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop, false, 0, true);
    rmloader.contentLoaderInfo.addEventListener(Event.COMPLETE, done, false, 0, true);
    rmloader.load(new URLRequest(rmPictures[event.currentTarget]));
    rmloader.x = 0;
    rmloader.y = 0;
    roomContainer.addChild(rmloader);

    //index the room as children
    var roomPosition:uint = roomContainer.numChildren - 1;
    roomContainer.setChildIndex(rmloader, roomPosition);
    //remove room on level one when adding another room.
    if (roomContainer.getChildIndex(rmloader) == 2) {
        roomContainer.removeChildAt(1);
    }
    //removeChild(myScrollPane);
    //removeChild(myContainer);
    //removeChild(texturePane);
    //removeChild(roomPane);
    colorText.alpha = 0;
}