Hi there
I currently have a few movieclips that I load into another movieclip container
. I use the MovieClipLoader class to load them and make use of the onLoadProgress
, onLoadStart
, onLoadInit
, onLoadComplete
and onLoadError
listeners.
In the onLoadProgess
listener, I listen for the loaded bytes and total bytes and put the the percentage into another movieclip's (that I put on the stage temporarily to show the loading) textbox. Here is the problem, the loading movieclip begins playing on the 40% loaded mark and does not wait to load 100%. This is weird and I don't understand what I could be doing wrong. Here is my code:
// loading icon to show progress
var loading_icon:MovieClip = new MovieClip();
// load PassionPurpose.swf
var passionPurposeLoader = new MovieClipLoader();
var passionPurpose:MovieClip = this.container.createEmptyMovieClip("passionPurpose", this.container.getNextHighestDepth());
passionPurpose._y = groupOverviewHeight;
passionPurposeLoader.onLoadInit = function (targetMc:MovieClip) {
trace("Init... "+PPFile);
loading_icon._visible = false;
loading_icon.unloadMovie();
}
passionPurposeLoader.onLoadStart = function (targetMc:MovieClip) {
loading_icon = passionPurpose._parent.attachMovie("loading_icon_ch1","loading_icon_ch1",passionPurpose._parent.getNextHighestDepth());
loading_icon._x = 245 - loading_icon._width/2;
loading_icon._y = 207 - loading_icon._height/2;
loading_icon._visible = true;
}
passionPurposeLoader.onLoadComplete = function (targetMc:MovieClip) {
trace("Complete... "+PPFile);
loading_icon._visible = false;
loading_icon.unloadMovie();
}
// progress function
passionPurposeLoader.onLoadProgress = function(targetMc:MovieClip, loadedBytes:Number, totalBytes:Number) {
// determine percentage
var percentage:Number = Math.round(loadedBytes / totalBytes * 100);
trace("Loading... "+loadedBytes+"/"+totalBytes+" "+PPFile);
loading_icon.loading_txt.text = percentage + "%";
if (loadedBytes == totalBytes) loading_icon.unloadMovie();
}
// there was an error loading the movieclip
passionPurposeLoader.onLoadError = function (targetMC, errorCode) {
trace("Error");
}
Does anyone have some sort of explanation or solution?