Preloader error

I have made a small preloader that I would like to implement but I’m getting some errors.

Preloader has 2 layers, one for text and one for AS.

Code:

var l:loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE.done);
l.load(new URLRequest("ATOITOrg6.swf"));
                      
function loop(e:ProgressEvent):void
{
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
    removeChildAt(0);
    percent = null;
    addChild(l);
}

Seems pretty simple, but I’m getting the following errors:

1046: Type was not found or was not a compile-time constant: loader.
1119: Access of possibly undefined property done through a reference with static type String.