# Preloader, movie loader, all in a class

**URL:** <https://forum.kirupa.com/t/preloader-movie-loader-all-in-a-class/275398>\
**Category:** Uncategorized\
**Created:** [November 13, 2008, 12:51pm UTC](https://forum.kirupa.com/t/preloader-movie-loader-all-in-a-class/275398 "2008-11-13T12:51:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![obmon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/obmon/32/3503_2.png) [@obmon](https://forum.kirupa.com/u/obmon)\
**Post date:** [November 13, 2008, 12:51pm UTC](https://forum.kirupa.com/t/preloader-movie-loader-all-in-a-class/275398/1 "2008-11-13T12:51:35Z")

</div>

Hello, and thanks in advance for your help.

I’m new to OOP in Flash 8. I created a class to load sub movies. This is what i have so far:

```php

/**
    Load Sub Stage class
    author: Ahmed I. Masri
    version: 1
    modified: 08/11/2008
    copyright: Ahmed I. Masri

    This code defines a custom class that loads the correct sub movie.
*/

// Load SubStage Class
class LoadSubStage {
    // Variable definitions
    private var linkToFile:String;
    //trace(activeStage);

    // Selection Constructor
    public function LoadSubStage (linkToFile) {
        // Check to see which file is loading
        if (linkToFile != "intro_stage.swf") {
            // do nothing
        } else {
            LIntroStage (linkToFile);
        }
    }
    
    // Constructor Function to Load Intro SubStage   
    private static function LIntroStage (linkToFile) {
        // Variable definitions
        var StageLoader = new MovieClipLoader();
        var Preloader = new Object();
        StageLoader.addListener(Preloader);
        
        // Create empty movie clip to place Intro SubStage
        var MC_emptyHolder:MovieClip = _root.createEmptyMovieClip ("MC_emptyHolder", 100);
        MC_emptyHolder._visible = false;
        MC_emptyHolder._x = 0;
        MC_emptyHolder._y = 55;
        
        // Function to handle the start of loading process
        Preloader.onLoadStart = function(targetMC) {
            // Place StageLoader onto stage to show progress of loading.
            _root.attachMovie("MC_stageLoader", "MC_stageLoader", 1000, {_x:100, _y:100});
        };
        
        // Function to handle progression of the loading process
        Preloader.onLoadProgress = function(targetMC, lBytes, tBytes) {
            // Update text field and loading progress bar in StageLoader to display percentage loaded
            _root.MC_stageLoader.MC_loadingProgressBar._width = (lBytes/tBytes)*100;
            _root.MC_stageLoader.txt_PercentLoaded.text = Math.round((lBytes/tBytes)*100);
        };
        
        // Function to handle the completion of the loading process
        Preloader.onLoadComplete = function(targetMC) {
            // Removes StageLoader and sets loaded content to visible
            //_root.MC_stageLoader._visible = false;
            MC_emptyHolder._visible = true;
            
        };
        
        // Loads the Intro SubStage
        StageLoader.loadClip(linkToFile, "MC_emptyHolder");
    }
}

```

Everything works, except that it seems that the onProgress part only runs once (the text box is only updated once). Can anyone tell me why this is? Or what i can look into?

Thanks again
