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:MovieClip, whatToLoad:String, whereToLoad:MovieClip) {
this.loader_mc = preLoader_mc;
this.loadTarget = whatToLoad;
this.loadLevel = whereToLoad;
init();
}
private function init() {
loadMovieNum(loadTarget, loadLevel);
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 + "%";
}
};
}
}