# External movie preload problem

**URL:** <https://forum.kirupa.com/t/external-movie-preload-problem/322165>\
**Category:** flash\
**Created:** [May 12, 2011, 4:36pm UTC](https://forum.kirupa.com/t/external-movie-preload-problem/322165 "2011-05-12T16:36:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NovemberRain](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@NovemberRain](https://forum.kirupa.com/u/NovemberRain)\
**Post date:** [May 12, 2011, 4:36pm UTC](https://forum.kirupa.com/t/external-movie-preload-problem/322165/1 "2011-05-12T16:36:58Z")

</div>

Hi

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

```auto
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

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

```

In the above code this portion is skipping.

```auto
 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…
