dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: What data type is a _level???

  1. #1
    []D[][]V[][]D
    Join Date
    Feb 2001
    Location
    Clearwater - FL
    Posts
    227

    What data type is a _level???

    Hi all -
    I am playing again..
    so I have a AS2 class that I am passing a String containing a movieclip to load using loadMovieNum() and a Number to use as the _level to load it into. There is no problems with the loading, but I am also doing some preloading, so I need to be able to use the GetBytesLoaded, and GetBytesTotal method of the "_level" to be loaded.

    I am having a hard time trying to understand how I should reference the _level in question once I pass it to the Class.


    //usage (preloader_mc, loadTarget, loadLevel)
    var myPreloader = new scripts.CustomPreloader(preloader, "cme_heavyLoad.swf" , 1);

    PHP Code:
    class scripts.CustomPreloader {
        public var 
    loadTarget:String;
        private var 
    loader_mc:MovieClip;
        private var 
    loadLevel:MovieClip;
        function 
    CustomPreloader(preLoader_mc:MovieClipwhatToLoad:StringwhereToLoad:MovieClip) {
            
    this.loader_mc preLoader_mc;
            
    this.loadTarget whatToLoad;
            
    this.loadLevel whereToLoad;
            
    init();
        }
        private function 
    init() {
            
    loadMovieNum(loadTargetloadLevel);
            var 
    initialized null;
            var 
    preloaded null;
            
    //returns "undefined"
            
    trace(loadLevel);
            
    loader_mc.onEnterFrame = function() {
                if (
    initialized == null) {
                    
    initialized 1;
                    
    // get original x and y coordinates
                    
    trace(this.preBar._width);
                    var 
    the_x this.preBar._x;
                    var 
    the_y this.preBar._y;
                    
    // get the leftmost x of bar
                    
    var left_x the_x-((this.preBar._width)/2);
                    
    // start out with a scale of 0
                    
    this.preBar._xscale 0;
                }
                
    // if we're still preloading
                
    if (preloaded == null) {
                    
    // set xscale of bar equal to ratio of gBL over gBT
                    //
                    //THIS IS A BIG PROBLEM AREA _ WHERE IS MY _LEVEL HANDLE?
                    
    this.preBar._xscale Math.floor((loadLevel.getBytesLoaded()/loadLevel.getBytesTotal())*100);
                    
    // adjust x position so that bar is always left-aligned
                    
    this.preBar._x left_x+(this.preBar._width/2);
                    
    // display percentage in text field
                    //_parent.text.percent = preBar._xscale + "%";
                
    }
            };
        }


  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Well a _level is of type "movieclip" but a level doesn't exist until you've begun loading anything into it. Wich i think might take a little while after the call to loadMovieNum(); (I think I've read something about loadMovie-statements not being executed until all the rest of the current frames script has executed).

    Also I dont think you need to pass the level as you should be able to get it with the use of the "associative array":

    Code:
    whereToLoad = _root["_level" + loadLevel];
    /Mirandir

  3. #3
    []D[][]V[][]D
    Join Date
    Feb 2001
    Location
    Clearwater - FL
    Posts
    227
    Perfect, havent tried yet - but thank you.
    Thats exactly what I needed to see...

  4. #4
    []D[][]V[][]D
    Join Date
    Feb 2001
    Location
    Clearwater - FL
    Posts
    227
    No - I still get an undefined result...

    And I am not so sure about using _root in the Associative Array ....
    - Since the next _level would be outside of the scope of the _root timeline...
    Not sure though. what do you think?

    I will keep messing with it.

  5. #5
    []D[][]V[][]D
    Join Date
    Feb 2001
    Location
    Clearwater - FL
    Posts
    227
    more to the point -
    from inside of the onEnterFrame loop if I hard code the proper value I am looking for:
    trace(_level1.getBytesLoaded());
    It still returns undefined - ?
    But the level does load.

    Even if there is some issue with the chronology of loadMovie executing after the rest of the script - the onEnterFrame event is continuous...

    How can I get a handle on that _levelX ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center