External movie preload problem

Hi

I’ve a function to check the preloading of external SWF files. The code is below.

function checkStat (){
tracker.onEnterFrame = function() {
    loadingStatus._visible = true;
    var l = holder.getBytesLoaded();
    var t = holder.getBytesTotal();
    trace(t);

    var percent = Math.round(l/t*100);
    loadingStatus.homeLoad.text = percent+"%";
    //trace(percent+"% loaded");
    if (l>=t && t>0) {
        this.onEnterFrame = null;
        _root.holder.setMask (contentMask);
        _root.contentMask.gotoAndPlay(2);
        _root.closeB._visible = true;
        this._visible = false;
        loadingStatus._visible = false;
    }
};
}

It’s working fine except the case that is intially calling in the first frame like

// Here another code to just load the SWF file. Then
checkStat ();

In the above code this portion is skipping.

 if (l>=t && t>0) {
        this.onEnterFrame = null;
        _root.holder.setMask (contentMask);
        _root.contentMask.gotoAndPlay(2);
        _root.closeB._visible = true; h
        this._visible = false;
        loadingStatus._visible = false;
    }

If i call the checkStat () in a mouse click something like

mybutton.onRelase = function ()
{
//code for loading swf
checkStat () ;
}

it will work fine.

Any idea why it’s happening like this.

thanks in advance…