.soulty
September 5th, 2003, 02:15 AM
Hey all, reading through Colin Moocks ASDG v2 come across a preloader which is
stop();
this.createEmptyMovieClip("loader",1);
this.loader.createEmptyMovieClip("totalBar",2);
this.loader.createEmptyMovieClip("loadedBar",3);
this.loader.createTextField("loadProgress_txt",4,80,10,200,20);
this.loader.loadedBar.lineStyle(5, 0xFF0000);
this.loader.totalBar.lineStyle(8, 0x000000);
this.loader.loadedBar.lineTo(250, 0);
this.loader.totalBar.lineTo(250, 0);
this.loader.onEnterFrame = function(){
this.percentDone = Math.floor((this._parent.getBytesLoaded()
/this._parent.getBytesTotal())*100);
this.loadProgress_txt.text= this.percentDone + "% complete";
this.loadedBar._xscale = this.percentDone;
this.loaded = this._parent._framesloaded;
if(this.loaded > 0 && this.loaded == this._parent._totalframes){
this._parent.gotoAndPlay("start");
this.removeMovieClip();
}
}
I pretty much understand whats going on, and its working fine, but as he mentions in the book in the as part has got me confused.
if(this.loaded > 0 && this.loaded == this._parent._totalframes){
}
He explain the following (extract from Colin Moocks ASDG v2)
"Notice that in our preloader examples we checked whether _framesloaded > 0 in addition to whether _framesloaded == _totalframes. This is necessary because when a movie is unloaded from a clip, that clip has a _totalframes of 0. Hence, if _framesloaded is 0 (as it might be on a very slow connection), the comparison _framesloaded == _totalframes can return true even when no frames have yet loaded. Our check prevents the movie from skipping ahead before the appopriate content had loaded. This precaution is not necessary with preloaders placed on the main timeline of loading .swf filesm because their _totalframes property is never 0.
Now does this mean that due to the preloader being created in a empty movie clip and by removing it at the end of the code, the _totalframes of it would return 0. So when next time the preloader is used on slow connection it would just thinks that it equals total frames. http://www.members.optusnet.com.au/paulsoultis/confused3b.gif
stop();
this.createEmptyMovieClip("loader",1);
this.loader.createEmptyMovieClip("totalBar",2);
this.loader.createEmptyMovieClip("loadedBar",3);
this.loader.createTextField("loadProgress_txt",4,80,10,200,20);
this.loader.loadedBar.lineStyle(5, 0xFF0000);
this.loader.totalBar.lineStyle(8, 0x000000);
this.loader.loadedBar.lineTo(250, 0);
this.loader.totalBar.lineTo(250, 0);
this.loader.onEnterFrame = function(){
this.percentDone = Math.floor((this._parent.getBytesLoaded()
/this._parent.getBytesTotal())*100);
this.loadProgress_txt.text= this.percentDone + "% complete";
this.loadedBar._xscale = this.percentDone;
this.loaded = this._parent._framesloaded;
if(this.loaded > 0 && this.loaded == this._parent._totalframes){
this._parent.gotoAndPlay("start");
this.removeMovieClip();
}
}
I pretty much understand whats going on, and its working fine, but as he mentions in the book in the as part has got me confused.
if(this.loaded > 0 && this.loaded == this._parent._totalframes){
}
He explain the following (extract from Colin Moocks ASDG v2)
"Notice that in our preloader examples we checked whether _framesloaded > 0 in addition to whether _framesloaded == _totalframes. This is necessary because when a movie is unloaded from a clip, that clip has a _totalframes of 0. Hence, if _framesloaded is 0 (as it might be on a very slow connection), the comparison _framesloaded == _totalframes can return true even when no frames have yet loaded. Our check prevents the movie from skipping ahead before the appopriate content had loaded. This precaution is not necessary with preloaders placed on the main timeline of loading .swf filesm because their _totalframes property is never 0.
Now does this mean that due to the preloader being created in a empty movie clip and by removing it at the end of the code, the _totalframes of it would return 0. So when next time the preloader is used on slow connection it would just thinks that it equals total frames. http://www.members.optusnet.com.au/paulsoultis/confused3b.gif