0

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?

2 Answers 2

1

I am not much into as2 but it seems you can put stop in first frame of the loading movie (passionPurpose) so when first frame is loaded, it stops there only. And when the loading is complete then play the movie. Or in onLoadStart just pause the movie (passionMovie.gotoAndStop(1);) and when it completes (i.e. onLoadComplete) play it. And one more thing, you probably don't need two unloadMovie call for loading_icon, either put it in onLoadComplete or inside onLoadProgress.
If it doesn't work then you can try to make it invisible till it loads completely.

0

As bhups suggested, put a stop action on the first frame of your loaded clips, or stop them as soon as they have begun to load. Movieclips will play automatically as soon as a frame is loaded unless you tell them not to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.